private void btnNextClick() { try { QLThuVien.ValueObject.PhieuMuonTra PMT = new QLThuVien.ValueObject.PhieuMuonTra(); PMT.SoPMT = txtSoPMT.Text.Trim(); PMT.MaDG = txtMDG.Text.Trim(); PMT.MaTT = txtMTT.Text.Trim(); PMT.NgayLap = dateLap.Value; PMT.NgayHTra = dateHtra.Value; PMT.NgayTra = dateLap.Value; if (DateTime.Compare(dateLap.Value, dateHtra.Value) >= 0) { throw new Exception(); } if (QLThuVien.BUSLayer.BUS.them_PMT(PMT) == 1) { Form frm = (Form)(this.Parent as Form); frm.Controls.Clear(); ThemSachMuon.soPMT = txtSoPMT.Text.Trim(); frm.Controls.Add(new ThemSachMuon()); } else { throw new Exception(); } } catch (Exception) { labErr.Text = "Input sai"; } }
private void btnGhiNhan_Click(object sender, EventArgs e) { try { if (btnSua.Active) { QLThuVien.ValueObject.PhieuMuonTra PMT = new QLThuVien.ValueObject.PhieuMuonTra(); PMT.SoPMT = txtSoPMT.Text.Trim(); PMT.MaDG = txtMDG2.Text.Trim(); PMT.MaTT = txtMTT.Text.Trim(); PMT.NgayLap = dateLap.Value; PMT.NgayHTra = dateHtra.Value; PMT.NgayTra = dateTra.Value; if (DateTime.Compare(PMT.NgayLap, PMT.NgayHTra) >= 0) { throw new Exception(); } if (DateTime.Compare(PMT.NgayLap, PMT.NgayTra) > 0) { throw new Exception(); } if (BUS.sua_PMT(PMT) == 1) { BUS.tinhTien_PMT(PMT.SoPMT); clearCTM(); loadPMT(); MessageBox.Show("S?a thành công"); } else { throw new Exception(); } } } catch (Exception) { MessageBox.Show("Input sai"); } finally { btnXoa.Text = "Xóa"; btnXoa.Active = true; clearTxtPMT(); disablePMT(); btnSua.Enabled = false; } }
private void btnTra_Click(object sender, EventArgs e) { try { if (dateTra.Text == " ") { QLThuVien.ValueObject.PhieuMuonTra PMT = new QLThuVien.ValueObject.PhieuMuonTra(); PMT.SoPMT = txtSoPMT.Text.Trim(); PMT.MaDG = txtMDG2.Text.Trim(); PMT.MaTT = txtMTT.Text.Trim(); PMT.NgayLap = dateLap.Value; PMT.NgayHTra = dateHtra.Value; PMT.NgayTra = DateTime.Today; if (DateTime.Compare(PMT.NgayLap, PMT.NgayTra) == 0) { throw new Exception(); } if (BUS.sua_PMT(PMT) == 1) { BUS.tinhTien_PMT(PMT.SoPMT); loadPMT(); loadCTM(); MessageBox.Show("Tr? thành công"); ChiTietMuon.soPMT = PMT.SoPMT; ChiTietMuon.maDG = PMT.MaDG; ChiTietMuon.ngayLap = PMT.NgayLap.ToShortDateString(); ChiTietMuon.ngayHtra = PMT.NgayHTra.ToShortDateString(); ChiTietMuon.ngayTra = (DateTime.Compare(PMT.NgayLap, PMT.NgayTra) != 0) ? PMT.NgayTra.ToShortDateString() : ""; new ChiTietMuon().Show(); } else { throw new Exception(); } } else { throw new Exception(); } } catch (Exception) { MessageBox.Show("Không tr? du?c"); } }