private void btnCheck_Click(object sender, EventArgs e) { if (!txtIDdia.Text.ToString().Trim().Equals("")) { eDVD dvd = dVDBUL.FindDVDById(Convert.ToInt32(txtIDdia.Text.ToString())); if (dvd != null) { this.Size = new Size(319, 137); lblTieuDe1.Visible = true; lblTrangThai1.Visible = true; lblTieuDe.Visible = true; lblTrangThai.Visible = true; lblTieuDe.Text = tieuDeBUL.Find(dvd.id_TieuDe).tenTieuDe; if (dvd.trangThai == -1) { lblTrangThai.Text = "Trên kệ"; } else if (dvd.trangThai == 0) { this.Size = new Size(319, 223); grCho.Visible = true; grThue.Visible = false; lblTrangThai.Text = "Đang giữ"; ePhieuDatTruoc phieu = phieuDatTruocBUL.GetPhieuDatTruocByID(dvd.id_DVD); lblNguoiDatTrc.Text = khachHangBUL.Find(phieu.id_KhachHang).tenKhachHang; lblNgayLay.Text = phieu.ngayDatTruoc.ToShortDateString(); } else { this.Size = new Size(319, 223); grThue.Visible = true; grCho.Visible = false; lblTrangThai.Text = "Đang thuê"; ePhieuThueTra phieu = phieuThueTraBUL.getPhieuThueTraByIdDVD(dvd.id_DVD); if (phieu != null) { lblNguoiThue.Text = khachHangBUL.Find(phieu.id_KhachHang).tenKhachHang; int tgianThue = theLoaiBUL.GetTheLoaiByID(tieuDeBUL.Find(dvd.id_TieuDe).id_TheLoai).thoiGianThue; DateTime ngayTraDuKien = phieu.ngayThue.AddDays(tgianThue); lblDenHan.Text = ngayTraDuKien.ToShortDateString(); } } } else { this.Size = new Size(319, 79); grThue.Visible = false; grCho.Visible = false; lblTieuDe1.Visible = false; lblTrangThai1.Visible = false; lblTieuDe.Visible = false; lblTrangThai.Visible = false; MessageBox.Show("Không tồn tại DVD"); return; } } }
private void btnSearch_Click(object sender, EventArgs e) { dgvphitrehanthanhtoan.DataSource = null; if (txt_ID.Text.Trim().Equals("")) { MessageBox.Show("Không được để rỗng"); txt_ID.Focus(); return; } eKhachHang kh = new eKhachHang(); kh = khbul.Find(Convert.ToInt32(txt_ID.Text.Trim())); if (kh != null) { idkh = kh.id_KhachHang; txt_ten.Text = kh.tenKhachHang; txt_cmnd.Text = kh.soCMND; txt_sdt.Text = kh.soDT; CheckDsTreHen(); } else { DialogResult dialogResult = MessageBox.Show("Không tồn tài khách hàng. " + "Bạn có muốn thêm khách hàng?", "Thông báo", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { QuanLyKhachHang frm = new QuanLyKhachHang(); // xử lí sau frm.ShowDialog(); } } }
private void btnTim_Click(object sender, EventArgs e) { if (!txtidkh.Text.ToString().Trim().Equals("")) { eKhachHang kh = khachHangBUL.Find(Convert.ToInt32(txtidkh.Text.ToString().Trim())); if (kh != null) { idkh = kh.id_KhachHang; txthotenkh.Text = kh.tenKhachHang; txtidkh.Text = kh.id_KhachHang.ToString(); txtsdt.Text = kh.soDT; listThueHen = phiTreHenBUL.getListPhiTreHen(kh.id_KhachHang); LoadData(listThueHen); foreach (DataGridViewRow row in dgvPhiTreHen.Rows) { tongTien += Convert.ToDouble(row.Cells[4].Value.ToString()); } txtTienThanhToan.Text = tongTien.ToString(); } else { MessageBox.Show("Không tìm thấy thông tin khách hàng"); } } else { MessageBox.Show("ID khách hàng không để trống"); return; } }
private void btn_tradia_Click(object sender, EventArgs e) { DateTime now = DateTime.Now; listKH = new List <eKhachHang>(); listDVD = new List <eDVD>(); int count = 0; foreach (DataGridViewRow row in dgvDsTra.Rows) { int id_phieu = Convert.ToInt32(row.Cells[0].Value.ToString()); DateTime ngayThue = Convert.ToDateTime(row.Cells[2].Value.ToString()); int id_dvd = Convert.ToInt32(row.Cells[1].Value.ToString()); double time = theLoaiBUL.GetTheLoaiByID(tieuDeBUL.GetTieuDeByID(dvdBul.FindDVDById(id_dvd).id_TieuDe).id_TheLoai).thoiGianThue; eDVD dvd = dvdBul.FindDVDById(id_dvd); if (!listDVD.Contains(dvd)) { listDVD.Add(dvd); } eKhachHang kh = khBul.Find(Convert.ToInt32(row.Cells[3].Value.ToString())); if (!listKH.Contains(kh)) { listKH.Add(kh); } if ((now - ngayThue).TotalDays > time) { count = phieuTTBul.UpdatePhieuThue_Tre(id_phieu, now, PHI_TRE_HEN); } else { count = phieuTTBul.UpdatePhieuThue(id_phieu, now, now, 0); } dvdBul.UpdateTrangThaiDVD(id_dvd, -1); } if (count == 1) { MessageBox.Show("Trả đĩa thành công"); table.Clear(); LoadData(); } CheckPhiTreHen(); UpdateDVDDatTruoc(); }
private void btn_timkiem_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txt_idkh.Text); eKhachHang kh = khachHangBUL.Find(id); if (kh == null) { Cleadrr(); MessageBox.Show("Chua co khach hang trong he thong"); } else { txt_idkh.Text = id.ToString(); txt_sdt.Text = kh.soDT; txt_tenkh.Text = kh.tenKhachHang; txt_cm.Text = kh.soCMND; } }