private void dgv_DatPhong_CellClick(object sender, DataGridViewCellEventArgs e) { BLPDP = new BLPhieuDatPhong(); try { int r = dgv_DatPhong.CurrentCell.RowIndex; this.txtMaPDP.Text = dgv_DatPhong.Rows[r].Cells[0].Value.ToString().Trim(); this.cbbMaKH.Text = dgv_DatPhong.Rows[r].Cells[1].Value.ToString().Trim(); this.cbbMaPhong.Text = dgv_DatPhong.Rows[r].Cells[2].Value.ToString().Trim(); this.txtSoNguoi.Text = dgv_DatPhong.Rows[r].Cells[3].Value.ToString().Trim(); this.dtNgayNhanPhong.Value = (DateTime)dgv_DatPhong.Rows[r].Cells[5].Value; this.txtTienCoc.Text = dgv_DatPhong.Rows[r].Cells[6].Value.ToString().Trim(); this.MaPDP_focused = dgv_DatPhong.Rows[r].Cells[0].Value.ToString().Trim(); this.MaKH_focused = dgv_DatPhong.Rows[r].Cells[1].Value.ToString().Trim(); } catch { this.cbbMaKH.Text = ""; this.txtSoNguoi.Text = ""; this.txtTienCoc.Text = ""; this.cbbMaPhong.Text = ""; this.txtMaPDP.Text = ""; } }
private void btnLuu_Click(object sender, EventArgs e) { BLPDP = new BLPhieuDatPhong(); if (Them) { if (this.cbbMaKH.Text == "" || this.txtSoNguoi.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ các thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { if (BLPDP.ThemPhieuDatPhong(this.cbbMaKH.Text, this.txtSoNguoi.Text, this.MaPhong, this.dtNgayNhanPhong.Value, this.txtTienCoc.Text, ref err)) { LoadData(); MessageBox.Show("Đã thêm xong!"); Default_Button(); } else { MessageBox.Show(err, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); BLPDP = new BLPhieuDatPhong(); BLPDP.XoaPhieuKhongCoCTPDP(ref err); } } catch (SqlException) { MessageBox.Show("Không thêm được. Lỗi rồi!"); } } } else { if (this.cbbMaKH.Text == "" || this.txtSoNguoi.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ các thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { if (BLPDP.CapNhatPhieuDatPhong(this.txtMaPDP.Text, this.cbbMaKH.Text, this.txtSoNguoi.Text, dtNgayNhanPhong.Value, this.txtTienCoc.Text, ref err)) { LoadData(); MessageBox.Show("Đã sửa xong!"); Default_Button(); } else { MessageBox.Show(this.err); } } catch (SqlException) { MessageBox.Show("Không sửa được. Lỗi rồi!"); } } } }
private void btnXoa_Click(object sender, EventArgs e) { BLPDP = new BLPhieuDatPhong(); try { DialogResult DL = MessageBox.Show("Bạn có muốn xóa mẫu tin này?", "xác nhận", MessageBoxButtons.YesNoCancel); if (DL == DialogResult.Yes) { int r = dgv_DatPhong.CurrentCell.RowIndex; if (BLPDP.XoaPhieuDatPhong(ref err, this.txtMaPDP.Text)) { LoadData(); MessageBox.Show("Đã xóa xong"); } else { MessageBox.Show(err, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch { MessageBox.Show("Lỗi rồi"); } }
private void btnTimKiemNhanh_Click(object sender, EventArgs e) { BLPDP = new BLPhieuDatPhong(); DTPDP = new DataTable(); DTPDP.Clear(); DataSet ds = new DataSet(); ds = BLPDP.TimKiemNhanh(txtTimKiem.Text); DTPDP = ds.Tables[0]; dgv_DatPhong.DataSource = DTPDP; }
public void LoadData() { LoadMAKH(); try { BLPDP = new BLPhieuDatPhong(); DTPDP = new DataTable(); DTPDP.Clear(); DataSet ds = BLPDP.ThongTinPhieuDatPhong(MaPhong); DTPDP = ds.Tables[0]; // Đưa dữ liệu lên DataGridView dgv_DatPhong.DataSource = DTPDP; Default_txt(); Default_Button(); dgv_DatPhong_CellClick(null, null); } catch (SqlException) { } }