private void btCapNhat_Click_1(object sender, EventArgs e) { int vaitro = 0; if (rdQuanLy.Checked) { vaitro = 1; } if (txtEmail.Text.Trim().Length == 0) //Check Email Null { MessageBox.Show("Bạn phải nhập email", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEmail.Focus(); return; } else if (!Isvaild(txtEmail.Text.Trim())) { MessageBox.Show("Email bạn nhập sai, vui lòng nhập lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtEmail.Focus(); return; } if (string.IsNullOrEmpty(txtTenNhanVien.Text) || string.IsNullOrWhiteSpace(txtTenNhanVien.Text)) { MessageBox.Show("Bạn chưa nhập tên nhân viên", "Thông báo"); } else if (string.IsNullOrEmpty(txtDiaChi.Text) || string.IsNullOrWhiteSpace(txtDiaChi.Text)) { MessageBox.Show("Bạn chưa địa chỉ", "Thông báo"); } else { Image img = pbHinh.BackgroundImage; byte[] arr; ImageConverter converter = new ImageConverter(); arr = (byte[])converter.ConvertTo(img, typeof(byte[])); DTO_NhanVien td = busnhanvien.curNV(dgvNhanVien.CurrentRow.Cells["Email_NV"].Value.ToString()); DTO_NhanVien curNV = new DTO_NhanVien(txtTenNhanVien.Text, txtEmail.Text, txtDiaChi.Text, (dateTimeNVL.Value).Date, vaitro, arr); //DTO_NhanVien curNV = new DTO_NhanVien(txtTenNhanVien.Text, txtEmail.Text, txtDiaChi.Text, (dateTimeNVL.Value).Date, vaitro, tinhTrang, arr); curNV.TrangThai = 1; //MessageBox.Show(td.MaNV + curNV.TenNV + curNV.Email+ curNV.DiaChi+ curNV.NgayVL+vaitro+ arr); if (busnhanvien.CapNhatNhanVien(td.MaNV, curNV)) { MessageBox.Show("Cập nhật thành công"); dgvNhanVien.DataSource = busnhanvien.getDanhSachNV(); dgvNhanVien.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } else { MessageBox.Show("Cập nhật thất bại"); } } }