private void btnCheckMember_Click(object sender, EventArgs e) { try { memcode = int.Parse(txtMemberCode.Text); BorrowBL b = new BorrowBL(); if (b.checkMember(memcode)) { txtName.Text = b.showMemberName(memcode); } else { MessageBox.Show("doesn't match with any menber ! Please try again."); return; } } catch (Exception ex) { if (ex is FormatException || ex is OverflowException || ex is ArgumentNullException) { MessageBox.Show("Wrong input"); return; } else MessageBox.Show("somethings wrong in checkmember funtion"); } txtMemberCode.Enabled = false; txtBookNumber.Enabled = true; btnCheckReservation.Enabled = true; DataSet ds = ReserveBL.selectTableReservation(memcode); DataView dv = new DataView(ds.Tables[0]); dataGridView1.DataSource = dv; label6.Text = "" + ds.Tables[0].Rows.Count; }
private void button2_Click(object sender, EventArgs e) { BorrowBL a = new BorrowBL(); BorrowDA b = new BorrowDA(); int code = 0; try { code = int.Parse(textBox3.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } bool test = a.checkCopy(code); if (!test) { MessageBox.Show("You can't borrow this copy !"); return; } bool test1 = a.checkFive(int.Parse(textBox1.Text)); if (!test1) { MessageBox.Show("You have borrowed 5 copies !"); return; } bool test2 = a.checkReserve1(code); if (!test2) { textBox4.Text = DateTime.Now.ToString("d/M/yyyy"); textBox3.Enabled = false; button2.Enabled = false; button3.Enabled = true; textBox4.Enabled = true; } else { bool test3 = a.checkReserve(code, b.getBoNum(code), int.Parse(textBox1.Text)); //MessageBox.Show("" + a.checkReserve1(code)); if (!test3) { MessageBox.Show("This book have resserved by other person !"); return; } else { textBox3.Enabled = false; textBox4.Text = DateTime.Now.ToString("d/M/yyyy"); button2.Enabled = false; textBox4.Enabled = true; button3.Enabled = true; } } }
private void button1_Click(object sender, EventArgs e) { BorrowDA b = new BorrowDA(); BorrowBL a = new BorrowBL(); int code = 0; try { code = int.Parse(textBox1.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } bool test = a.checkMember(code); if (!test) { MessageBox.Show("Don't have this member in Database"); return; } else { DataSet ds = b.SelectDS(code); DataView dv = new DataView(ds.Tables[0]); dataGridView1.DataSource = dv; textBox2.Text = b.getName(code); textBox3.Enabled = true; button2.Enabled = true; textBox1.Enabled = false; textBox2.Enabled = false; button1.Enabled = false; } }
private void button3_Click(object sender, EventArgs e) { BorrowBL a = new BorrowBL(); BorrowDA b = new BorrowDA(); DateTime brDate = new DateTime(); try { brDate = DateTime.ParseExact(textBox4.Text, "d/M/yyyy", null); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } DateTime dueDate = brDate.AddDays(14); textBox5.Text = dueDate.ToShortDateString(); int copyNum = int.Parse(textBox3.Text); int brNum = int.Parse(textBox1.Text); CirculatedCopy h = new CirculatedCopy(); a.SetIdMax(); h.Id = ++a.idMax; h.CopyNumber = copyNum; h.BorrowerNumber = brNum; h.BorrowedDate = brDate; h.DueDate = dueDate; b.insertBorrow(h); b.borrowUpdate(copyNum); DataSet ds = b.SelectDS(brNum); DataView dv = new DataView(ds.Tables[0]); dataGridView1.DataSource = dv; bool test2 = a.checkReserve1(copyNum); bool test3 = a.checkReserve(copyNum, b.getBoNum(copyNum), int.Parse(textBox1.Text)); if (test2 && test3) { b.borrowReUpdate(b.getBoNum(copyNum), int.Parse(textBox1.Text)); } button3.Enabled = false; }
private void button3_Click(object sender, EventArgs e) { BorrowBL a = new BorrowBL(); BorrowDA b = new BorrowDA(); //DateTime returnDate = new DateTime(); CirculatedCopy c = new CirculatedCopy(); try { c.Id = int.Parse(dataGridView1.SelectedRows[0].Cells["ID"].Value.ToString()); c.CopyNumber = int.Parse(dataGridView1.SelectedRows[0].Cells["copyNumber"].Value.ToString()); c.BorrowerNumber = int.Parse(dataGridView1.SelectedRows[0].Cells["borrowerNumber"].Value.ToString()); c.DueDate = Convert.ToDateTime(dataGridView1.SelectedRows[0].Cells["dueDate"].Value.ToString()); c.BorrowedDate = Convert.ToDateTime(dataGridView1.SelectedRows[0].Cells["borrowedDate"].Value.ToString()); } catch (Exception) { MessageBox.Show("You must select a book !"); return; } try { c.ReturnedDate = DateTime.ParseExact(textBox3.Text, "d/M/yyyy", null); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (c.ReturnedDate.Date < c.BorrowedDate) { MessageBox.Show("BorrowedDate must less than ReturnedDate !"); return; } TimeSpan dayLater = c.ReturnedDate.Date - c.DueDate; double ngay = dayLater.TotalDays; if (ngay > 0) { textBox4.Text = "" + ngay; } else textBox4.Text = "0"; dataGridView1.Enabled = false; textBox3.Enabled = false; button3.Enabled = false; button2.Enabled = true; }
private void btnCheckReservation_Click(object sender, EventArgs e) { try { BorrowBL b = new BorrowBL(); bookcode = int.Parse(txtBookNumber.Text); if (ReserveBL.checkReservation(bookcode, memcode) && b.checkMember(memcode)) { txtName.Text = b.showMemberName(bookcode); textBox4.Enabled = true; button3.Enabled = true; } } catch (Exception ex) { if (ex is FormatException || ex is OverflowException || ex is ArgumentNullException) { MessageBox.Show("Wrong book number!"); return; } else MessageBox.Show("somethings wrong in checkReservation funtion"); } }