温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:特瑞飞家教信息平台源码
当前文件:
HomeTeachingNet/DataBusiness/Teacher.cs[10K,2009-6-12 11:44:15],打开代码结构图
HomeTeachingNet/DataBusiness/Teacher.cs[10K,2009-6-12 11:44:15],打开代码结构图1using System; 2
using System.Collections.Generic; 3
using System.Text; 4
using System.Data; 5
using System.Data.SqlClient; 6
7
namespace DataBusiness 8
{ 9
public partial class Teacher 10
{ 11
public void UpdateTeacherInfo(int teacherID, string name, string sex, int age, string school, string course, string phone, string email, string address, string info) 12
{ 13
if (name != "") 14
{ 15
SqlParameter[] para1 = { 16
new SqlParameter("@teacherID", teacherID), 17
new SqlParameter("@columnName", "name"), 18
new SqlParameter("@columnValue",name) 19
}; 20
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 21
"updateTeacherInfo", para1); 22
} 23
if (sex != "") 24
{ 25
SqlParameter[] para1 = { 26
new SqlParameter("@teacherID", teacherID), 27
new SqlParameter("@columnName", "sex"), 28
new SqlParameter("@columnValue",sex) 29
}; 30
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 31
"updateTeacherInfo", para1); 32
} 33
if (age != 0) 34
{ 35
SqlParameter[] para1 = { 36
new SqlParameter("@teacherID", teacherID), 37
new SqlParameter("@columnName", "age"), 38
new SqlParameter("@columnValue",age.ToString()) 39
}; 40
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 41
"updateTeacherInfo", para1); 42
} 43
if (school != "") 44
{ 45
SqlParameter[] para1 = { 46
new SqlParameter("@teacherID", teacherID), 47
new SqlParameter("@columnName", "school"), 48
new SqlParameter("@columnValue",school) 49
}; 50
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 51
"updateTeacherInfo", para1); 52
} 53
if (course != "") 54
{ 55
SqlParameter[] para1 = { 56
new SqlParameter("@teacherID", teacherID), 57
new SqlParameter("@columnName", "course"), 58
new SqlParameter("@columnValue",course) 59
}; 60
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 61
"updateTeacherInfo", para1); 62
} 63
if (phone != "") 64
{ 65
SqlParameter[] para1 = { 66
new SqlParameter("@teacherID", teacherID), 67
new SqlParameter("@columnName", "phone"), 68
new SqlParameter("@columnValue",phone) 69
}; 70
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 71
"updateTeacherInfo", para1); 72
} 73
if (email != "") 74
{ 75
SqlParameter[] para1 = { 76
new SqlParameter("@teacherID", teacherID), 77
new SqlParameter("@columnName", "email"), 78
new SqlParameter("@columnValue",email) 79
}; 80
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 81
"updateTeacherInfo", para1); 82
} 83
if (address != "") 84
{ 85
SqlParameter[] para1 = { 86
new SqlParameter("@teacherID", teacherID), 87
new SqlParameter("@columnName", "address"), 88
new SqlParameter("@columnValue",address) 89
}; 90
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 91
"updateTeacherInfo", para1); 92
} 93
if (info != "") 94
{ 95
SqlParameter[] para1 = { 96
new SqlParameter("@teacherID", teacherID), 97
new SqlParameter("@columnName", "info"), 98
new SqlParameter("@columnValue",info) 99
}; 100
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 101
"updateTeacherInfo", para1); 102
} 103
} 104
105
public DataSet GetSearchTeacher(string theValue, int type) 106
{ 107
SqlParameter[] para = { 108
new SqlParameter("@value", theValue), 109
new SqlParameter("@type", type) 110
}; 111
112
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 113
"GetSearchTeacher", para); 114
} 115
116
public DataSet GetSearchTeacher2(string theValue, int type) 117
{ 118
SqlParameter[] para = { 119
new SqlParameter("@value", theValue), 120
new SqlParameter("@type", type) 121
}; 122
123
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 124
"GetSearchTeacher2", para); 125
} 126
127
public DataSet GetTeacherOrderList(int teacherID) 128
{ 129
SqlParameter[] para = { 130
new SqlParameter("@teacherID", teacherID) 131
}; 132
133
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 134
"GetTeacherOrderList", para); 135
} 136
public bool AddTeacher(string name, string sex, int age, string school, string course, string phone, string email, string address, string info, string regedit_time, string user_guid) 137
{ 138
SqlParameter[] para = { 139
new SqlParameter("@name", name), 140
new SqlParameter("@sex", sex), 141
new SqlParameter("@age", age), 142
new SqlParameter("@school", school), 143
new SqlParameter("@course", course), 144
new SqlParameter("@phone", phone), 145
new SqlParameter("@email", email), 146
new SqlParameter("@address", address), 147
new SqlParameter("@info", info), 148
new SqlParameter("@regedit_time", regedit_time), 149
new SqlParameter("@user_guid", user_guid), 150
151
}; 152
int ret = DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 153
"AddTeacher", para); 154
155
return (ret > 0); 156
} 157
158
public DataSet GetTeacherID(string teacherName, string regeditTime) 159
{ 160
SqlParameter[] para = { 161
new SqlParameter("@name", teacherName), 162
new SqlParameter("@regedit_time", regeditTime) 163
}; 164
165
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 166
"GetTeacherID", para); 167
} 168
169
170
public DataSet GetTeacherInfo(int teacherID) 171
{ 172
SqlParameter[] para = { 173
new SqlParameter("@teacherID", teacherID) 174
}; 175
176
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 177
"GetTeacherInfo", para); 178
} 179
180
public int Order_Require(int requireID, int teacherID) 181
{ 182
SqlParameter[] para = { 183
new SqlParameter("@requireID", requireID) 184
}; 185
// 1) 检测是否已经被预约 186
DataSet ds = DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 187
"CheckIsOrdered", para); 188
if (ds == null) 189
{ 190
return 1; 191
} 192
// 用于检测是否有数据返回 193
if (ds.Tables[0].Rows.Count == 0) 194
{ 195
return 1; 196
} 197
if (ds.Tables[0].Rows[0]["teacherID"].ToString() != "" && 198
ds.Tables[0].Rows[0]["teacherID"].ToString() != "0") 199
{ 200
return 2; 201
} 202
SqlParameter[] para2 = { 203
new SqlParameter("@teacherID", teacherID) 204
}; 205
ds = null; 206
// 2) 获取并判断教师余额是否足够支付此次信息费 207
ds = DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 208
"GetSelfMoney", para2); 209
if (ds == null) 210
return 3; 211
if (ds.Tables[0].Rows.Count == 0) 212
{ 213
return 1; 214
} 215
216
double money; 217
try 218
{ 219
money = double.Parse(ds.Tables[0].Rows[0]["money"].ToString()); 220
} 221
catch (System.FormatException e1) 222
{ 223
string szMsg = e1.Message; 224
return 3; 225
} 226
if (money < 50) 227
return 3; 228
money -= 10; 229
// 3) 更新教师的剩余金额并设置预约信息 230
SqlParameter[] para3 = { 231
new SqlParameter("@teacherID", teacherID), 232
new SqlParameter("@money", money) 233
}; 234
int ret = DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 235
"order_deal", para3); 236
SqlParameter[] para4 = { 237
new SqlParameter("@requireID", requireID), 238
new SqlParameter("@teacherID", teacherID) 239
}; 240
// 只有当更新余额成功后才设置预约信息 241
if (ret == 1 ) 242
{ 243
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, 244
"order_deal_updateRequire", para4); 245
} 246
return 0; 247
248
} 249
public DataSet GetNewTeacherList(int count) 250
{ 251
SqlParameter[] para = { 252
new SqlParameter("@count", count) 253
}; 254
255
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 256
"GetNewTeacherList", para); 257
} 258
public DataSet GetAllTeacherList() 259
{ 260
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 261
"GetAllTeacherList", null); 262
} 263
264
public DataSet GetTeacherMoneyInfo() 265
{ 266
return DataExecute.ExecuteDataset(DataExecute.CONN_STRING, CommandType.StoredProcedure, 267
"GetTeacherMoneyInfo", null); 268
} 269
270
public void UpdateMoney(int teacherID, double money) 271
{ 272
SqlParameter[] para = { 273
new SqlParameter("@teacherID", teacherID), 274
new SqlParameter("@money", money) 275
}; 276
DataExecute.ExecuteNonQuery(DataExecute.CONN_STRING, CommandType.StoredProcedure, "UpdateMoney", 277
para); 278
} 279
} 280
281
282
} 283






}
}