private void btnSua_Click(object sender, EventArgs e) { try { if (txtMaPN.Text != "" && dtNgayNhap.IsEmpty != true) { phieuNhapDTO.MaPN = Convert.ToInt32(txtMaPN.Text); phieuNhapDTO.NgayNhap = Convert.ToDateTime(dtNgayNhap.Value); if (pnBLL.CheckID(phieuNhapDTO.MaPN)) { int check = pnBLL.UpdatePN(phieuNhapDTO); if (check == 1) { dgvPN.DataSource = pnBLL.getAllPN(); MessageBox.Show("Đã sửa ngày nhập có mã " + phieuNhapDTO.MaPN); dgvPN.Show(); } else { MessageBox.Show("Sửa không thành công"); } } else { MessageBox.Show("Mã phiếu nhập " + phieuNhapDTO.MaPN + " không 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("Sửa bị lỗi ! " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }