private void btnThem_Click(object sender, EventArgs e) { try { if (txtMaPX.Text != "" && dtNgayXuat.IsEmpty != true) { phieuXuatDTO.MaPX = Convert.ToInt32(txtMaPX.Text); phieuXuatDTO.NgayXuat = Convert.ToDateTime(dtNgayXuat.Value); if (!(pxBLL.CheckID(phieuXuatDTO.MaPX))) { int check = pxBLL.InsertPX(phieuXuatDTO); if (check == 1) { dgvPX.DataSource = pxBLL.getAllPX(); dgvPX.Show(); } else { MessageBox.Show("Thêm không thành công"); } } else { MessageBox.Show("Mã phiếu xuất " + phieuXuatDTO.MaPX + " đã tồn tại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Các trường không được để trống !"); } } catch (Exception ex) { MessageBox.Show("Thêm bị lỗi ! " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }