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

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





}
}