private TblEmpWeeklyDayOff UpdateOrInsertTblEmpWeeklyDayOff(TblEmpWeeklyDayOff newRow, bool save, int index, int user, out int outindex) { outindex = index; using (var context = new TimeAttEntities()) { if (save) { newRow.CreationBy = user; newRow.CreationDate = DateTime.Now; context.TblEmpWeeklyDayOffs.AddObject(newRow); } else { var oldRow = (from e in context.TblEmpWeeklyDayOffs where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } } context.SaveChanges(); return(newRow); } }
public void SaveMainRow() { if (SelectedMainRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (isvalid) { var save = SelectedMainRow.Iserial == 0; if (save) { if (AllowAdd != true) { MessageBox.Show(strings.AllowAddMsg); return; } } else { if (AllowUpdate != true) { MessageBox.Show(strings.AllowUpdateMsg); return; } } var saveRow = new TblEmpWeeklyDayOff(); saveRow.InjectFrom(SelectedMainRow); Client.UpdateOrInsertTblEmpWeeklyDayOffAsync(saveRow, save, 0, LoggedUserInfo.Iserial); } } }
private int DeleteTblEmpWeeklyDayOff(TblEmpWeeklyDayOff row) { using (var context = new TimeAttEntities()) { var oldRow = (from e in context.TblEmpWeeklyDayOffs where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }