protected void borrowButton_Click(object sender, EventArgs e) { string number = memberNoTextBox.Text; MemberBll aMemberBll = new MemberBll(); BookEnroll aBookEnroll = new BookEnroll(); BookBLL aBookBll = new BookBLL(); if (aMemberBll.CheckMemberExistance(number) == true) { messageLable.Text = ""; BorrowBookBll aBorrowBookBll = new BorrowBookBll(); aBookEnroll.BookID = (int)ViewState["bookId"]; aBookEnroll.MemberNumber = number; if (aBookBll.CheckBookDuplication(aBookEnroll) == true) { messageLabel.Text = "This book already you take"; } else { messageLabel.Text = ""; aBorrowBookBll.Save(aBookEnroll); } } else { messageLable.Text = "This Member Number doesn't exist"; } }
public void ReturnBook(BookEnroll aBookEnroll) { SqlConnection aConnection = new SqlConnection(Connection()); string query = string.Format("Delete from t_book_enroll where book_id={0} and member_id='{1}'", aBookEnroll.BookID, aBookEnroll.MemberNumber); SqlCommand aCommand = new SqlCommand(query, aConnection); aConnection.Open(); aCommand.ExecuteNonQuery(); }
public void InsertIntoDatabase(BookEnroll aBookEnroll) { SqlConnection aConnection = new SqlConnection(Connection()); string query = string.Format("INSERT INTO t_book_enroll VALUES({0},'{1}')", aBookEnroll.BookID, aBookEnroll.MemberNumber); SqlCommand aCommand = new SqlCommand(query, aConnection); aConnection.Open(); aCommand.ExecuteNonQuery(); aConnection.Close(); }
protected void returnButton_Click(object sender, EventArgs e) { BookEnroll aBookEnroll = new BookEnroll(); BorrowBookBll aBorrowBookBll = new BorrowBookBll(); aBookEnroll.MemberNumber = memberNumberTextBox.Text; int index = bookListDropDownList.SelectedIndex; Book aBook = aBorrowBookEnroll.TakenBooks(aBookEnroll.MemberNumber)[index]; aBookEnroll.BookID = aBook.Id; aBorrowBookBll.ReturnBook(aBookEnroll); }
public bool CheckBookDuplication(BookEnroll aBookEnroll) { SqlConnection aConnection = new SqlConnection(Connection()); string query = string.Format("Select* from t_book_enroll where book_id={0} and member_id='{1}'", aBookEnroll.BookID, aBookEnroll.MemberNumber); SqlCommand aCommand = new SqlCommand(query, aConnection); aConnection.Open(); SqlDataReader aReader = aCommand.ExecuteReader(); if (aReader.HasRows) { return(true); } else { return(false); } }
public bool CheckBookDuplication(BookEnroll aBookEnroll) { return(aBookGateway.CheckBookDuplication(aBookEnroll)); }
public void ReturnBook(BookEnroll aBookEnroll) { aBookEnrollGateway.ReturnBook(aBookEnroll); }
public void Save(BookEnroll aBookEnroll) { aBookEnrollGateway.InsertIntoDatabase(aBookEnroll); }