public static void ProcessBook() { ProcessBook processBook = new ProcessBook(); Commision commision = new Commision(); Console.WriteLine(processBook.CreateDuplicatePackingSlip(true)); Console.WriteLine(commision.CommisionPayment()); }
private void btnProcesBookRelease_Click(object sender, EventArgs e) { var checkReleased = from p in db.ProcessBooks where p.StudentID == int.Parse(txtProBookStudID.Text) && p.BookID == int.Parse(cmbProBookAvail.SelectedValue.ToString()) select p; var checkReturn = from p in db.ProcessBooks where p.StudentID == int.Parse(txtProBookStudID.Text) && p.BookID == int.Parse(cmbProBookAvail.SelectedValue.ToString()) && p.BookReturn != null select p; if (btnProBookRelease.Text == "Release") { if (checkReleased.Count() > 0) { MessageBox.Show("Book already released to the student!"); } else { ProcessBook probook = new ProcessBook(); probook.StudentID = int.Parse(txtProBookStudID.Text); probook.BookID = Convert.ToInt32(cmbProBookAvail.SelectedValue); probook.Distributer = txtProcBookDistributer.Text; probook.BookRelease = DateTime.Now; probook.BookReturn = null; db.ProcessBooks.InsertOnSubmit(probook); db.SubmitChanges(); MessageBox.Show("Release"); ProcessBookClear(); DisplayProcessBook(); } } else { if (checkReturn.Count() > 0) { MessageBox.Show("Book already returned to the student!"); } else { ProcessBookID = int.Parse(dgvProcessBook.CurrentRow.Cells[0].Value.ToString()); var procbooksupdate = db.ProcessBooks.SingleOrDefault(x => x.ProcessBookID == ProcessBookID); procbooksupdate.BookReturn = DateTime.Now; db.SubmitChanges(); MessageBox.Show("Return"); ProcessBookClear(); DisplayProcessBook(); btnProBookRelease.Text = "Release"; btnProcBookCLear.Text = "Clear"; } } }