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!"); } } } }