public decimal PurchaseFabricLinesToAx(TblPurchaseOrderHeaderRequest headerObjToPost, TblPurchaseReceiveDetail item, string purchaseOrder, int userIserial, Axapta axapta) { try { var importNew = axapta.CreateAxaptaObject("CreateProductionJournals"); var lineNum = importNew.Call("CreatePurchaseLinesSize", purchaseOrder, item.TblPurchaseOrderDetailRequest1.ItemId, item.Qty, item.BatchNo ?? "", item.TblPurchaseOrderDetailRequest1.TblColor.Code, headerObjToPost.TblWarehouse1.Code, item.TblPurchaseOrderDetailRequest1.Price, headerObjToPost.TblWarehouse1.Code, headerObjToPost.TblWarehouse1.TblSite1.Code, item.TblPurchaseOrderDetailRequest1.Size ?? ""); return(Convert.ToDecimal(lineNum)); } catch (Exception ex) { throw new Exception(ex.Message); } }
private int DeleteTblPurchaseOrderHeaderRequest(TblPurchaseOrderHeaderRequest row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblPurchaseOrderHeaderRequests where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
private TblPurchaseOrderHeaderRequest UpdateOrInsertTblPurchaseOrderHeaderRequest(TblPurchaseOrderHeaderRequest newRow, int index, int user, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { var warehouse = context.TblWarehouses.FirstOrDefault(w => w.Iserial == newRow.TblWarehouse).Po; var seq = context.TblSequenceProductions.FirstOrDefault(w => w.Iserial == warehouse); var oldRow = (from e in context.TblPurchaseOrderHeaderRequests where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { newRow.CreatedBy = oldRow.CreatedBy; newRow.CreationDate = oldRow.CreationDate; SharedOperation.GenericUpdate(oldRow, newRow, context); } else { newRow.CreationDate = DateTime.Now; newRow.CreatedBy = user; newRow.Code = SharedOperation.HandelSequence(seq); context.TblPurchaseOrderHeaderRequests.AddObject(newRow); } context.SaveChanges(); return(newRow); } }