private void borrow(CirculatedCopy cc, Copy c, Reservation r) { // Insert borrow record if (cc == null) { return; } CirculatedCopyDAO.Insert(cc); // update type = 'B' at Copy if (c == null) { return; } c.Type = 'B'; CopyDAO.Update(c); // update status = 'A' at Reservation if (r == null) { return; } r.Status = 'A'; ReserveDAO.Update(r); }
private void borrow(CirculatedCopy cc, Copy c, Reservation r) { // Insert borrow record if (cc == null) { return; } if (CirculatedCopyDAO.Insert(cc)) { txtDueDate.Text = Calendar1.SelectedDate.AddDays(14).ToString("dd/MM/yyyy"); // update type = 'B' at Copy c = (Copy)Session["copy"]; if (c == null) { return; } c.Type = 'B'; CopyDAO.Update(c); // update status = 'A' at Reservation r = (Reservation)Session["reser"]; if (r == null) { return; } r.Status = 'A'; ReserveDAO.Update(r); } else { lblError.Text = cc.BorrowedDate.ToString("yyyy-MM-dd hh:mm:ss"); lblError.Text = "Borrow Fail :< "; } }
private void btnReturn_Click(object sender, EventArgs e) { CirculatedCopy cc = new CirculatedCopy(); cc.CirculatedCopyId = Convert.ToInt32(dgvBorrowedBooks.Rows[rowIndex].Cells["circulatedCopyId"].Value); cc.ReturnedDate = dtpReturnedDate.Value; cc.FineAmount = double.Parse(txtFineAmount.Text); CirculatedCopyDAO.Update(cc); Copy c = CopyDAO.GetCopy(Convert.ToInt32(dgvBorrowedBooks.Rows[rowIndex].Cells["copyNumber"].Value)); if (ReservationDAO.GetFirstReservation(c.BookNumber) != null) { c.Type = 2; } else { c.Type = 0; } CopyDAO.UpdateType(c); view(int.Parse(txtMemberCode.Text)); MessageBox.Show("Return Successful."); btnReturn.Enabled = false; txtFineAmount.Text = ""; btnConfirmFine.Enabled = false; }
private void View() { DataTable dt = CirculatedCopyDAO.GetBorrowedCopies(int.Parse(txtBorrowerNumber.Text)); GridView1.DataSource = dt; GridView1.DataBind(); lblNumberBorrowedCopied.Text = dt.Rows.Count.ToString(); }
private void Return(CirculatedCopy cc) { CirculatedCopyDAO.Update(cc); Copy c = CopyDAO.GetCopy(cc.CopyNumber); // update type = 'A' in copy c.Type = 'A'; CopyDAO.Update(c); }
// Get borrowed copies by this borrower and display private void View() { DataTable dt = CirculatedCopyDAO.GetBorrowedCopies(int.Parse(txtBorrowerNumber.Text)); dataGridView1.DataSource = dt; this.dataGridView1.Columns["borrowedDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; this.dataGridView1.Columns["dueDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; this.dataGridView1.Columns["returnedDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; lblNumberBorrowedBooks.Text = dt.Rows.Count.ToString(); }
public void showData() { DataTable dt = CirculatedCopyDAO.GetBorrowedCopies(int.Parse(txtBorrowerNumber.Text)); lblNoOfBorrowedCopy.Text = dt.Rows.Count.ToString(); DataView dv = new DataView(dt); GridView1.DataSource = dv; GridView1.DataBind(); }
private void Return(CirculatedCopy cc) { CirculatedCopyDAO.Update(cc); Copy c = CopyDAO.GetCopy(cc.CopyNumber); // if copy is reference if (c.Type == 'R') { return; } // update type = 'A' in copy c.Type = 'A'; CopyDAO.Update(c); }
private void Return(CirculatedCopy cc) { if (CirculatedCopyDAO.Update(cc)) { showMessageError("Return completed <3"); Copy c = CopyDAO.GetCopy(cc.CopyNumber); // update type = 'A' in copy c.Type = 'A'; CopyDAO.Update(c); } else { showMessageError("Return Fail :<"); } }
private void btnBorrow_Click(object sender, EventArgs e) { if (dtpBorrowed.Value < dtpDue.Value) { CirculatedCopy cc = new CirculatedCopy(); cc.CopyNumber = int.Parse(txtCopyNumber.Text); cc.MemberNumber = int.Parse(txtMemberCode.Text); cc.BorrowedDate = dtpBorrowed.Value; cc.DueDate = dtpDue.Value; if (CirculatedCopyDAO.Add(cc)) { Copy c = CopyDAO.GetCopy(int.Parse(txtCopyNumber.Text)); c.Type = 1; CopyDAO.UpdateType(c); display(2); view(int.Parse(txtMemberCode.Text)); MessageBox.Show("Add Successful."); if (check == 1) { Reservation r = ReservationDAO.GetFirstReservation(c.BookNumber); r.Status = true; ReservationDAO.UpdateStatus(r); } if (dgvBorrowedBooks.Rows.Count >= 5) { display(0); MessageBox.Show("The number of borrowed books is 5. You can not borrow anymore book."); } } else { MessageBox.Show("Error."); } } else { MessageBox.Show("Borrowed date has to be smaller than Due date."); } }
// get all borrowed copies by this borrower and display private void View() { DataTable dt = new CirculatedCopyDAO().GetBorrowedCopies(int.Parse(txtBorrowerNumber.Text)); dataGridView1.DataSource = dt; this.dataGridView1.Columns["borrowedDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; this.dataGridView1.Columns["dueDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; this.dataGridView1.Columns["returnedDate"].DefaultCellStyle.Format = "dd/MM/yyyy"; int count = dataGridView1.Rows.Count; lbNumberOfBorrowedBooks.Text = count.ToString(); if (count >= 5) { MessageBox.Show("You has borrowed 5 books, so you can't borrow any more!"); //MessageBox.Show("You borrowed 5 books, so you can't borrow any more!"); txtBorrowerNumber.Focus(); return; } }
private void borrow(CirculatedCopy cc, Copy c, Reservation r) { // Insert borrow record if (cc == null) { return; } CirculatedCopyDAO.Insert(cc); // update type = 'B' at Copy c = CopyDAO.GetCopy(Int32.Parse(txtCopyNumber.Text)); c.Type = 'B'; CopyDAO.Update(c); // update status = 'A' at Reservation if (r == null) { return; } r.Status = 'A'; ReserveDAO.Update(r); }
private void dgvBorrowedBooks_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = (DataGridView)sender; if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { if (Convert.ToInt32(dgvBorrowedBooks.Rows[e.RowIndex].Cells["numberRenew"].Value) < 3) { CirculatedCopy cc = new CirculatedCopy(); cc.CirculatedCopyId = Convert.ToInt32(dgvBorrowedBooks.Rows[e.RowIndex].Cells["circulatedCopyId"].Value); cc.DueDate = Convert.ToDateTime(dgvBorrowedBooks.Rows[e.RowIndex].Cells["dueDate"].Value).AddDays(14); if (CirculatedCopyDAO.Renew(cc)) { dgvBorrowedBooks.DataSource = MemberDAO.GetBorrowedBooks(Convert.ToInt32(txtMemberCode.Text)); MessageBox.Show("Renew Successful."); } } else { MessageBox.Show("You can not renew more than 3 times."); } } }
private void Return(CirculatedCopy cc) { CirculatedCopyDAO.Update(cc); CopyDAO.Update1(cc.CopyNumber, "A"); }