public ucDetialsMember(int _member_id) { InitializeComponent(); member_id = _member_id; entity = new LibraryDBEntities(); member = EntityBroker.getMemberByMemberID(_member_id); }
public Window_Popup_ReturnBook(int _book_id) { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.FixedSingle; //make unresizable transaction = EntityBroker.getLastTransationByBookID(_book_id); book = EntityBroker.getBookByBookID(_book_id); member = EntityBroker.getMemberByMemberID(transaction.MemberID); bookmodel = EntityBroker.getBookModelByID(book.BookModelID); calculateCharge(); lblBookTitle.Text = bookmodel.BookTitle; lblBookIDValue.Text = book.BookID.ToString(); lblMemberNameValue.Text = member.MemberName; lblMemberIDValue.Text = member.MemberID.ToString(); lblRentDateValue.Text = transaction.LendDate.ToString("dd MM, yyyy"); lblChargeValue.Text = charge.ToString(); }
private void btnRent_Click(object sender, EventArgs e) { //#TODO::ExceptionHandle LibraryDBEntities entity = new LibraryDBEntities(); LibTran t = new LibTran(); int member_id = 0; int book_id = 0; try { book_id = Convert.ToInt32(txtBookID.Text); } catch { MessageBox.Show("BookID you entered is not valid type."); return; } try { member_id = Convert.ToInt32(txtMemberID.Text); } catch { MessageBox.Show("MemberID you entered is not valid type."); return; } Book book = EntityBroker.getBookByBookID(book_id); if (book == null) { MessageBox.Show("BookID doesn't exit."); return; } if (book.BookStatus != 1) { MessageBox.Show("Book is not avaiable to rent."); return; } Member member; member = EntityBroker.getMemberByMemberID(member_id); if (member == null) { MessageBox.Show("MemberID doesn't exit."); return; } t.MemberID = member_id; t.BookID = book_id; t.LendDate = DateTime.Now; entity.AddToLibTrans(t); try { entity.SaveChanges(); }catch { MessageBox.Show("User not exit"); } Book b = entity.Books.Where(x => x.BookID == t.BookID).SingleOrDefault(); b.BookStatus = 0; int i = entity.SaveChanges(); if (i == 1) { try { ucListBooks booklist = new ucListBooks(); booklist.setMainWindowRefrence(MainWindowObject); MainWindowObject.RequestContentChange(booklist); } catch { MessageBox.Show("Exception. Please close the window manually. Sorry for inconvenience"); } } this.Close(); }