private void btn_dat_Click(object sender, EventArgs e) { DataGridViewRow row = this.dgv_dstieude.Rows[vitri]; //Ma tieu de int s = Convert.ToInt32(row.Cells[0].Value.ToString()); ePhieuDatTruoc pdt = new ePhieuDatTruoc(); int id = Convert.ToInt32(txt_idkh.Text); eKhachHang kh = khachHangBUL.Find(id); if (kh == null) { eKhachHang ekh = new eKhachHang(); ekh.tenKhachHang = txt_tenkh.Text; ekh.soDT = txt_sdt.Text; ekh.soCMND = txtsocm.Text; khachHangBUL.Save(ekh); List <eKhachHang> lst = khachHangBUL.getKhachHangs(); eKhachHang khh = lst.FirstOrDefault(st => st.id_KhachHang.Equals(ekh.id_KhachHang)); if (khh != null) { pdt.id_TieuDe = s; pdt.ngayDatTruoc = DateTime.Today; pdt.id_KhachHang = khh.id_KhachHang; pdt.trangThai = 0; phieuDatTruocBUL.Save(pdt); MessageBox.Show("Đặt trước thành công"); } } else { pdt.id_TieuDe = s; pdt.ngayDatTruoc = DateTime.Today; pdt.id_KhachHang = kh.id_KhachHang; pdt.trangThai = 0; phieuDatTruocBUL.Save(pdt); MessageBox.Show("Đặt trước thành công"); } dgv_dstieude.DataSource = tieuDeBUL.getTieuDes(); }
private void btn_dat_Click(object sender, EventArgs e) { DataGridViewRow row = this.dgv_dstieude.Rows[vitri]; //Ma tieu de int s = Convert.ToInt32(row.Cells[0].Value.ToString()); ePhieuDatTruoc pdt = new ePhieuDatTruoc(); int id = Convert.ToInt32(txt_idkh.Text); eKhachHang kh = khachHangBUL.Find(id); if (kh != null) { eDVD dvd = dVDBUL.getDVDOnShelf(s); if (dvd != null) { pdt.id_DVD = dvd.id_DVD; pdt.id_TieuDe = s; pdt.ngayDatTruoc = DateTime.Today; pdt.id_KhachHang = kh.id_KhachHang; pdt.trangThai = 0; phieuDatTruocBUL.Save(pdt); MessageBox.Show("Đặt trước thành công"); dVDBUL.UpdateTrangThaiDVD(dvd.id_DVD, 0); } else { pdt.id_TieuDe = s; pdt.ngayDatTruoc = DateTime.Today; pdt.id_KhachHang = kh.id_KhachHang; pdt.trangThai = 0; phieuDatTruocBUL.Save(pdt); MessageBox.Show("Đặt trước thành công"); } } else { MessageBox.Show("Không tìm thấy khách hàng"); return; } dgv_dstieude.DataSource = tieuDeBUL.getTieuDes(); }