public readerreserveModel(bookreserveModel model) { this.bookId = model.BookId; this.bookName = model.BookName; this.readerId = model.ReaderId; this.reserveDate = model.BorrowDate; this.returnDate = model.BorrowDate.AddDays(30); }
public static List<bookreserveModel> GetModelList() { List<bookreserveModel> modellist = new List<bookreserveModel>(); string sqlstring = "select * from bookInfo"; SqlDataReader datareader = CommonDB.ExecuteReader(CommonDB.CONN_STRING, CommandType.Text, sqlstring, null); while (datareader.Read()) { DateTime time; DateTime.TryParse(datareader["BookDate"].ToString(), out time); bookreserveModel model = new bookreserveModel(datareader["BookID"].ToString(), datareader["BookName"].ToString(), datareader["CardNum"].ToString(), time); modellist.Add(model); } return modellist; }
public static void AddReverse(bookreserveModel model) { try { string sqlstring = "insert into bookreserve (BookID,BookName,ReaderID,ReserveDate) " + "values (@bookid,@bookname,@readerid,@reservedate)"; SqlParameter[] sqlpara = new SqlParameter[]{ new SqlParameter("@bookid", SqlDbType.VarChar), new SqlParameter("@bookname", SqlDbType.VarChar) , new SqlParameter("@readerid", SqlDbType.VarChar), new SqlParameter("@reservedate", SqlDbType.DateTime)}; sqlpara[0].Value = model.BookId; sqlpara[1].Value = model.BookName; sqlpara[2].Value = model.ReaderId; sqlpara[3].Value = model.BorrowDate; CommonDB.ExecuteNonQuery(CommonDB.CONN_STRING, CommandType.Text, sqlstring, sqlpara); } catch (Exception ex) { Console.WriteLine("ReaderReverse Remove error!"); } }
protected void Button1_Click1(object sender, EventArgs e) { var bu = (((sender as Button).Parent.Parent) as GridViewRow).DataItemIndex; var bookpress = -1; int.TryParse(bookstocklist[bu].BookPress, out bookpress); if (bookpress > 0) { if (Session["UserType"].ToString() == "2") { var bookid = bookstocklist[bu].BookId; var bookname = bookstocklist[bu].BookName; string readerid = Session["UserName"].ToString(); bookreserveModel _model = new bookreserveModel(bookid, bookname, readerid, System.DateTime.Now); ReaderReverse.AddReverse(_model); Response.Write("<script type='text/javascript'>alert('" + "预定成功!" + "');</script>"); } } else { Response.Write("<script type='text/javascript'>alert('" + "存书不足!" + "');</script>"); } }