private TblTransferMsg UpdateOrInsertTblTransferMsg(TblTransferMsg newRow, bool save, int index, out int outindex, string code) { outindex = index; using (var model = new TimeAttEntities()) { var emp = model.EmployeesViews.FirstOrDefault(x => x.Emplid == code); newRow.Company = emp.Company; newRow.Store = emp.Store; using (var context = new WorkFlowManagerDBEntities()) { if (save) { context.TblTransferMsgs.AddObject(newRow); } else { var oldRow = (from e in context.TblTransferMsgs where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } } context.SaveChanges(); return(newRow); } } }
private int DeleteTblTransferMsg(TblTransferMsg row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblTransferMsgs where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
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; var saveRow = new TblTransferMsg(); saveRow.InjectFrom(SelectedMainRow); Client.UpdateOrInsertTblTransferMsgAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow), LoggedUserInfo.Code); } } }