private void btn_tkID_Click(object sender, EventArgs e) { if (txt_IDDia.Text.ToString().Trim().Equals("")) { MessageBox.Show("Nhập Id DVD"); txt_IDDia.Focus(); return; } int id_dvd = Convert.ToInt32(txt_IDDia.Text.ToString().Trim()); ePhieuThueTra phieu = phieuTTBul.getPhieuThueTraByIdDVD(id_dvd); if (phieu != null) { eKhachHang kh = khBul.GetKhachHangByID(phieu.id_KhachHang); txt_idkh.Text = kh.id_KhachHang.ToString(); txt_sdt.Text = kh.soDT; txt_tenkh.Text = kh.tenKhachHang; txt_tendia.Text = tieuDeBUL.GetTieuDeByID(dvdBul.FindDVDById(id_dvd).id_TieuDe).tenTieuDe; table.Rows.Add(phieu.id_PhieuThue, phieu.id_DVD, phieu.ngayThue, kh.id_KhachHang, kh.tenKhachHang); LoadData(); } else { MessageBox.Show("Không tìm thấy kết quả"); } }
private DataTable ConvertListToDataTableTreHan(List<ePhieuThueTra> list) { DataTable table_PhiTreHen = new DataTable(); table_PhiTreHen.Columns.Add("id_PhieuThue", typeof(int)); table_PhiTreHen.Columns.Add("id_DVD", typeof(int)); table_PhiTreHen.Columns.Add("ngayThue", typeof(string)); table_PhiTreHen.Columns.Add("ngayTra", typeof(string)); table_PhiTreHen.Columns.Add("phiTreHan", typeof(double)); foreach (ePhieuThueTra item in list) { double phiThue = tlbus.GetTheLoaiByID(tieuDeBUL.GetTieuDeByID(dVDBUL.FindDVDById(item.id_DVD).id_TieuDe).id_TheLoai).giaThue; table_PhiTreHen.Rows.Add(item.id_PhieuThue, item.id_DVD, item.ngayThue.ToString(), item.ngayTra.ToString(), phiThue * PHI_TRE_HEN); } return table_PhiTreHen; }
private void btn_timkiem_Click(object sender, EventArgs e) { Clearr(); if (nhapid.Text != "") { int id = Convert.ToInt32(nhapid.Text); eDVD dvd = dVDBUL.FindDVDById(id); if (dvd != null) { eTieuDe tieuDe = tieuDe = tieuDeBUL.Find(dvd.id_TieuDe); eTheLoai theLoai = tieuDeBUL.FindTheLoaiById(tieuDe.id_TieuDe); txt_tendia.Text = tieuDe.tenTieuDe; txtgiathue.Text = theLoai.giaThue.ToString(); txttgthue.Text = theLoai.thoiGianThue.ToString(); txt_iddia.Text = dvd.id_DVD.ToString(); txt_tragthai.Text = dvd.trangThai.ToString(); btn_timkiem.Text = " Tìm kiếm"; } else { MessageBox.Show("Không có đĩa trong danh sách"); } } else { MessageBox.Show("Nhap ma can tim"); } }
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 cb_listkh_SelectedIndexChanged(object sender, EventArgs e) { if (cb_listkh.SelectedIndex == 1) { List <eKhachHang> lskh = khbul.getKhachHangs(); List <eKhachHang> lskh1 = new List <eKhachHang>(); foreach (var item in lskh) { List <ePhieuThueTra> lsp = phieu.getPhieuThueTraByKHBaoCao(item.id_KhachHang); foreach (var item1 in lsp) { eDVD dvd1 = dvd.FindDVDById(item1.id_DVD); eTieuDe t = td.GetTieuDeByID(dvd1.id_TieuDe); eTheLoai theloai = tl.GetTheLoaiByID(t.id_TheLoai); DateTime dt = (DateTime)item1.ngayThue; DateTime today = DateTime.Now; if (item1.ngayTra == null && DateTime.Compare(today, dt.AddDays(theloai.thoiGianThue)) == 1) { lskh1.Add(item); break; } } } dgv_dskh.DataSource = lskh1; FormatLaiDataGridviewkh(dgv_dskh); } else if (cb_listkh.SelectedIndex == 0) { List <eKhachHang> ls = khbul.getKhachHangs(); dgv_dskh.DataSource = ls; FormatLaiDataGridviewkh(dgv_dskh); } else { List <eKhachHang> lskh = khbul.getKhachHangs(); List <eKhachHang> lskh1 = new List <eKhachHang>(); foreach (var item in lskh) { List <ePhieuThueTra> lsp = phieu.getPhieuThueTraByKHBaoCao(item.id_KhachHang); foreach (var item1 in lsp) { if (item1.ngayTraPhiTreHen == null) { lskh1.Add(item); break; } } } dgv_dskh.DataSource = lskh1; FormatLaiDataGridviewkh(dgv_dskh); } }