//BUTTON UPDATE CLICK private void btnSua_Click(object sender, RoutedEventArgs e) { #region 1. Get row staff infomation DataRowView _drv = (DataRowView)dgNhanVien.SelectedItem; NhanVienPublic _staff = new NhanVienPublic(); _staff.MaNV_NV = _drv["MaNV_NV"].ToString(); _staff.HoTen_NV = _drv["HoTen_NV"].ToString(); _staff.NgaySinh_NV = Convert.ToDateTime(_drv["NgaySinh_NV"].ToString()); _staff.GioiTinh_NV = _drv["GioiTinh_NV"].ToString(); _staff.DiaChi_NV = _drv["DiaChi_NV"].ToString(); _staff.SDT_NV = _drv["SDT_NV"].ToString(); _staff.Anh_NV = _drv["Anh_NV"].ToString(); _staff.ID_Q = _drv["ID_Q"].ToString(); _staff.DangDung_NV = (bool)_drv["DangDung_NV"]; #endregion #region 2. Display wpf update staff NhanVienSuaPresentation wpf = new NhanVienSuaPresentation(); wpf._UpdateStaff += new EventHandler(UpdateStaff); wpf._staff = _staff; wpf.ShowDialog(); #endregion }
//METHOD UPDATE STAFF void UpdateStaff(object sender, EventArgs e) { #region 1. Get new staff NhanVienSuaPresentation wpf = (NhanVienSuaPresentation)sender; NhanVienPublic _staff = wpf._staff; _staff.Anh_NV = CoppyAnhNV(_staff.Anh_NV, _staff.MaNV_NV); #endregion #region 2. Update to database if (NhanVienBusiness.UpdateStaff(_staff)) { LoadDataToDataGrid(); EventHandler _eh = _CapNhatHienThi; if (_eh != null) { _eh(this, e); } } else { MessageBox.Show("Sửa thông tin nhân viên thất bại"); } #endregion }