protected void btnCapNhat_Click(object sender, DirectEventArgs e) { try { ThietLapCaTheoBoPhanController controller = new ThietLapCaTheoBoPhanController(); foreach (var item in RowSelectionModel1.SelectedRows) { DAL.ThietLapCaTheoBoPhan obj = new DAL.ThietLapCaTheoBoPhan() { CreatedBy = CurrentUser.ID, CreatedDate = DateTime.Now, MaCaThu7 = cbCaThu7.SelectedItem.Value, MaCaChuNhat = cbCaChuNhat.SelectedItem.Value, MaCa = cbCaLamViec.SelectedItem.Value, MaDonVi = item.RecordID, SoNgayCongChuan = double.Parse(txtSoNgayCongChuan.Text.Replace('.', ',')) }; controller.UpdateCa(obj); } grpDanhSachDonVi.Reload(); wdChinhSuaCaLamViec.Hide(); } catch (Exception ex) { X.MessageBox.Alert("Có lỗi xảy ra", ex.Message).Show(); } }
public void UpdateCa(DAL.ThietLapCaTheoBoPhan item) { try { DAL.ThietLapCaTheoBoPhan caBoPhan = dataContext.ThietLapCaTheoBoPhans.FirstOrDefault(t => t.MaDonVi == item.MaDonVi); if (caBoPhan != null) { caBoPhan.MaCa = item.MaCa; caBoPhan.MaCaThu7 = item.MaCaThu7; caBoPhan.MaCaChuNhat = item.MaCaChuNhat; caBoPhan.SoNgayCongChuan = item.SoNgayCongChuan; Save(); } else { dataContext.ThietLapCaTheoBoPhans.InsertOnSubmit(item); Save(); } } catch (Exception ex) { throw ex; } }