private void BorrowBtn_Click(object sender, EventArgs e) { string input = ExtenttextBox.Text; int extent_days = 0; if (input == "") { MessageBox.Show("Input the day you want to extent!"); } else { if (Int32.TryParse(input, out extent_days)) { ExtendApplication ea = new ExtendApplication(); ea.TransactionID = it.TransactionID; ea.ExtendDays = extent_days; ea.IsApproved = "False"; ea.Remarks = RemarktextBox.Text; context.ExtendApplications.Add(ea); context.SaveChanges(); MessageBox.Show("Submit Success!"); this.Close(); } } }
private void Delete_Click(object sender, EventArgs e) { int primarykey; if (dataGridView.Rows.Count > 0) { if (Int32.TryParse(dataGridView.CurrentRow.Cells[0].Value.ToString(), out primarykey)) { switch (clickedBtn) { case ButtonClicked.BookList: { Book item = context.Books.Where(x => x.BookCode == primarykey).ToList().First(); if (ConfirmDelete()) { context.Books.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.CustomerList: { Customer item = context.Customers.Where(x => x.CustomerID == primarykey).ToList().First(); if (ConfirmDelete()) { context.Customers.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.Extention: { ExtendApplication item = context.ExtendApplications.Where(x => x.ApplicationID == primarykey).ToList().First(); if (ConfirmDelete()) { context.ExtendApplications.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.IssueTran: { IssueTran item = context.IssueTrans.Where(x => x.TransactionID == primarykey).ToList().First(); if (ConfirmDelete()) { context.IssueTrans.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.PaymentTran: { PaymentTran item = context.PaymentTrans.Where(x => x.PaymentID == primarykey).ToList().First(); if (ConfirmDelete()) { context.PaymentTrans.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.AuthorList: { Author item = context.Authors.Where(x => x.AuthorID == primarykey).ToList().First(); if (ConfirmDelete()) { context.Authors.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.PublisherList: { Publisher item = context.Publishers.Where(x => x.PublisherID == primarykey).ToList().First(); if (ConfirmDelete()) { context.Publishers.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } case ButtonClicked.CountryList: { Country item = context.Countries.Where(x => x.CountryCode == primarykey).ToList().First(); if (ConfirmDelete()) { context.Countries.Remove(item); context.SaveChanges(); MessageBox.Show("Delete success!"); } break; } } } } else { MessageBox.Show("No data in the table"); } }
public ManageExtendeApplication(int primarykey) { InitializeComponent(); ea = context.ExtendApplications.Where(x => x.ApplicationID == primarykey).ToList().First(); }
public ManageExtendeApplication() { InitializeComponent(); ea = new ExtendApplication(); }