温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyShop网络商城080617源码
当前文件:
MyShop080617/AccessDAL/Channel.cs,打开代码结构图
MyShop080617/AccessDAL/Channel.cs,打开代码结构图1using System; 2
using System.Collections.Generic; 3
using System.Data; 4
using System.Data.OleDb; 5
using MyShop.IDAL; 6
using MyShop.Model; 7
8
9
namespace MyShop.AccessDAL 10
...{ 11
public class Channel:IChannel 12
...{ 13
private ConfigInfo configInfo = new ConfigInfo(); 14
private string tableName = "Ljh_Channel"; 15
16
public Channel() 17
...{ 18
if (!string.IsNullOrEmpty(configInfo.TablePrefix.Trim())) 19
tableName = configInfo.TablePrefix + "Channel"; 20
} 21
22
IChannel member#region IChannel member 23
24
25
/**//// <summary> 26
/// add 27
/// </summary> 28
/// <param name="model"></param> 29
/// <returns>返回ID, 如果发生错误则返回-1</returns> 30
public int Add(ChannelInfo model) 31
...{ 32
if (model == null) 33
...{ 34
return -1; 35
} 36
string commandText = "insert into " + this.tableName + "(ChannelName,ChannelShortName\t,ChannelItemUnit,Meta_Keywords,Meta_Description,ChannelPicUrl,OrderID,OpenType,ChannelDir,ModuleType,Disabled,ShowName,ShowNameOnPath,ShowClassTreeGuide,ShowSuspensionPoints,CheckLevel,EnableUploadFile,UploadDir,MaxFileSize,HitsOfHot,DaysOfNew,UpFileType,DefaultSkinID,Template_Index,UseCreateHTML,CommentCount,SpecialCount,HitsCount,StructureType,AutoCreateType,FileExt_Index,FileExt_List,FileExt_Item,ChannelPurview,arrGroupID,JS_SpecialNum,AuthorInfoLen,MaxPerPage_Index,MaxPerPage_SearchResult,MaxPerPage_New,MaxPerPage_Hot,MaxPerPage_Elite,MaxPerPage_SpecialList,TimingCreateSetting,EmailOfReject,EmailOfPassed,Custom_Content,Fields_Options,ChannelType,LinkUrl) values(@ChannelName,@ChannelShortName\t,@ChannelItemUnit,@Meta_Keywords,@Meta_Description,@ChannelPicUrl,@OrderID,@OpenType,@ChannelDir,@ModuleType,@Disabled,@ShowName,@ShowNameOnPath,@ShowClassTreeGuide,@ShowSuspensionPoints,@CheckLevel,@EnableUploadFile,@UploadDir,@MaxFileSize,@HitsOfHot,@DaysOfNew,@UpFileType,@DefaultSkinID,@Template_Index,@UseCreateHTML,@CommentCount,@SpecialCount,@HitsCount,@StructureType,@AutoCreateType,@FileExt_Index,@FileExt_List,@FileExt_Item,@ChannelPurview,@arrGroupID,@JS_SpecialNum,@AuthorInfoLen,@MaxPerPage_Index,@MaxPerPage_SearchResult,@MaxPerPage_New,@MaxPerPage_Hot,@MaxPerPage_Elite,@MaxPerPage_SpecialList,@TimingCreateSetting,@EmailOfReject,@EmailOfPassed,@Custom_Content,@Fields_Options,@ChannelType,@LinkUrl) "; 37
OleDbParameter[] commandParameters = ...{ 38
Database.MakeInParam("@ChannelName", OleDbType.VarWChar , 20 ,model.ChannelName ), 39
Database.MakeInParam("@ChannelShortName", OleDbType.VarWChar , 20 ,model.ChannelShortName ), 40
Database.MakeInParam("@ChannelItemUnit", OleDbType.VarWChar , 20 ,model.ChannelItemUnit ), 41
Database.MakeInParam("@Meta_Keywords", OleDbType.VarWChar , 255 ,model.Meta_Keywords ), 42
Database.MakeInParam("@Meta_Description", OleDbType.VarWChar , 255 ,model.Meta_Description ), 43
Database.MakeInParam("@ChannelPicUrl", OleDbType.VarWChar , 50 ,model.ChannelPicUrl ), 44
Database.MakeInParam("@OrderID", OleDbType.Integer , 4 ,model.OrderID ), 45
Database.MakeInParam("@OpenType", OleDbType.Integer , 4 ,model.OpenType ), 46
Database.MakeInParam("@ChannelDir", OleDbType.VarWChar , 50 ,model.ChannelDir ), 47
Database.MakeInParam("@ModuleType", OleDbType.Integer , 4 ,model.ModuleType ), 48
Database.MakeInParam("@Disabled", OleDbType.UnsignedTinyInt , 1 ,model.Disabled ), 49
Database.MakeInParam("@ShowName", OleDbType.UnsignedTinyInt , 1 ,model.ShowName ), 50
Database.MakeInParam("@ShowNameOnPath", OleDbType.UnsignedTinyInt , 1 ,model.ShowNameOnPath ), 51
Database.MakeInParam("@ShowClassTreeGuide", OleDbType.UnsignedTinyInt , 1 ,model.ShowClassTreeGuide ), 52
Database.MakeInParam("@ShowSuspensionPoInts", OleDbType.UnsignedTinyInt , 1 ,model.ShowSuspensionPoints ), 53
Database.MakeInParam("@CheckLevel", OleDbType.Integer , 4 ,model.CheckLevel ), 54
Database.MakeInParam("@EnableUploadFile", OleDbType.UnsignedTinyInt , 1 ,model.EnableUploadFile ), 55
Database.MakeInParam("@UploadDir", OleDbType.VarWChar , 50 ,model.UploadDir ), 56
57
Database.MakeInParam("@MaxFileSize", OleDbType.Integer , 4 ,model.MaxFileSize ), 58
Database.MakeInParam("@HitsOfHot", OleDbType.Integer , 4 ,model.HitsOfHot ), 59
Database.MakeInParam("@DaysOfNew", OleDbType.Integer , 4 ,model.DaysOfNew ), 60
Database.MakeInParam("@UpFileType", OleDbType.VarWChar , 255 ,model.UpFileType ), 61
Database.MakeInParam("@DefaultSkinID", OleDbType.Integer , 4 ,model.DefaultSkinID ), 62
Database.MakeInParam("@Template_Index", OleDbType.Integer , 4 ,model.Template_Index ), 63
Database.MakeInParam("@UseCreateHTML", OleDbType.Integer , 4 ,model.UseCreateHTML ), 64
Database.MakeInParam("@CommentCount", OleDbType.Integer , 4 ,model.CommentCount ), 65
Database.MakeInParam("@SpecialCount", OleDbType.Integer , 4 ,model.SpecialCount ), 66
Database.MakeInParam("@HitsCount", OleDbType.Integer , 4 ,model.HitsCount ), 67
Database.MakeInParam("@StructureType", OleDbType.Integer , 4 ,model.StructureType ), 68
Database.MakeInParam("@AutoCreateType", OleDbType.Integer , 4 ,model.AutoCreateType ), 69
Database.MakeInParam("@FileExt_Index", OleDbType.Integer , 4 ,model.FileExt_Index ), 70
Database.MakeInParam("@FileExt_List", OleDbType.Integer , 4 ,model.FileExt_List ), 71
Database.MakeInParam("@FileExt_Item", OleDbType.Integer , 4 ,model.FileExt_Item ), 72
Database.MakeInParam("@ChannelPurview", OleDbType.Integer , 4 ,model.ChannelPurview ), 73
Database.MakeInParam("@arrGroupID", OleDbType.VarWChar , 255 ,model.arrGroupID ), 74
Database.MakeInParam("@JS_SpecialNum", OleDbType.Integer , 4 ,model.JS_SpecialNum ), 75
76
Database.MakeInParam("@AuthorInfoLen", OleDbType.Integer , 4 ,model.AuthorInfoLen ), 77
Database.MakeInParam("@MaxPerPage_Index", OleDbType.Integer , 4 ,model.MaxPerPage_Index ), 78
Database.MakeInParam("@MaxPerPage_SearchResult", OleDbType.Integer , 4 ,model.MaxPerPage_SearchResult ), 79
Database.MakeInParam("@MaxPerPage_New", OleDbType.Integer , 4 ,model.MaxPerPage_New ), 80
Database.MakeInParam("@MaxPerPage_Hot", OleDbType.Integer , 4 ,model.MaxPerPage_Hot ), 81
Database.MakeInParam("@MaxPerPage_Elite", OleDbType.Integer , 4 ,model.MaxPerPage_Elite ), 82
Database.MakeInParam("@MaxPerPage_SpecialList", OleDbType.Integer , 4 ,model.MaxPerPage_SpecialList ), 83
Database.MakeInParam("@TimingCreateSetting", OleDbType.VarWChar , 0 ,model.TimingCreateSetting ), 84
Database.MakeInParam("@EmailOfReject", OleDbType.VarWChar , 0 ,model.EmailOfReject ), 85
Database.MakeInParam("@EmailOfPassed", OleDbType.VarWChar , 0 ,model.EmailOfPassed ), 86
Database.MakeInParam("@Custom_Content", OleDbType.VarWChar , 0 ,model.Custom_Content ), 87
Database.MakeInParam("@Fields_Options", OleDbType.VarWChar , 0 ,model.Fields_Options ), 88
Database.MakeInParam("@ChannelType", OleDbType.UnsignedTinyInt , 1 ,model.ChannelType ), 89
Database.MakeInParam("@LinkUrl", OleDbType.VarWChar , 200 ,model.LinkUrl ) 90
}; 91
int intIdentity = -1; 92
try 93
...{ 94
Database.ExecuteNonQuery(CommandType.Text, out intIdentity, commandText, commandParameters); 95
} 96
catch (Exception exception) 97
...{ 98
throw exception; 99
} 100
return intIdentity; 101
} 102
103
104
105
106
/**//// <summary> 107
/// 删除 108
/// </summary> 109
/// <param name="filter">where后面的条件语句,不加where</param> 110
/// <returns>返回影响行数</returns> 111
public int Delete(string filter) 112
...{ 113
int count = -1; 114
string sql = @"delete from " + tableName; 115
if (!string.IsNullOrEmpty(filter.Trim())) 116
...{ 117
sql = sql + " where " + filter; 118
} 119
try 120
...{ 121
122
count = Database.ExecuteNonQuery(sql); 123
} 124
catch (Exception ex) 125
...{ 126
throw ex; 127
} 128
return count; 129
} 130
131
/**//// <summary> 132
/// 133
/// </summary> 134
/// <param name="filter"></param> 135
/// <returns></returns> 136
public bool Exist(string filter) 137
...{ 138
bool result = false; 139
string sql = @"select * from " + tableName; 140
if (!string.IsNullOrEmpty(filter)) 141
...{ 142
sql = sql + " where " + filter; 143
} 144
try 145
...{ 146
147
148
DataSet dataset = new DataSet(); 149
dataset = Database.ExecuteDataSet(sql); 150
if (dataset.Tables[0].Rows.Count > 0) 151
...{ 152
result = true; 153
} 154
} 155
catch (Exception ex) 156
...{ 157
throw ex; 158
} 159
return result; 160
} 161
162
/**//// <summary> 163
/// 返回所有 164
/// </summary> 165
/// <returns>返回所有</returns> 166
public DataSet GetDataSet() 167
...{ 168
string sql = "select * from " + tableName; 169
DataSet dataset = new DataSet(); 170
try 171
...{ 172
173
dataset = Database.ExecuteDataSet(sql); 174
175
} 176
catch (Exception ex) 177
...{ 178
throw ex; 179
} 180
return dataset; 181
} 182
183
public DataSet GetDataSet(string filter) 184
...{ 185
if (string.IsNullOrEmpty(filter)) 186
return null; 187
188
string sql = "select * from " + tableName + " where " + filter; 189
DataSet dataset = new DataSet(); 190
try 191
...{ 192
193
dataset = Database.ExecuteDataSet(sql); 194
} 195
catch (Exception ex) 196
...{ 197
throw ex; 198
} 199
return dataset; 200
} 201
202
/**//// <summary> 203
/// 204
/// </summary> 205
/// <param name="dr"></param> 206
/// <returns></returns> 207
public ChannelInfo GetModel(DataRow dr) 208
...{ 209
if (dr == null) 210
return null; 211
ChannelInfo model = new ChannelInfo(); 212
213
if (dr["ChannelID"].ToString() != "") model.ChannelID = Convert.ToInt32( dr["ChannelID"].ToString()); 214
if (dr["ChannelName"].ToString() != "") model.ChannelName = dr["ChannelName"].ToString(); 215
if (dr["ChannelShortName"].ToString() != "") model.ChannelShortName = dr["ChannelShortName"].ToString(); 216
if (dr["ChannelItemUnit"].ToString() != "") model.ChannelItemUnit = dr["ChannelItemUnit"].ToString(); 217
if (dr["Meta_Keywords"].ToString() != "") model.Meta_Keywords = dr["Meta_Keywords"].ToString(); 218
if (dr["Meta_Description"].ToString() != "") model.Meta_Description = dr["Meta_Description"].ToString(); 219
if (dr["ChannelPicUrl"].ToString() != "") model.ChannelPicUrl = dr["ChannelPicUrl"].ToString(); 220
if (dr["OrderID"].ToString() != "") model.OrderID = Convert.ToInt32( dr["OrderID"].ToString()); 221
if (dr["OpenType"].ToString() != "") model.OpenType = Convert.ToInt32( dr["OpenType"].ToString()); 222
if (dr["ChannelDir"].ToString() != "") model.ChannelDir = dr["ChannelDir"].ToString(); 223
224
225
if (dr["ModuleType"].ToString() != "") model.ModuleType= Convert.ToInt32( dr["ModuleType"].ToString()); 226
if (dr["Disabled"].ToString() != "") model.Disabled= Convert.ToInt32( dr["Disabled"]); 227
if (dr["ShowName"].ToString() != "") model.ShowName= Convert.ToInt32( dr["ShowName"]); 228
if (dr["ShowNameOnPath"].ToString() != "") model.ShowNameOnPath= Convert.ToInt32( dr["ShowNameOnPath"]); 229
if (dr["ShowClassTreeGuide"].ToString() != "") model.ShowClassTreeGuide= Convert.ToInt32( dr["ShowClassTreeGuide"]); 230
231
if (dr["ShowSuspensionPoints"].ToString() != "") model.ShowSuspensionPoints= Convert.ToInt32( dr["ShowSuspensionPoints"]); 232
if (dr["CheckLevel"].ToString() != "") model.CheckLevel= Convert.ToInt32( dr["CheckLevel"].ToString()); 233
if (dr["EnableUploadFile"].ToString() != "") model.EnableUploadFile= Convert.ToInt32( dr["EnableUploadFile"]); 234
if (dr["UploadDir"].ToString() != "") model.UploadDir = dr["UploadDir"].ToString(); 235
if (dr["MaxFileSize"].ToString() != "") model.MaxFileSize= Convert.ToInt32( dr["MaxFileSize"].ToString()); 236
237
238
239
if (dr["HitsOfHot"].ToString() != "") model.HitsOfHot = Convert.ToInt32( dr["HitsOfHot"].ToString()); 240
if (dr["DaysOfNew"].ToString() != "") model.DaysOfNew = Convert.ToInt32( dr["DaysOfNew"]); 241
if (dr["UpFileType"].ToString() != "") model.UpFileType = dr["UpFileType"].ToString(); 242
if (dr["DefaultSkinID"].ToString() != "") model.DefaultSkinID = Convert.ToInt32( dr["DefaultSkinID"].ToString()); 243
if (dr["Template_Index"].ToString() != "") model.Template_Index = Convert.ToInt32( dr["Template_Index"].ToString()); 244
if (dr["UseCreateHTML"].ToString() != "") model.UseCreateHTML = Convert.ToInt32( dr["UseCreateHTML"].ToString()); 245
if (dr["CommentCount"].ToString() != "") model.CommentCount = Convert.ToInt32( dr["CommentCount"].ToString()); 246
if (dr["SpecialCount"].ToString() != "") model.SpecialCount = Convert.ToInt32( dr["SpecialCount"].ToString()); 247
if (dr["HitsCount"].ToString() != "") model.HitsCount = Convert.ToInt32( dr["HitsCount"].ToString()); 248
if (dr["StructureType"].ToString() != "") model.StructureType = Convert.ToInt32( dr["StructureType"].ToString())





}