private int DeleteDyeingOrderInvoiceMarkupTransProds(TblDyeingOrderInvoiceMarkupTransProd row, int index, string company) { using (var entity = new WorkFlowManagerDBEntities()) { var query = (from e in entity.TblDyeingOrderInvoiceMarkupTransProds where e.Iserial == row.Iserial select e).SingleOrDefault(); if (query != null) { entity.DeleteObject(query); } entity.SaveChanges(); } return(row.Iserial); }
private TblDyeingOrderInvoiceMarkupTransProd UpdateOrInsertDyeingOrderInvoiceMarkupTransProds(TblDyeingOrderInvoiceMarkupTransProd newRow, bool save, int index, out int outindex, string company) { outindex = index; using (var entity = new ccnewEntities(SharedOperation.GetSqlConnectionString(company))) { var entityrow = entity.Entities.Any(w => w.Iserial == newRow.TblMarkupProd && w.scope == 0 && w.TblJournalAccountType == 9 && w.AccountIserial != 0); if (!entityrow) { newRow.Iserial = -1; return(newRow); } } using (var entity = new WorkFlowManagerDBEntities()) { newRow.TblMarkupProd1 = null; if (save) { entity.TblDyeingOrderInvoiceMarkupTransProds.AddObject(newRow); } else { var oldRow = (from e in entity.TblDyeingOrderInvoiceMarkupTransProds where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { SharedOperation.GenericUpdate(oldRow, newRow, entity); } } entity.SaveChanges(); return(newRow); } }