温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:个人图书管理系统源码
当前文件路径:MyLibary/App_Code/BusinessLogicLayer/Book.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
9
namespace MyLibrary.BusinessLogicLayer 10
...{ 11
//用户类 12
public class Book 13
...{ 14
私有成员#region 私有成员 15
private int _bookID; //书号 16
private string _bookName; //书名 17
private string _bookISBN; //ISBN 18
private string _bookAuthor; //作者 19
private string _bookPublish; //出版社 20
private DateTime _bookPublishDate; //出版时间 21
private string _bookClassify; //分类 22
private string _bookSubject; //主题 23
private string _bookIndex; //索书号 24
private double _bookPrice; //价格 25
private int _bookPageNum; //页数 26
private string _bookSeries; //系列 27
private string _bookDescription; //描述 28
29
#endregion 私有成员 30
31
属性#region 属性 32
33
public int BookID 34
...{ 35
set 36
...{ 37
this._bookID = value; 38
} 39
get 40
...{ 41
return this._bookID; 42
} 43
} 44
public string BookName 45
...{ 46
set 47
...{ 48
this._bookName = value; 49
} 50
get 51
...{ 52
return this._bookName; 53
} 54
} 55
public string BookISBN 56
...{ 57
set 58
...{ 59
this._bookISBN = value; 60
} 61
get 62
...{ 63
return this._bookISBN; 64
} 65
} 66
public string BookAuthor 67
...{ 68
set 69
...{ 70
this._bookAuthor = value; 71
} 72
get 73
...{ 74
return this._bookAuthor; 75
} 76
} 77
public string BookPublish 78
...{ 79
set 80
...{ 81
this._bookPublish = value; 82
} 83
get 84
...{ 85
return this._bookPublish; 86
} 87
} 88
public DateTime BookPublishDate 89
...{ 90
set 91
...{ 92
this._bookPublishDate = value; 93
} 94
get 95
...{ 96
return this._bookPublishDate; 97
} 98
} 99
public string BookClassify 100
...{ 101
set 102
...{ 103
this._bookClassify = value; 104
} 105
get 106
...{ 107
return this._bookClassify; 108
} 109
} 110
public string BookSubject 111
...{ 112
set 113
...{ 114
this._bookSubject = value; 115
} 116
get 117
...{ 118
return this._bookSubject; 119
} 120
} 121
public string BookIndex 122
...{ 123
set 124
...{ 125
this._bookIndex = value; 126
} 127
get 128
...{ 129
return this._bookIndex; 130
} 131
} 132
public double BookPrice 133
...{ 134
set 135
...{ 136
this._bookPrice = value; 137
} 138
get 139
...{ 140
return this._bookPrice; 141
} 142
} 143
public int BookPageNum 144
...{ 145
set 146
...{ 147
this._bookPageNum = value; 148
} 149
get 150
...{ 151
return this._bookPageNum; 152
} 153
} 154
public string BookSeries 155
...{ 156
set 157
...{ 158
this._bookSeries = value; 159
} 160
get 161
...{ 162
return this._bookSeries; 163
} 164
} 165
public string BookDescription 166
...{ 167
set 168
...{ 169
this._bookDescription = value; 170
} 171
get 172
...{ 173
return this._bookDescription; 174
} 175
} 176
177
#endregion 属性 178
179
方法#region 方法 180
181
//根据书号 BookID 初始化 182
//输入: 183
// XBookID - 书号; 184
//输出: 185
// 书存在:返回True; 186
// 书不在:返回False; 187
public bool LoadData(int XBookID) 188
...{ 189
SqlParameter[] Params = new SqlParameter[1]; 190
DataBase DB = new DataBase(); 191
192
Params[0] = DB.MakeInParam("@BookID", SqlDbType.Int, 4, XBookID); //书号 193
194
DataSet ds = DB.GetDataSet("Proc_BookDetail", Params); 195
ds.CaseSensitive = false; 196
DataRow DR; 197
if (ds.Tables[0].Rows.Count > 0) 198
...{ 199
DR = ds.Tables[0].Rows[0]; 200
this._bookID = GetSafeData.ValidateDataRow_N(DR, "BookID"); //书号 201
this._bookName = GetSafeData.ValidateDataRow_S(DR, "BookName"); //书名 202
this._bookISBN = GetSafeData.ValidateDataRow_S(DR, "BookISBN"); //书ISBN号 203
this._bookAuthor = GetSafeData.ValidateDataRow_S(DR, "BookAuthor"); //作者 204
this._bookPublish = GetSafeData.ValidateDataRow_S(DR, "BookPublish"); //出版社 205
this._bookPublishDate = GetSafeData.ValidateDataRow_T(DR, "BookPublishDate"); //出版时间 206
this._bookClassify = GetSafeData.ValidateDataRow_S(DR, "BookClassify"); //分类 207
this._bookSubject = GetSafeData.ValidateDataRow_S(DR, "BookSubject"); //主题 208
this._bookIndex = GetSafeData.ValidateDataRow_S(DR, "BookIndex"); //索引号 209
this._bookPrice = GetSafeData.ValidateDataRow_F(DR, "BookPrice"); //价格 210
this._bookPageNum = GetSafeData.ValidateDataRow_N(DR, "BookPageNum"); //页数 211
this._bookSeries = GetSafeData.ValidateDataRow_S(DR, "BookSeries"); //系列 212
this._bookDescription = GetSafeData.ValidateDataRow_S(DR, "BookDescription"); //介绍 213
return true; 214
} 215
else 216
...{ 217
return false; 218
} 219
} 220
221
//根据BookID判断该图书是否存在 222
//输入: 223
// XBookID - 用户编号; 224
//输出: 225
// 用户存在:返回True; 226
// 用户不在:返回False; 227
public bool CheckBook(string XBookID) 228
...{ 229
SqlParameter[] Params = new SqlParameter[1]; 230
DataBase DB = new DataBase(); 231
232
Params[0] = DB.MakeInParam("@BookID", SqlDbType.Int, 4, XBookID); //书号 233
234
SqlDataReader DR = DB.RunProcGetReader("Proc_BookDetail", Params); 235
236
if (!DR.Read()) 237
...{ 238
return false; 239
} 240
else 241
...{ 242
return true; 243
} 244
} 245
246
247
//向Books表中添加书籍信息(采用存储过程) 248
//输出: 249
// 插入成功:返回True; 250
// 插入失败:返回False; 251
public bool InsertByProc() 252
...{ 253
SqlParameter[] Params = new SqlParameter[12]; 254
255
DataBase DB = new DataBase(); 256
257
//Params[0] = DB.MakeInParam("@BookID", SqlDbType.Int, 4, BookID); //书号 258
Params[0] = DB.MakeInParam("@BookName", SqlDbType.VarChar, 50, BookName); //书名 259
Params[1] = DB.MakeInParam("@BookISBN", SqlDbType.VarChar, 50, BookISBN); //ISBN 260
Params[2] = DB.MakeInParam("@BookAuthor", SqlDbType.VarChar, 50, BookAuthor); //作者 261
Params[3] = DB.MakeInParam("@BookPublish", SqlDbType.VarChar, 50, BookPublish); //出版社 262
Params[4] = DB.MakeInParam("@BookPublishDate", SqlDbType.DateTime, 8, BookPublishDate); //出版时间 263
Params[5] = DB.MakeInParam("@BookClassify", SqlDbType.VarChar, 50, BookClassify); //分类 264
Params[6] = DB.MakeInParam("@BookSubject", SqlDbType.VarChar, 50, BookSubject); //主题 265
Params[7] = DB.MakeInParam("@BookIndex", SqlDbType.VarChar, 50, BookIndex); //索引号 266
Params[8] = DB.MakeInParam("@BookPrice", SqlDbType.Float, 8, BookPric




