温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:MyShop网络商城源码(mvc开发)
当前文件路径:MyShop/BLL/Channel.cs

1using System; 2
using System.Collections.Generic; 3
using System.Data; 4
5
6
using MyShop.DALFactory; 7
using MyShop.IDAL; 8
using MyShop.Model; 9
10
11
namespace MyShop.BLL 12
...{ 13
public class Channel 14
...{ 15
private IChannel dal = DataAccess.CreateChannel(); 16
17
IChannel#region IChannel 18
19
public int Add(ChannelInfo model) 20
...{ 21
if (model == null) 22
...{ 23
return 0; 24
} 25
return dal.Add(model); 26
} 27
28
public int Delete(string filter) 29
...{ 30
if (string.IsNullOrEmpty(filter)) 31
return 0; 32
return dal.Delete(filter); 33
} 34
35
public bool Exist(string filter) 36
...{ 37
filter = filter.Trim(); 38
if (string.IsNullOrEmpty(filter)) 39
return false; 40
return dal.Exist(filter); 41
} 42
public DataSet GetDataSet() 43
...{ 44
return dal.GetDataSet(); 45
} 46
47
public DataSet GetDataSet(string filter) 48
...{ 49
filter = filter.Trim(); 50
if (string.IsNullOrEmpty(filter)) 51
return null; 52
return dal.GetDataSet(filter); 53
} 54
55
public ChannelInfo GetModel(DataRow dr) 56
...{ 57
if (dr == null) 58
return null; 59
return dal.GetModel(dr); 60
} 61
62
private DataSet Query(string sql) 63
...{ 64
sql = sql.Trim(); 65
if (string.IsNullOrEmpty(sql)) 66
return null; 67
return dal.Query(sql); 68
} 69
70
public int Update(ChannelInfo model, string filter) 71
...{ 72
if (model == null) 73
return 0; 74
filter = filter.Trim(); 75
if (string.IsNullOrEmpty(filter)) 76
return 0; 77
return dal.Update(model, filter); 78
} 79
80
#endregion 81
82
common#region common 83
84
public int Add(ChannelInfo model, out string msg) 85
...{ 86
msg = ""; 87
if (model == null) 88
...{ 89
msg = msg + "<li>数据不能为空</li>"; 90
return 0; 91
} 92
bool isErr = false; 93
94
if (isErr) 95
return 0; 96
97
int count = 0; 98
count = Add(model); 99
if (count == 0) 100
msg = "<li>系统发生错误,请重新添加!</li>"; 101
if (count == 1) 102
msg = "<li>添加成功!</li>"; 103
return count; 104
} 105
106
public int Delete(int channelId) 107
...{ 108
if (string.IsNullOrEmpty(channelId.ToString())) 109
return 0; 110
string filer; 111
filer = " channelId =" + channelId; 112
return Delete(filer); 113
} 114
public int Update(ChannelInfo model) 115
...{ 116
117
if (model == null) 118
...{ 119
return 0; 120
} 121
string filter; 122
filter = " channelId=" + model.ChannelID; 123
return Update(model, filter); 124
} 125
126
public ChannelInfo GetModel(int channelId) 127
...{ 128
DataSet dataset = new DataSet(); 129
dataset = GetDataSet(" channelId=" + channelId); 130
if (dataset != null && dataset.Tables[0].Rows.Count > 0) 131
return GetModel(dataset.Tables[0].Rows[0]); 132
return null; 133
} 134
135
136
/**//// <summary> 137
/// 系统商品频道 138
/// </summary> 139
/// <returns></returns> 140
public ChannelInfo GetShopModel() 141
...{ 142
DataSet dataset = new DataSet(); 143
dataset = GetDataSet(" [channelID] = 2 "); 144
if (dataset != null && dataset.Tables[0].Rows.Count > 0) 145
return GetModel(dataset.Tables[0].Rows[0]); 146
return null; 147
} 148
149
/**//// <summary> 150
/// 系统文章频道 151
/// </summary> 152
/// <returns></returns> 153
public ChannelInfo GetArticlepModel() 154
...{ 155
DataSet dataset = new DataSet(); 156
dataset = GetDataSet(" [channelID] = 1 "); 157
if (dataset != null && dataset.Tables[0].Rows.Count > 0) 158
return GetModel(dataset.Tables[0].Rows[0]); 159
return null; 160
} 161
162
163
/**//// <summary> 164
/// 返回可用的频道 165
/// </summary> 166
/// <returns></returns> 167
public DataSet GetDataSetChannelNav() 168
...{ 169
string filter = " [disabled] = 0 Order by OrderId "; 170
return GetDataSet(filter); 171
} 172
173
174
#endregion 175
176
后台管理#region 后台管理 177
178
public DataSet GetDataSetOrderByOrderId() 179
...{ 180
return GetDataSet(" [channelId] > 0 Order by OrderId "); 181
} 182
/**//// <summary> 183
/// 启用或禁用 184
/// </summary> 185
/// <param name="channelId"></param> 186
/// <returns></returns> 187
public int Enable(int channelId,bool action) 188
...{ 189
ChannelInfo model = new ChannelInfo(); 190
model = GetModel(channelId); 191
if (model == null) 192
return 0; 193
194
model.Disabled = action? 0 :1; 195
return Update(model); 196
} 197
198
199
/**//// <summary> 200
/// 频道是否存在 201
/// </summary> 202
/// <param name="channelName"></param> 203
/// <returns></returns> 204
public bool IsExist(string channelName) 205
...{ 206
channelName = channelName.Trim(); 207
if (Utils.ChkBadChar(channelName)) 208
return false; 209
if (Exist(" [channelName] = '" + Utils.ReplaceBadSQL(channelName.Trim()) + "' ")) 210
...{ 211
return true; 212
} 213
else 214
return false; 215
} 216
217
218
#endregion 219
} 220
} 221





}
}