温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:新宇科技企业网站管理系统.net源码(三层)
当前文件:
XinYuCompanyManageSystem/DAL/ProductSQL.cs[11K,2009-6-12 11:59:35],打开代码结构图
XinYuCompanyManageSystem/DAL/ProductSQL.cs[11K,2009-6-12 11:59:35],打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Text; 6
using System.Collections.Generic; 7
using System.Data.SqlClient; 8
using SQLHelper; 9
using Model; 10
/// <summary> 11
/// ProductSQL 的摘要说明 12
/// </summary> 13
namespace DAL 14
{ 15
public class ProductSQL 16
{ 17
/// <summary> 18
/// 添加商品 19
/// </summary> 20
/// <param name="product"></param> 21
/// <returns></returns> 22
public int Add_Product(Product product) 23
{ 24
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 25
SqlParameter[] ParamList ={ 26
sqlHelper.CreateInParam("@ClassID",SqlDbType.Int,4,product.productClass.ClassID), 27
sqlHelper.CreateInParam("@Pro_Name",SqlDbType.NVarChar,50,product.Pro_Name), 28
sqlHelper.CreateInParam("@Pic",SqlDbType.NVarChar,255,product.Pic), 29
sqlHelper.CreateInParam("@Content",SqlDbType.NText,0,product.Content), 30
sqlHelper.CreateInParam("@Updatatime",SqlDbType.DateTime,8,product.Updatatime), 31
sqlHelper.CreateInParam("@Click",SqlDbType.Int,4,product.Click) 32
}; 33
try 34
{ 35
return (sqlHelper.RunProc("Add_Product", ParamList)); 36
} 37
catch (Exception ex) 38
{ 39
SystemError.CreateErrorLog(ex.Message); 40
throw new Exception(ex.Message, ex); 41
} 42
} 43
/// <summary> 44
/// 修改商品 45
/// </summary> 46
/// <param name="product"></param> 47
public void Update_Product(Product product) 48
{ 49
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 50
SqlParameter[] ParamList ={ 51
sqlHelper.CreateInParam("@ID",SqlDbType.Int,4,product.ID), 52
sqlHelper.CreateInParam("@ClassID",SqlDbType.Int,4,product.productClass.ClassID), 53
sqlHelper.CreateInParam("@Pro_Name",SqlDbType.NVarChar,50,product.Pro_Name), 54
sqlHelper.CreateInParam("@Pic",SqlDbType.NVarChar,255,product.Pic), 55
sqlHelper.CreateInParam("@Content",SqlDbType.NText,0,product.Content), 56
sqlHelper.CreateInParam("@Updatatime",SqlDbType.DateTime,8,product.Updatatime), 57
sqlHelper.CreateInParam("@Click",SqlDbType.Int,4,product.Click) 58
}; 59
try 60
{ 61
sqlHelper.RunProc("Update_Product", ParamList); 62
} 63
catch (Exception ex) 64
{ 65
SystemError.CreateErrorLog(ex.Message); 66
throw new Exception(ex.Message, ex); 67
} 68
} 69
/// <summary> 70
/// 删除商品 71
/// </summary> 72
/// <param name="nID"></param> 73
public void Delete_Product(int nID) 74
{ 75
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 76
SqlParameter[] ParamList ={ 77
sqlHelper.CreateInParam("@ID",SqlDbType.Int,4,nID) 78
}; 79
try 80
{ 81
sqlHelper.RunProc("Delete_Product", ParamList); 82
} 83
catch (Exception ex) 84
{ 85
SystemError.CreateErrorLog(ex.Message); 86
throw new Exception(ex.Message, ex); 87
} 88
} 89
/// <summary> 90
/// 查看全部商品 91
/// </summary> 92
/// <param name="nstartIndex"></param> 93
/// <param name="nendIndex"></param> 94
/// <returns></returns> 95
public List<Product> Get_Product(int nstartIndex, int nendIndex) 96
{ 97
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 98
SqlParameter[] ParamList ={ 99
sqlHelper.CreateInParam("@startIndex",SqlDbType.Int,4,nstartIndex), 100
sqlHelper.CreateInParam("@endIndex",SqlDbType.Int,4,nendIndex), 101
sqlHelper.CreateInParam("@docount",SqlDbType.Bit,1,0) 102
}; 103
SqlDataReader rec = null; 104
try 105
{ 106
sqlHelper.RunProc("Get_Product", ParamList, out rec); 107
} 108
catch (Exception ex) 109
{ 110
SystemError.CreateErrorLog(ex.Message); 111
throw new Exception(ex.Message, ex); 112
} 113
List<Product> List_product = new List<Product>(); 114
while (rec.Read()) 115
{ 116
Product product = new Product(); 117
ProductClass productClass = new ProductClass(); 118
ProductClassSQL productClassSQL = new ProductClassSQL(); 119
productClass = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString())); 120
product.productClass = productClass; 121
product.ID = Int32.Parse(rec["ID"].ToString()); 122
product.Pro_Name = rec["Pro_Name"].ToString(); 123
product.Pic = rec["Pic"].ToString(); 124
product.Content = rec["Content"].ToString(); 125
product.Updatatime = DateTime.Parse(rec["Updatatime"].ToString()); 126
product.Click = Int32.Parse(rec["Click"].ToString()); 127
List_product.Add(product); 128
product = null; 129
productClass = null; 130
} 131
return List_product; 132
} 133
/// <summary> 134
/// 查看全部商品总数 135
/// </summary> 136
/// <param name="nstartIndex"></param> 137
/// <param name="nendIndex"></param> 138
/// <returns></returns> 139
public int Get_ProductNum() 140
{ 141
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 142
SqlParameter[] ParamList ={ 143
sqlHelper.CreateInParam("@startIndex",SqlDbType.Int,4,1), 144
sqlHelper.CreateInParam("@endIndex",SqlDbType.Int,4,1), 145
sqlHelper.CreateInParam("@docount",SqlDbType.Bit,1,1) 146
}; 147
SqlDataReader rec = null; 148
try 149
{ 150
sqlHelper.RunProc("Get_Product", ParamList, out rec); 151
} 152
catch (Exception ex) 153
{ 154
SystemError.CreateErrorLog(ex.Message); 155
throw new Exception(ex.Message, ex); 156
} 157
int Num = 0; 158
while(rec.Read()) 159
{ 160
Num = Int32.Parse(rec["Counts"].ToString()); 161
} 162
return Num; 163
} 164
/// <summary> 165
/// 按分类查看商品 166
/// </summary> 167
/// <param name="nstartIndex"></param> 168
/// <param name="nendIndex"></param> 169
/// <param name="nClassID"></param> 170
/// <returns></returns> 171
public List<Product> Get_Product(int nstartIndex, int nendIndex, int nClassID) 172
{ 173
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 174
SqlParameter[] ParamList ={ 175
sqlHelper.CreateInParam("@startIndex",SqlDbType.Int,4,nstartIndex), 176
sqlHelper.CreateInParam("@endIndex",SqlDbType.Int,4,nendIndex), 177
sqlHelper.CreateInParam("@Classid",SqlDbType.Int,4,nClassID), 178
sqlHelper.CreateInParam("@docount",SqlDbType.Bit,1,0) 179
}; 180
SqlDataReader rec = null; 181
try 182
{ 183
sqlHelper.RunProc("Get_ClassProduct", ParamList, out rec); 184
} 185
catch (Exception ex) 186
{ 187
SystemError.CreateErrorLog(ex.Message); 188
throw new Exception(ex.Message, ex); 189
} 190
List<Product> List_product = new List<Product>(); 191
while (rec.Read()) 192
{ 193
Product product = new Product(); 194
ProductClass productClass = new ProductClass(); 195
ProductClassSQL productClassSQL = new ProductClassSQL(); 196
productClass = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString())); 197
product.productClass = productClass; 198
product.ID = Int32.Parse(rec["ID"].ToString()); 199
product.Pro_Name = rec["Pro_Name"].ToString(); 200
product.Pic = rec["Pic"].ToString(); 201
product.Content = rec["Content"].ToString(); 202
product.Updatatime = DateTime.Parse(rec["Updatatime"].ToString()); 203
product.Click = Int32.Parse(rec["Click"].ToString()); 204
List_product.Add(product); 205
product = null; 206
productClass = null; 207
} 208
return List_product; 209
} 210
/// <summary> 211
/// 按分类查看商品总数 212
/// </summary> 213
/// <param name="nstartIndex"></param> 214
/// <param name="nendIndex"></param> 215
/// <param name="nClassID"></param> 216
/// <returns></returns> 217
public int Get_ProductNum(int nClassID) 218
{ 219
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 220
SqlParameter[] ParamList ={ 221
sqlHelper.CreateInParam("@startIndex",SqlDbType.Int,4,1), 222
sqlHelper.CreateInParam("@endIndex",SqlDbType.Int,4,1), 223
sqlHelper.CreateInParam("@Classid",SqlDbType.Int,4,nClassID), 224
sqlHelper.CreateInParam("@docount",SqlDbType.Bit,1,1) 225
}; 226
SqlDataReader rec = null; 227
try 228
{ 229
sqlHelper.RunProc("Get_ClassProduct", ParamList, out rec); 230
} 231
catch (Exception ex) 232
{ 233
SystemError.CreateErrorLog(ex.Message); 234
throw new Exception(ex.Message, ex); 235
} 236
int Num = 0; 237
while (rec.Read()) 238
{ 239
Num = Int32.Parse(rec["Counts"].ToString()); 240
} 241
return Num; 242
} 243
/// <summary> 244
/// 查看单个商品 245
/// </summary> 246
/// <param name="nID"></param> 247
/// <returns></returns> 248
public Product Get_SingProduct(int nID) 249
{ 250
SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper(); 251
SqlParameter[] ParamList ={ 252
sqlHelper.CreateInParam("@ID",SqlDbType.Int,4,nID) 253
}; 254
SqlDataReader rec = null; 255
try 256
{ 257
sqlHelper.RunProc("Get_SingProduct", ParamList, out rec); 258
} 259
catch (Exception ex) 260
{ 261
SystemError.CreateErrorLog(ex.Message); 262
throw new Exception(ex.Message, ex); 263
} 264
Product product = new Product(); 265
while (rec.Read()) 266
{ 267
ProductClass productClass = new ProductClass(); 268
ProductClassSQL productClassSQL = new ProductClassSQL(); 269
productClass = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString())); 270
product.productClass = productClass; 271
product.ID = Int32.Parse(rec["ID"].ToString()); 272
product.Pro_Name = rec["Pro_Name"].ToString(); 273
product.Pic = rec["Pic"].ToString(); 274
product.Content = rec["Content"].ToString(); 275
product.Updatatime = DateTime.Parse(rec["Updatatime"].ToString()); 276
product.Click = Int32.Parse(rec["Click"].ToString()); 277
} 278
return product; 279
} 280
281
} 282
} 283








