温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:个人图书管理系统源码
当前文件路径:MyLibary/App_Code/BusinessLogicLayer/Users.cs

1using System; 2
using System.Data; 3
using System.Collections; 4
using System.Data.SqlClient; 5
using MyLibrary.DataAccessLayer; 6
using MyLibrary.DataAccessHelper; 7
8
//51_a_s_p_x.c_o_m 9
namespace MyLibrary.BusinessLogicLayer 10
...{ 11
//用户类 12
public class Users 13
...{ 14
私有成员#region 私有成员 15
private string _userID; //用户编号 16
private string _userPassword; //用户密码 17
private int _userPower; //用户权限 18
private string _userName; //用户姓名 19
private bool _userSex; //用户性别 20
private string _userDepart; //用户系院 21
private string _userTelephone; //用户电话 22
private string _userEMail; //用户E_Mail 23
24
#endregion 私有成员 25
26
属性#region 属性 27
//51-A-s-p-x.com 28
29
public string UserID 30
...{ 31
set 32
...{ 33
this._userID = value; 34
} 35
get 36
...{ 37
return this._userID; 38
} 39
} 40
public string UserPassword 41
...{ 42
set 43
...{ 44
this._userPassword = value; 45
} 46
get 47
...{ 48
return this._userPassword; 49
} 50
} 51
public int UserPower 52
...{ 53
set 54
...{ 55
this._userPower = value; 56
} 57
get 58
...{ 59
return this._userPower; 60
} 61
} 62
public string UserName 63
...{ 64
set 65
...{ 66
this._userName = value; 67
} 68
get 69
...{ 70
return this._userName; 71
} 72
} 73
public bool UserSex 74
...{ 75
set 76
...{ 77
this._userSex = value; 78
} 79
get 80
...{ 81
return this._userSex; 82
} 83
} 84
public string UserDepart 85
...{ 86
set 87
...{ 88
this._userDepart = value; 89
} 90
get 91
...{ 92
return this._userDepart; 93
} 94
} 95
public string UserTelephone 96
...{ 97
set 98
...{ 99
this._userTelephone = value; 100
} 101
get 102
...{ 103
return this._userTelephone; 104
} 105
} 106
public string UserEMail 107
...{ 108
set 109
...{ 110
this._userEMail = value; 111
} 112
get 113
...{ 114
return this._userEMail; 115
} 116
} 117
118
#endregion 属性 119
120
方法#region 方法 121
122
//根据用户 UserID 初始化该用户 123
//输入: 124
// XUserID - 用户编号; 125
//输出: 126
// 用户存在:返回True; 127
// 用户不在:返回False; 128
public bool LoadData(string XUserID) 129
...{ 130
SqlParameter[] Params = new SqlParameter[1]; 131
DataBase DB = new DataBase(); 132
133
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //用户编号 134
135
DataSet ds = DB.GetDataSet("Proc_UsersDetail", Params); 136
ds.CaseSensitive = false; 137
DataRow DR; 138
if (ds.Tables[0].Rows.Count > 0) 139
...{ 140
DR= ds.Tables[0].Rows[0]; 141
this._userID = GetSafeData.ValidateDataRow_S(DR, "UserID"); //用户编号 142
this._userPower = GetSafeData.ValidateDataRow_N(DR, "UserPower"); //用户权限 143
this._userName = GetSafeData.ValidateDataRow_S(DR, "UserName"); //用户姓名 144
this._userSex = GetSafeData.ValidateDataRow_B(DR, "UserSex"); //用户性别 145
this._userDepart = GetSafeData.ValidateDataRow_S(DR, "UserDepart"); //用户系院 146
this._userTelephone = GetSafeData.ValidateDataRow_S(DR, "UserTelephone"); //用户电话 147
this._userEMail = GetSafeData.ValidateDataRow_S(DR, "UserEMail"); //用户EMail 148
return true; 149
} 150
else 151
...{ 152
return false; 153
} 154
} 155
156
//根据UserID判断该用户是否存在 157
//输入: 158
// XUserID - 用户编号; 159
//输出: 160
// 用户存在:返回True; 161
// 用户不在:返回False; 162
public bool CheckUser(string XUserID) 163
...{ 164
SqlParameter[] Params = new SqlParameter[1]; 165
DataBase DB = new DataBase(); 166
167
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //教工姓名 168
169
SqlDataReader DR = DB.RunProcGetReader("Proc_UsersDetail", Params); 170
171
if (!DR.Read()) 172
...{ 173
return false; 174
} 175
else 176
...{ 177
return true; 178
} 179
} 180
181
//根据UserID和UserPassword判断密码是否正确 182
//输入: 183
// XUserID - 用户编号(From Asp.net源码下载专业站5+a+s+p+x); 184
//输出: 185
// 用户存在:返回True; 186
// 用户不在:返回False; 187
public bool CheckPassword(string XUserID) 188
...{ 189
SqlParameter[] Params = new SqlParameter[1]; 190
DataBase DB = new DataBase(); 191
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //教工姓名 192
193
SqlDataReader DR = DB.RunProcGetReader("Proc_UsersDetail", Params); 194
if (!DR.Read()) 195
...{ 196
return false; 197
} 198
else 199
...{ 200
this._userPassword = DR["UserPassword"].ToString(); 201
this._userPower = int.Parse(DR["UserPower"].ToString()); 202
return true; 203
} 204
} 205
206
207
//向Users表中添加用户信息(采用存储过程) 208
//输出: 209
// 插入成功:返回True; 210
// 插入失败:返回False; 211
public bool InsertByProc() 212
...{ 213
SqlParameter[] Params = new SqlParameter[8]; 214
215
DataBase DB = new DataBase(); 216
217
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, UserID); //用户编号 218
Params[1] = DB.MakeInParam("@UserPassword", SqlDbType.VarChar,50, UserPassword); //用户密码 219
Params[2] = DB.MakeInParam("@UserPower", SqlDbType.SmallInt, 2, UserPower); //用户权限 220
Params[3] = DB.MakeInParam("@UserName", SqlDbType.VarChar, 50, UserName); //用户姓名 221
Params[4] = DB.MakeInParam("@UserSex", SqlDbType.Bit,1, UserSex); //用户性别 222
Params[5] = DB.MakeInParam("@UserDepart", SqlDbType.VarChar,50, UserDepart); //用户系院 223
Params[6] = DB.MakeInParam("@UserTelephone", SqlDbType.VarChar, 50, UserTelephone); //用户电话 224
Params[7] = DB.MakeInParam("@UserEMail", SqlDbType.VarChar, 50, UserEMail); //用户EMail 225
226
int Count = -1; 227
Count = DB.RunProc("Proc_UsersAdd", Params); 228
if (Count > 0) 229
return true; 230
else return false; 231
} 232
233
//更新用户的信息 234
public bool UpdateByProc(string XUserID) 235
...{ 236
SqlParameter[] Params = new SqlParameter[6]; 237
238
DataBase DB = new DataBase(); 239
240
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //用户编号 241
Params[1] = DB.MakeInParam("@UserPower", SqlDbType.SmallInt, 2, UserPower); //用户权限 242
Params[2] = DB.MakeInParam("@UserName", SqlDbType.VarChar, 50, UserName); //用户姓名 243
Params[3] = DB.MakeInParam("@UserDepart", SqlDbType.VarChar, 50, UserDepart); //用户系院 244
Params[4] = DB.MakeInParam("@UserTelephone", SqlDbType.VarChar, 50, UserTelephone); //用户电话 245
Params[5] = DB.MakeInParam("@UserEMail", SqlDbType.VarChar, 50, UserEMail); //用户EMail 246
247
int Count = -1; 248
Count = DB.RunProc("Proc_UsersModify", Params); 249
if (Count > 0) 250
return true; 251
else return false; 252
} 253
//更新读者联系方式 254
public bool UpdateMessage(string XUserID) 255
...{ 256
SqlParameter[] Params = new SqlParameter[3]; 257
258
DataBase DB = new DataBase(); 259
260
Params[0] = DB.MakeInParam("@UserID", SqlDbType.VarChar, 50, XUserID); //用户编号 261
Params[1] = DB.MakeInParam("@UserTelephone", SqlDbType.VarChar, 50, UserTelephone); //用户电话 262
Params[2] = DB.MakeInParam("@UserEMail", SqlDbType.VarChar, 50, UserEMail); //用户EMail 263
264
int Count = -1; 265
Count = DB.RunProc("Proc_UsersMessageModify", Params); 266
if (Count > 0) 267
return true; 268
else return false; 269
} 270
271
//删除用户 272
//输入: 273
// XUserID - 用户编号; 274
//输出: 275
// 删除成功:返回True; 276
// 删除失败:返回False; 277
public bool DeleteByProc(string XUserID) 278




