private void btnSearch_Click(object sender, EventArgs e) { if (txtID.Text != "") { DTO_Borrow dto_book = new DTO_Borrow(); String id = txtID.Text; dto_book = br.SearchBorrow("br_id", txtID.Text); if (dto_book != null) { txtQuanity.Text = dto_book.Quanity.ToString(); txtDeposit.Text = dto_book.Deposit.ToString(); cbxBookID.Text = dto_book.BookID.ToString(); dateTimePicker1.Text = dto_book.TakeDate.ToShortDateString(); dateTimePicker2.Text = dto_book.ReturnDate.ToShortDateString(); a.Text = dto_book.StaffID.ToString(); cbxReadID.Text = dto_book.ReaderID.ToString(); } else { MessageBox.Show("Không tìm thấy!"); } } else { MessageBox.Show("Hãy nhập mã sách cần tìm!"); } }
private void btnA_Click(object sender, EventArgs e) { if (checkNull()) { DTO_Borrow b = new DTO_Borrow(); b.ID = int.Parse(txtID.Text); b.ReturnDate = DateTime.Parse(dateTimePicker2.Value.ToShortDateString()); b.TakeDate = DateTime.Parse(dateTimePicker1.Value.ToShortDateString()); b.Quanity = Int32.Parse(txtQuanity.Text); b.Deposit = int.Parse(txtDeposit.Text); b.BookID = int.Parse(cbxBookID.Text); b.StaffID = int.Parse(a.Text); b.ReaderID = int.Parse(cbxReadID.Text); if (br.InsertBorrow(b) == 1) { MessageBox.Show("Thành công"); frmBorrow_Load(sender, e); } else if (br.InsertBorrow(b) == -5) { MessageBox.Show("Nhập mã sách bị trùng!"); txtID.Text = ""; txtID.Focus(); } else { MessageBox.Show("Không thành công"); } } else { MessageBox.Show("Hãy nhập đủ thông tin"); } }
public int Insert(DTO_Borrow borrow) { string sql = "INSERT INTO Borrow(br_id, take_date, return_date, quanity, br_deposit, b_id, s_id, r_id)" + " VALUES('" + borrow.ID + "','" + borrow.TakeDate + "','" + borrow.ReturnDate + "','" + borrow.Quanity + "','" + borrow.Deposit + "','" + borrow.BookID + "','" + borrow.StaffID + "','" + borrow.ReaderID + "')"; return(this.ExecuteNonQuery(sql)); }
private void btnEdit_Click(object sender, EventArgs e) { if (checkNull()) { DTO_Borrow b = new DTO_Borrow(); b.ID = int.Parse(txtID.Text); b.ReturnDate = DateTime.Parse(dateTimePicker2.Value.ToShortDateString()); b.TakeDate = DateTime.Parse(dateTimePicker1.Value.ToShortDateString()); b.Quanity = Int32.Parse(txtQuanity.Text); b.Deposit = int.Parse(txtDeposit.Text); b.BookID = int.Parse(cbxBookID.Text); b.StaffID = int.Parse(cbxStaffID.Text); b.ReaderID = int.Parse(cbxReadID.Text); if (br.UpdateBorrow(b) == 1) { MessageBox.Show("Thành công"); frmBorrow_Load(sender, e); } else { MessageBox.Show("Không thành công"); } } else { MessageBox.Show("Hãy điển đủ thông tin!"); } }
public int UpdateBorrow(DTO_Borrow borrow) { try { return(borrowDAO.Update(borrow)); } catch (Exception) { return(-1); } }
public int InsertBorrow(DTO_Borrow borrow) { if (checkID(borrow.ID)) { return(-5); } int res = borrowDAO.Insert(borrow); if (res == 1) { listID.Add(borrow.ID); } return(res); }
public int Update(DTO_Borrow borrow) { string sql = "UPDATE Borrow SET br_id='" + borrow.ID + "',take_date='" + borrow.TakeDate + "',return_date='" + borrow.ReturnDate + "',quanity='" + borrow.Quanity + "',br_deposit='" + borrow.Deposit + "',b_id='" + borrow.BookID + "',s_id='" + borrow.StaffID + "',r_id='" + borrow.ReaderID + "'WHERE br_id = '" + borrow.ID; return(this.ExecuteNonQuery(sql)); }