//		public static void Process(POReceipt doc)
//		{
//			List<POReceipt> list = new List<POReceipt>();
//
//			list.Add(doc);
//			Process(list, false);
//		}

        public static void Process(List <POOrder> list, bool isMassProcess)
        {
            POOrderEntry rg = PXGraph.CreateInstance <POOrderEntry>();

            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    rg.Clear();
                    rg.Document.Current = PXSelect <POOrder, Where <POOrder.orderType, Equal <Required <POOrder.orderType> >, And <POOrder.orderNbr, Equal <Required <POOrder.orderNbr> > > > > .Select(rg, list[i].OrderType, list[i].OrderNbr);

                    rg.CalculateExternalTax(rg.Document.Current);
                    PXProcessing <POOrder> .SetInfo(i, ActionsMessages.RecordProcessed);
                }
                catch (Exception e)
                {
                    if (isMassProcess)
                    {
                        PXProcessing <POOrder> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message);
                    }
                    else
                    {
                        throw new PXMassProcessException(i, e);
                    }
                }
            }
        }
示例#2
0
        //数量变更
        protected void Update_SL(DataTable dt)
        {
            POOrderEntry model    = new POOrderEntry();
            string       tempsql  = string.Empty;
            string       sql      = string.Empty;
            int          FInterID = 0;
            int          FEntryID = 0;

            foreach (DataRow dr in dt.Rows)
            {
                if (!string.IsNullOrEmpty(dr["WuLiaoNum"].ToString()))
                {
                    FInterID = Convert.ToInt32(dr["FInterID"].ToString());
                    FEntryID = Convert.ToInt32(dr["FEntryID"].ToString());
                    model    = dal.Detail(FInterID, FEntryID);


                    model.FAuxQty = Math.Round(Convert.ToDecimal(dr["FAuxQty"].ToString()), 10); //数量更新
                    model         = LastUpdateModel(model);
                    dal.Update(model);
                    //sql = string.Format(@"update POOrderEntry set FAuxQty='{0}' {3} where FInterID='{1}' and FEntryID='{2}'",
                    //    dr["FAuxQty"].ToString(), dr["FInterID"].ToString(), dr["FEntryID"].ToString(), tempsql);
                }
                //common.WriteLogs("料号:" + dr["WuLiaoNum"].ToString() + ",数量变更:" + sql);
                //DBUtil.ExecuteSql(sql, K3connectionString);
            }
        }
示例#3
0
        //NPI变更
        protected void Update_NPI(DataTable dt)
        {
            POOrderEntry model    = new POOrderEntry();
            string       tempsql  = string.Empty;
            string       sql      = string.Empty;
            int          FInterID = 0;
            int          FEntryID = 0;

            foreach (DataRow dr in dt.Rows)
            {
                if (!string.IsNullOrEmpty(dr["WuLiaoNum"].ToString()))
                {
                    FInterID        = Convert.ToInt32(dr["FInterID"].ToString());
                    FEntryID        = Convert.ToInt32(dr["FEntryID"].ToString());
                    model           = dal.Detail(FInterID, FEntryID);
                    model.FAuxQty   = Math.Round(Convert.ToDecimal(dr["FAuxQty"].ToString()), 10);   //数量更新
                    model.FAuxPrice = Math.Round(Convert.ToDecimal(dr["FAuxPrice"].ToString()), 10); //价格变更
                    if (!String.IsNullOrEmpty(dr["FEntrySelfP0267"].ToString()))
                    {
                        model.FEntrySelfP0267 = Convert.ToDateTime(dr["FEntrySelfP0267"].ToString());
                    }
                    if (!String.IsNullOrEmpty(dr["FEntrySelfP0268"].ToString()))
                    {
                        model.FEntrySelfP0268 = Convert.ToDateTime(dr["FEntrySelfP0268"].ToString());
                    }
                    if (!string.IsNullOrEmpty(dr["FDate"].ToString()))
                    {
                        model.FDate = Convert.ToDateTime(dr["FDate"].ToString());
                    }
                    model = LastUpdateModel(model);
                    dal.Update(model);
                }
            }
        }
示例#4
0
        //采购订单明细最后更新 更新相关基础信息
        protected POOrderEntry LastUpdateModel(POOrderEntry model)
        {
            #region   FQty数量初始化
            DataTable dtable = MeasureUnit(model.FUnitID.ToString());
            if (dtable.Rows.Count > 0)
            {
                decimal FAuxQty    = Convert.ToDecimal(model.FAuxQty); //数量变更时候 要初始值
                decimal Convertion = Convert.ToDecimal(dtable.Rows[0]["FCoefficient"].ToString());
                model.FQty = Math.Round(FAuxQty * Convertion, 10);
            }
            else
            {
                model.FQty = model.FAuxQty;
            }
            #endregion
            decimal Fcess  = Convert.ToDecimal(100.00);
            decimal Fcess2 = Convert.ToDecimal(100 + model.FCess) / Fcess;
            model.FAmount    = Math.Round(model.FQty * model.FPrice, 2);
            model.FTaxAmount = Math.Round(model.FAmount * Math.Round(model.FCess / Fcess, 6), 2);
            model.FAllAmount = model.FAmount + model.FTaxAmount;



            model.FAuxTaxPrice = model.FPrice + model.FPrice * Math.Round(model.FCess / Fcess, 10);
            model.FTaxPrice    = model.FAuxTaxPrice;

            model.FAllAmountExceptDisCount = model.FPriceDiscount * model.FQty;
            model.FAmountExceptDisCount    = Math.Round(model.FAllAmountExceptDisCount / Fcess2, 4);
            common.WriteLogs("LastUpdateModel结束");
            return(model);
        }
示例#5
0
 private void InitializePOOrderDocument(POOrderEntry graphPOOrderEntry, POOrder poOrderRow, POEnabledFSSODet firstPOEnabledFSSODetRow)
 {
     poOrderRow                  = new POOrder();
     poOrderRow                  = graphPOOrderEntry.Document.Current = graphPOOrderEntry.Document.Insert(poOrderRow);
     poOrderRow.OrderType        = POOrderType.RegularOrder;
     poOrderRow.VendorID         = firstPOEnabledFSSODetRow.POVendorID;
     poOrderRow.VendorLocationID = firstPOEnabledFSSODetRow.POVendorLocationID;
     graphPOOrderEntry.Document.Update(poOrderRow);
 }
        public void UpdatePOOrderEntry(int ItemID)
        {
            JD_OrderBG_Log model    = dal.Detail(ItemID);
            string         ErrorMsg = string.Empty;
            string         TitleMsg = string.Empty;

            try
            {
                if (model != null)
                {
                    POOrderEntry entrymodel = entrydal.Detail(model.FInterID, model.FEntryID);
                    TitleMsg = "基础信息—采购单号:" + model.PONum + ",内部编号:" + model.FInterID.ToString() + ",行号:" + model.FEntryID.ToString() + ",操作人:" + model.Operater;
                    if (entrymodel != null)
                    {
                        //更新首次确认时间 末次确认时间
                        if (model.FEntrySelfP0267 != null)
                        {
                            if (entrymodel.FEntrySelfP0267 != model.FEntrySelfP0267)
                            {
                                entrymodel.FEntrySelfP0267 = model.FEntrySelfP0267;
                            }
                        }

                        if (model.FEntrySelfP0268 != null)
                        {
                            if (entrymodel.FEntrySelfP0268 != model.FEntrySelfP0268)
                            {
                                entrymodel.FEntrySelfP0268 = model.FEntrySelfP0268;
                            }
                        }
                        entrydal.Update(entrymodel);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMsg = ex.Message;
                common.WriteLogs("采购订单交期变更Error:" + ex.Message);
            }
            finally
            {
                model.UpdateTime = DateTime.Now;
                model.IsUpdate   = "1";
                dal.Update(model);
                if (!string.IsNullOrEmpty(ErrorMsg))
                {
                    common.AddLogQueue("采购订单交期变更", "JD_OrderBG_Log", ItemID, "SQL", ErrorMsg + TitleMsg, false);
                }
                else
                {
                    common.AddLogQueue("采购订单交期变更", "JD_OrderBG_Log", ItemID, "SQL", "操作成功!" + TitleMsg, true);
                }
            }
        }
示例#7
0
 public virtual IEnumerable Details(PXAdapter adapter)
 {
     if (Records.Current != null && Filter.Current != null)
     {
         POOrderEntry graph = PXGraph.CreateInstance <POOrderEntry>();
         graph.Document.Current = Records.Current;
         throw new PXRedirectRequiredException(graph, true, Messages.ViewPOOrder)
               {
                   Mode = PXBaseRedirectException.WindowMode.NewWindow
               };
     }
     return(adapter.Get());
 }
示例#8
0
        private void ViewPoEntity(POOrderEntry graph, string message, Func <POOrder, bool> checkPurchaseOrderType)
        {
            if (Base.Transactions.Current == null)
            {
                return;
            }
            var purchaseOrder = GetPurchaseOrder(Base.Transactions.Current);

            if (purchaseOrder == null || !checkPurchaseOrderType(purchaseOrder))
            {
                return;
            }
            graph.Document.Current = purchaseOrder;
            throw new PXRedirectRequiredException(graph, message)
                  {
                      Mode = PXBaseRedirectException.WindowMode.NewWindow
                  };
        }
示例#9
0
        private void CreatePOOrderDocument(
            POOrderEntry graphPOOrderEntry,
            List <POEnabledFSSODet> itemGroup,
            POOrder poOrderRow,
            POLine poLineRow,
            POEnabledFSSODet firstPOEnabledFSSODetRow)
        {
            firstPOEnabledFSSODetRow = itemGroup[0];

            this.InitializePOOrderDocument(graphPOOrderEntry, poOrderRow, firstPOEnabledFSSODetRow);

            foreach (POEnabledFSSODet poEnabledFSSODetRow in itemGroup)
            {
                this.InsertPOLine(graphPOOrderEntry, poLineRow, poEnabledFSSODetRow);
            }

            graphPOOrderEntry.Save.Press();
        }
示例#10
0
        private void InsertPOLine(POOrderEntry graphPOOrderEntry, POLine poLineRow, POEnabledFSSODet poEnabledFSSODetRow)
        {
            poLineRow = new POLine()
            {
                BranchID = poEnabledFSSODetRow.BranchID
            };

            poLineRow = graphPOOrderEntry.Transactions.Current = graphPOOrderEntry.Transactions.Insert(poLineRow);

            poLineRow.InventoryID  = poEnabledFSSODetRow.InventoryID;
            poLineRow.SiteID       = poEnabledFSSODetRow.SiteID;
            poLineRow.OrderQty     = poEnabledFSSODetRow.EstimatedQty;
            poLineRow.ProjectID    = poEnabledFSSODetRow.ProjectID;
            poLineRow.TaskID       = poEnabledFSSODetRow.ProjectTaskID;
            poLineRow.CuryUnitCost = poEnabledFSSODetRow.UnitCost;
            poLineRow = graphPOOrderEntry.Transactions.Update(poLineRow);

            poEnabledFSSODetRow.POType      = poLineRow.OrderType;
            poEnabledFSSODetRow.POLineNbr   = poLineRow.LineNbr;
            poEnabledFSSODetRow.POCompleted = poLineRow.Completed;

            this.CopyNotesAndAttachments(graphPOOrderEntry.Transactions.Cache, poLineRow, poEnabledFSSODetRow);
        }
示例#11
0
        protected void createICPOAction()
        {
            Base.Save.Press();

            var curCompanyID = PXInstanceHelper.CurrentCompany;
            var curUserName  = PXLogin.ExtractUsername(PXContext.PXIdentity.IdentityName);

            //A.By using LMICCustomer table to identify the destination tenant of PO need to be created
            var curSOOrder      = (SOOrder)Base.Caches[typeof(SOOrder)].Current;
            var curLMICCustomer = PXSelect <LMICCustomer, Where <LMICCustomer.customerID, Equal <Required <LMICCustomer.customerID> > > > .Select(Base, curSOOrder.CustomerID).TopFirst;

            //B.Go to the destination tenant, and ensure vendor is defined in LMICVendor.If not, throw error message “The vendor is not defined in destination tenant”.
            var curCompanyName = PXLogin.ExtractCompany(PXContext.PXIdentity.IdentityName);
            var curLMICVendor  = new LMICVendor();

            try
            {
                using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICCustomer.LoginName}"))
                {
                    curLMICVendor = PXSelect <LMICVendor, Where <LMICVendor.tenantID, Equal <Required <LMICVendor.tenantID> > > > .Select(PXGraph.CreateInstance <POOrderEntry>(), curCompanyID).TopFirst;
                }
            }
            catch (Exception)
            {
                throw new PXException("Please try again.");
            }

            /*Get InventoryCD in each line*/
            var inventoryCDList = new List <string>();

            foreach (SOLine line in Base.Transactions.Cache.Cached)
            {
                inventoryCDList.Add(PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, line.InventoryID).TopFirst?.InventoryCD);
            }

            if (curLMICCustomer != null)
            {
                if (curLMICVendor != null)
                {
                    try
                    {
                        PXLongOperation.StartOperation(Base, () =>
                        {
                            var SOOrderCustomerOrderNbr = string.Empty;


                            //C.Create a purchase order in destination tenant by uing the following mapping.
                            using (PXLoginScope pXLoginScope = new PXLoginScope($"{curUserName}@{curLMICCustomer.LoginName}"))
                            {
                                POOrderEntry pOOrderEntry = PXGraph.CreateInstance <POOrderEntry>();
                                /* PO Header */
                                POOrder pOOrder = new POOrder();
                                pOOrder         = pOOrderEntry.Document.Insert(pOOrder);

                                pOOrder.BranchID = curLMICVendor.BranchID;
                                pOOrder.VendorID = curLMICVendor.VendorID;

                                pOOrderEntry.Document.Cache.RaiseFieldUpdated <POOrder.vendorID>(pOOrder, pOOrder.VendorID);

                                pOOrder.VendorRefNbr = curSOOrder.OrderNbr;
                                pOOrder.OrderDate    = curSOOrder.OrderDate;
                                pOOrder.OrderDesc    = "IC PO | " + curCompanyName + " | " + curSOOrder.OrderNbr;

                                /* PO Line */
                                int i = 0;
                                foreach (SOLine line in Base.Transactions.Cache.Cached)
                                {
                                    POLine pOLine       = new POLine();
                                    var tempInventoryID = PXSelect <InventoryItem, Where <InventoryItem.inventoryCD, Equal <Required <InventoryItem.inventoryCD> > > > .Select(pOOrderEntry, inventoryCDList[i])?.TopFirst?.InventoryID;
                                    pOLine.InventoryID  =
                                        tempInventoryID == null ?
                                        PXSelect <INItemXRef, Where <INItemXRef.alternateID, Equal <Required <INItemXRef.alternateID> > > > .Select(pOOrderEntry, inventoryCDList[i])?.TopFirst?.InventoryID : tempInventoryID;
                                    pOLine.OrderQty = line.OrderQty;
                                    pOLine          = pOOrderEntry.Transactions.Insert(pOLine);

                                    pOLine.CuryUnitCost = line.CuryUnitPrice;
                                    pOLine = pOOrderEntry.Transactions.Update(pOLine);

                                    i++;
                                }

                                //D.If the PO is saved successfully, please update the following fields
                                // - POOrder, ICSOCreated = true
                                POOrderExt pOOrderExt     = pOOrder.GetExtension <POOrderExt>();
                                pOOrderExt.UsrICSOCreated = true;
                                pOOrderEntry.Document.Update(pOOrder);
                                pOOrderEntry.Actions.PressSave();

                                SOOrderCustomerOrderNbr = pOOrder.OrderNbr;
                            }

                            //D.If the PO is saved successfully, please update the following fields
                            // - SOOrder, ICPOCreated = true; Customer Order Nbr = POOrder.OrderNbr
                            SOOrderExt sOOrderExt       = curSOOrder.GetExtension <SOOrderExt>();
                            sOOrderExt.UsrICPOCreated   = true;
                            curSOOrder.CustomerOrderNbr = SOOrderCustomerOrderNbr;
                            Base.Document.Update(curSOOrder);
                            Base.Save.Press();
                        });
                    }
                    catch (Exception)
                    {
                        throw new PXException("Please try again.");
                    }
                }
                else
                {
                    throw new PXException("The vendor is not defined in destination tenant");
                }
            }
        }
示例#12
0
        /// <summary>
        /// 交期变更
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="TaskID">主表ID</param>
        protected void Update_JQ(DataTable dt, string TaskID)
        {
            POOrderEntryDal dal       = new POOrderEntryDal();
            POOrderEntry    old_model = new POOrderEntry(); //原始的采购订单明细
            //找出不重复的FEntryID  遍历
            string sql = "select distinct FEntryID  from dbo.JD_OrderListDeailBG_WL where TaskID='" + TaskID + "' order by FEntryID asc";
            //string updatesql = "";
            //string sqltemp = "";
            var FEntryIDs = DBUtil.Query(sql).Tables[0].AsEnumerable().Select(r => r["FEntryID"]).Distinct();

            foreach (var item in FEntryIDs)
            {
                DataRow[] dr    = dt.Select("FEntryID='" + item.ToString() + "'", "FAuxQty desc");
                int       Count = 0;
                foreach (DataRow datarow in dr)
                {
                    //更新
                    if (Count == 0)
                    {
                        common.WriteLogs("首行");
                        common.WriteLogs("Count:" + Count);
                        common.WriteLogs("FEntryID:" + datarow["FInterID"].ToString() + ",FEntryID:" + item.ToString());
                        old_model = dal.Detail(Convert.ToInt32(datarow["FInterID"].ToString()), Convert.ToInt32(item.ToString()));
                        if (!String.IsNullOrEmpty(datarow["FEntrySelfP0267"].ToString()))
                        {
                            old_model.FEntrySelfP0267 = Convert.ToDateTime(datarow["FEntrySelfP0267"].ToString());
                        }
                        if (!String.IsNullOrEmpty(datarow["FEntrySelfP0268"].ToString()))
                        {
                            old_model.FEntrySelfP0268 = Convert.ToDateTime(datarow["FEntrySelfP0268"].ToString());
                        }
                        if (!string.IsNullOrEmpty(datarow["FDate"].ToString()))
                        {
                            old_model.FDate = Convert.ToDateTime(datarow["FDate"].ToString());
                        }
                        old_model.FAuxQty = Math.Round(Convert.ToDecimal(datarow["FAuxQty"].ToString()), 10); //数量更新
                        old_model         = LastUpdateModel(old_model);
                        dal.Update(old_model);
                        //sqltemp = (!String.IsNullOrEmpty(datarow["FEntrySelfP0267"].ToString())) ? ",FEntrySelfP0267='" + Convert.ToDateTime(datarow["FEntrySelfP0267"].ToString()).ToString("yyyy-MM-dd") + "'" : "";
                        //sqltemp += (!String.IsNullOrEmpty(datarow["FEntrySelfP0268"].ToString())) ? ",FEntrySelfP0268='" + Convert.ToDateTime(datarow["FEntrySelfP0268"].ToString()).ToString("yyyy-MM-dd") + "'" : "";
                        //updatesql = string.Format(@"update POOrderEntry set FDate='{0}' {1} {4}
                        //  where FInterID='{2}' and FEntryID='{3}'", Convert.ToDateTime(datarow["FDate"].ToString()).ToString("yyyy-MM-dd"), sqltemp, datarow["FInterID"].ToString(), item.ToString(),
                        // ",FAuxQty='"+ Math.Round(Convert.ToDecimal(datarow["FAuxQty"].ToString()), 10).ToString() + "'" );
                        //common.WriteLogs("首行");
                        //common.WriteLogs(updatesql);
                        //DBUtil.ExecuteSql(updatesql, K3connectionString);
                    }
                    //插入
                    else
                    {
                        common.WriteLogs("非首行");
                        common.WriteLogs("Count:" + Count);

                        //获取拆分订单中首个明细
                        POOrderEntry model = dal.Detail(Convert.ToInt32(datarow["FInterID"]), Convert.ToInt32(item.ToString()));
                        //带出Max(FEntryID)
                        int MaxFEntryID = common.GetMaxID("FEntryID", "POOrderEntry", " where FInterID='" + datarow["FInterID"] + "' ");

                        model.FAuxQty = Math.Round(Convert.ToDecimal(datarow["FAuxQty"].ToString()), 10);
                        if (!String.IsNullOrEmpty(datarow["FEntrySelfP0267"].ToString()))
                        {
                            model.FEntrySelfP0267 = Convert.ToDateTime(datarow["FEntrySelfP0267"].ToString());
                        }
                        if (!String.IsNullOrEmpty(datarow["FEntrySelfP0268"].ToString()))
                        {
                            model.FEntrySelfP0268 = Convert.ToDateTime(datarow["FEntrySelfP0268"].ToString());
                        }
                        if (!string.IsNullOrEmpty(datarow["FDate"].ToString()))
                        {
                            model.FDate = Convert.ToDateTime(datarow["FDate"].ToString());
                        }
                        decimal zero = Convert.ToDecimal(0.00);

                        model.FEntryID   = MaxFEntryID; //行号更新
                        model.FCommitQty = model.FCheckAmount = model.FAuxCommitQty = model.FStockQty = model.FAuxStockQty = model.FQtyInvoice = model.FReceiveAmountFor_Commit = model.FReceiveAmount_Commit = model.FAuxQtyInvoice = model.FAuxReceiptQty = model.FReceiptQty = model.FAuxReturnQty = model.FReturnQty = model.FAmountExceptDisCount = model.FAllAmountExceptDisCount = zero;
                        model            = LastUpdateModel(model);
                        dal.Add(model);
                    }

                    Count++;
                }
            }
        }
示例#13
0
        public static PXRedirectRequiredException CreatePOOrders2(
            System.Collections.Generic.List <POFixedDemand> list,
            DateTime?PurchDate,
            bool extSort)
        {
            POOrderEntry docgraph = PXGraph.CreateInstance <POOrderEntry>();

            docgraph.Views.Caches.Add(typeof(POOrderEntry.SOLineSplit3));
            POSetup current = docgraph.POSetup.Current;
            DocumentList <POOrder> documentList1 = new DocumentList <POOrder>((PXGraph)docgraph);
            Dictionary <string, DocumentList <POLine> > dictionary = new Dictionary <string, DocumentList <POLine> >();

            list.Sort((Comparison <POFixedDemand>)((a, b) =>
            {
                string empty1 = string.Empty;
                string empty2 = string.Empty;
                string str;
                if (a.PlanType == "90")
                {
                    PX.Objects.IN.InventoryItem inventoryItem = PX.Objects.IN.InventoryItem.PK.Find((PXGraph)docgraph, a.InventoryID);
                    str = string.Format("ZZ.{0}", inventoryItem == null ? (object)string.Empty : (object)inventoryItem.InventoryCD);
                }
                else
                {
                    POOrderEntry.SOLineSplit3 soLineSplit3 = (POOrderEntry.SOLineSplit3)PXSelectBase <POOrderEntry.SOLineSplit3, PXSelect <POOrderEntry.SOLineSplit3, Where <POOrderEntry.SOLineSplit3.planID, Equal <Required <POOrderEntry.SOLineSplit3.planID> > > > .Config> .Select((PXGraph)docgraph, (object)a.PlanID);
                    str = soLineSplit3 == null ? string.Empty : string.Format("{0}.{1}.{2:D7}", (object)soLineSplit3.OrderType, (object)soLineSplit3.OrderNbr, (object)soLineSplit3.SortOrder.GetValueOrDefault());
                }
                string strB;
                if (b.PlanType == "90")
                {
                    PX.Objects.IN.InventoryItem inventoryItem = PX.Objects.IN.InventoryItem.PK.Find((PXGraph)docgraph, b.InventoryID);
                    strB = string.Format("ZZ.{0}", inventoryItem == null ? (object)string.Empty : (object)inventoryItem.InventoryCD);
                }
                else
                {
                    POOrderEntry.SOLineSplit3 soLineSplit3 = (POOrderEntry.SOLineSplit3)PXSelectBase <POOrderEntry.SOLineSplit3, PXSelect <POOrderEntry.SOLineSplit3, Where <POOrderEntry.SOLineSplit3.planID, Equal <Required <POOrderEntry.SOLineSplit3.planID> > > > .Config> .Select((PXGraph)docgraph, (object)b.PlanID);
                    strB = soLineSplit3 == null ? string.Empty : string.Format("{0}.{1}.{2:D7}", (object)soLineSplit3.OrderType, (object)soLineSplit3.OrderNbr, (object)soLineSplit3.SortOrder.GetValueOrDefault());
                }
                return(str.CompareTo(strB));
            }));
            POOrder poOrder1 = (POOrder)null;
            bool    flag1    = false;

            foreach (POFixedDemand demand in list)
            {
                if (!(demand.FixedSource != "P"))
                {
                    string OrderType = demand.PlanType == "6D" ? "DP" : (demand.PlanType == "6E" ? "DP" : "RO");
                    string str1      = (string)null;
                    int?   nullable1 = demand.VendorID;
                    int    num1;
                    if (nullable1.HasValue)
                    {
                        nullable1 = demand.VendorLocationID;
                        num1      = !nullable1.HasValue ? 1 : 0;
                    }
                    else
                    {
                        num1 = 1;
                    }
                    if (num1 != 0)
                    {
                        PXProcessing <POFixedDemand> .SetWarning(list.IndexOf(demand), "Vendor and vendor location should be defined.");
                    }
                    else
                    {
                        PXErrorLevel pxErrorLevel = PXErrorLevel.RowInfo;
                        string       empty        = string.Empty;
                        try
                        {
                            PX.Objects.SO.SOOrder soOrder = (PX.Objects.SO.SOOrder) PXSelectBase <PX.Objects.SO.SOOrder, PXSelect <PX.Objects.SO.SOOrder, Where <PX.Objects.SO.SOOrder.noteID, Equal <Required <PX.Objects.SO.SOOrder.noteID> > > > .Config> .Select((PXGraph)docgraph, (object)demand.RefNoteID);

                            POOrderEntry.SOLineSplit3 soLineSplit3 = (POOrderEntry.SOLineSplit3) PXSelectBase <POOrderEntry.SOLineSplit3, PXSelect <POOrderEntry.SOLineSplit3, Where <POOrderEntry.SOLineSplit3.planID, Equal <Required <POOrderEntry.SOLineSplit3.planID> > > > .Config> .Select((PXGraph)docgraph, (object)demand.PlanID);

                            string str2 = (string)null;
                            string str3 = (string)null;
                            if (demand.PlanType == "6B" || demand.PlanType == "6E")
                            {
                                str2 = soLineSplit3.POType;
                                str3 = soLineSplit3.PONbr;
                            }
                            System.Collections.Generic.List <FieldLookup> fieldLookupList1 = new System.Collections.Generic.List <FieldLookup>()
                            {
                                (FieldLookup) new FieldLookup <POOrder.orderType>((object)OrderType),
                                (FieldLookup) new FieldLookup <POOrder.vendorID>((object)demand.VendorID),
                                (FieldLookup) new FieldLookup <POOrder.vendorLocationID>((object)demand.VendorLocationID),
                                (FieldLookup) new FieldLookup <POOrder.bLOrderNbr>((object)str3)
                            };
                            if (OrderType == "RO")
                            {
                                bool?projectPerDocument = docgraph.apsetup.Current.RequireSingleProjectPerDocument;
                                bool flag2 = true;
                                if (projectPerDocument.GetValueOrDefault() == flag2 & projectPerDocument.HasValue)
                                {
                                    nullable1 = demand.ProjectID;
                                    int?nullable2 = nullable1.HasValue ? nullable1 : ProjectDefaultAttribute.NonProject();
                                    fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.projectID>((object)nullable2));
                                }
                                int num2;
                                if (poOrder1 != null && poOrder1.ShipDestType == "L")
                                {
                                    nullable1 = poOrder1.SiteID;
                                    num2      = !nullable1.HasValue ? 1 : 0;
                                }
                                else
                                {
                                    num2 = 0;
                                }
                                if (num2 == 0)
                                {
                                    fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.siteID>((object)demand.POSiteID));
                                }
                            }
                            else if (OrderType == "DP")
                            {
                                fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.sOOrderType>((object)soLineSplit3.OrderType));
                                fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.sOOrderNbr>((object)soLineSplit3.OrderNbr));
                            }
                            else
                            {
                                fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.shipToBAccountID>((object)soOrder.CustomerID));
                                fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.shipToLocationID>((object)soOrder.CustomerLocationID));
                                fieldLookupList1.Add((FieldLookup) new FieldLookup <POOrder.siteID>((object)demand.POSiteID));
                            }
                            poOrder1 = documentList1.Find(fieldLookupList1.ToArray()) ?? new POOrder();
                            if (poOrder1.OrderNbr == null)
                            {
                                docgraph.Clear();
                                poOrder1.OrderType = OrderType;
                                poOrder1           = PXCache <POOrder> .CreateCopy(docgraph.Document.Insert(poOrder1));

                                poOrder1.VendorID         = demand.VendorID;
                                poOrder1.VendorLocationID = demand.VendorLocationID;
                                poOrder1.SiteID           = demand.POSiteID;
                                nullable1 = demand.ProjectID;
                                if (nullable1.HasValue)
                                {
                                    poOrder1.ProjectID = demand.ProjectID;
                                }
                                poOrder1.OrderDate  = PurchDate;
                                poOrder1.BLType     = str2;
                                poOrder1.BLOrderNbr = str3;
                                if (OrderType == "DP" | extSort)
                                {
                                    poOrder1.SOOrderType = soLineSplit3.OrderType;
                                    poOrder1.SOOrderNbr  = soLineSplit3.OrderNbr;
                                }
                                if (!string.IsNullOrEmpty(poOrder1.BLOrderNbr))
                                {
                                    POOrder poOrder2 = (POOrder)PXSelectBase <POOrder, PXSelect <POOrder, Where <POOrder.orderType, Equal <Current <POOrder.bLType> >, And <POOrder.orderNbr, Equal <Current <POOrder.bLOrderNbr> > > > > .Config> .SelectSingleBound((PXGraph)docgraph, new object[1]
                                    {
                                        (object)poOrder1
                                    });

                                    if (poOrder2 != null)
                                    {
                                        poOrder1.VendorRefNbr = poOrder2.VendorRefNbr;
                                    }
                                }
                                if (OrderType == "DP")
                                {
                                    poOrder1.ShipDestType     = "C";
                                    poOrder1.ShipToBAccountID = soOrder.CustomerID;
                                    poOrder1.ShipToLocationID = soOrder.CustomerLocationID;
                                }
                                else if (current.ShipDestType == "S")
                                {
                                    poOrder1.ShipDestType = "S";
                                    poOrder1.SiteID       = demand.POSiteID;
                                }
                                if (PXAccess.FeatureInstalled <PX.Objects.CS.FeaturesSet.multicurrency>())
                                {
                                    docgraph.currencyinfo.Current.CuryID = (string)null;
                                }
                                poOrder1 = docgraph.Document.Update(poOrder1);
                                if (OrderType == "DP")
                                {
                                    SOAddress soAddress = (SOAddress)PXSelectBase <SOAddress, PXSelect <SOAddress, Where <SOAddress.addressID, Equal <Required <PX.Objects.SO.SOOrder.shipAddressID> > > > .Config> .Select((PXGraph)docgraph, (object)soOrder.ShipAddressID);

                                    bool?isDefaultAddress = soAddress.IsDefaultAddress;
                                    bool flag2            = false;
                                    if (isDefaultAddress.GetValueOrDefault() == flag2 & isDefaultAddress.HasValue)
                                    {
                                        SharedRecordAttribute.CopyRecord <POOrder.shipAddressID>(docgraph.Document.Cache, (object)poOrder1, (object)soAddress, true);
                                    }
                                    SOContact soContact = (SOContact)PXSelectBase <SOContact, PXSelect <SOContact, Where <SOContact.contactID, Equal <Required <PX.Objects.SO.SOOrder.shipContactID> > > > .Config> .Select((PXGraph)docgraph, (object)soOrder.ShipContactID);

                                    bool?isDefaultContact = soContact.IsDefaultContact;
                                    bool flag3            = false;
                                    if (isDefaultContact.GetValueOrDefault() == flag3 & isDefaultContact.HasValue)
                                    {
                                        SharedRecordAttribute.CopyRecord <POOrder.shipContactID>(docgraph.Document.Cache, (object)poOrder1, (object)soContact, true);
                                    }
                                    DateTime?expectedDate = poOrder1.ExpectedDate;
                                    DateTime?requestDate  = soOrder.RequestDate;
                                    if (expectedDate.HasValue & requestDate.HasValue && expectedDate.GetValueOrDefault() < requestDate.GetValueOrDefault())
                                    {
                                        poOrder1 = PXCache <POOrder> .CreateCopy(poOrder1);

                                        poOrder1.ExpectedDate = soOrder.RequestDate;
                                        poOrder1 = docgraph.Document.Update(poOrder1);
                                    }
                                }
                            }
                            else if (!docgraph.Document.Cache.ObjectsEqual((object)docgraph.Document.Current, (object)poOrder1))
                            {
                                docgraph.Document.Current = (POOrder)docgraph.Document.Search <POOrder.orderNbr>((object)poOrder1.OrderNbr, (object)poOrder1.OrderType);
                            }
                            poOrder1.UpdateVendorCost = new bool?(false);
                            POLine poLine1 = (POLine)null;
                            DocumentList <POLine> documentList2;
                            if (!dictionary.TryGetValue(demand.PlanType, out documentList2))
                            {
                                documentList2 = dictionary[demand.PlanType] = new DocumentList <POLine>((PXGraph)docgraph);
                            }
                            if (OrderType == "RO" && demand.PlanType != "6B")
                            {
                                System.Collections.Generic.List <FieldLookup> fieldLookupList2 = new System.Collections.Generic.List <FieldLookup>();
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.vendorID>((object)demand.VendorID));
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.vendorLocationID>((object)demand.VendorLocationID));
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.siteID>((object)demand.POSiteID));
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.inventoryID>((object)demand.InventoryID));
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.subItemID>((object)demand.SubItemID));
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.requestedDate>((object)(DateTime?)soLineSplit3?.ShipDate));
                                int?nullable2;
                                if (soLineSplit3 == null)
                                {
                                    nullable1 = new int?();
                                    nullable2 = nullable1;
                                }
                                else
                                {
                                    nullable2 = soLineSplit3.ProjectID;
                                }
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.projectID>((object)nullable2));
                                int?nullable3;
                                if (soLineSplit3 == null)
                                {
                                    nullable1 = new int?();
                                    nullable3 = nullable1;
                                }
                                else
                                {
                                    nullable3 = soLineSplit3.TaskID;
                                }
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.taskID>((object)nullable3));
                                int?nullable4;
                                if (soLineSplit3 == null)
                                {
                                    nullable1 = new int?();
                                    nullable4 = nullable1;
                                }
                                else
                                {
                                    nullable4 = soLineSplit3.CostCodeID;
                                }
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.costCodeID>((object)nullable4));
                                int?nullable5;
                                if (soLineSplit3 == null)
                                {
                                    nullable1 = new int?();
                                    nullable5 = nullable1;
                                }
                                else
                                {
                                    nullable5 = soLineSplit3.LineNbr;
                                }
                                fieldLookupList2.Add((FieldLookup) new FieldLookup <POLine.lineNbr>((object)nullable5));
                                System.Collections.Generic.List <FieldLookup> fieldLookupList3 = fieldLookupList2;
                                bool?nullable6 = current.CopyLineDescrSO;
                                bool flag2     = true;
                                if (nullable6.GetValueOrDefault() == flag2 & nullable6.HasValue && soLineSplit3 != null)
                                {
                                    fieldLookupList3.Add((FieldLookup) new FieldLookup <POLine.tranDesc>((object)soLineSplit3.TranDesc));
                                    poLine1 = documentList2.Find(fieldLookupList3.ToArray());
                                    int num2;
                                    if (poLine1 != null)
                                    {
                                        nullable6 = current.CopyLineNoteSO;
                                        bool flag3 = true;
                                        if (nullable6.GetValueOrDefault() == flag3 & nullable6.HasValue)
                                        {
                                            num2 = PXNoteAttribute.GetNote(docgraph.Caches[typeof(POLine)], (object)poLine1) != null ? 1 : (PXNoteAttribute.GetNote(docgraph.Caches[typeof(POOrderEntry.SOLineSplit3)], (object)soLineSplit3) != null ? 1 : 0);
                                            goto label_67;
                                        }
                                    }
                                    num2 = 0;
label_67:
                                    if (num2 != 0)
                                    {
                                        poLine1 = (POLine)null;
                                    }
                                }
                                else
                                {
                                    poLine1 = documentList2.Find(fieldLookupList3.ToArray());
                                }
                            }
                            POLine dest = poLine1 ?? new POLine();
                            POLine copy1;
                            if (dest.OrderNbr == null)
                            {
                                docgraph.FillPOLineFromDemand(dest, demand, OrderType, soLineSplit3);
                                POLine line           = docgraph.Transactions.Insert(dest);
                                bool?  copyLineNoteSo = current.CopyLineNoteSO;
                                bool   flag2          = true;
                                if (copyLineNoteSo.GetValueOrDefault() == flag2 & copyLineNoteSo.HasValue && soLineSplit3 != null)
                                {
                                    PXNoteAttribute.SetNote(docgraph.Transactions.Cache, (object)line, PXNoteAttribute.GetNote(docgraph.Caches[typeof(POOrderEntry.SOLineSplit3)], (object)soLineSplit3));
                                }
                                if (docgraph.onCopyPOLineFields != null)
                                {
                                    docgraph.onCopyPOLineFields(demand, line);
                                }
                                copy1 = PXCache <POLine> .CreateCopy(line);

                                documentList2.Add(copy1);
                            }
                            else
                            {
                                copy1 = PXCache <POLine> .CreateCopy((POLine)PXSelectBase <POLine, PXSelect <POLine, Where <POLine.orderType, Equal <Current <POOrder.orderType> >, And <POLine.orderNbr, Equal <Current <POOrder.orderNbr> >, And <POLine.lineNbr, Equal <Current <POLine.lineNbr> > > > > > .Config> .SelectSingleBound((PXGraph)docgraph, new object[1]
                                {
                                    (object)dest
                                }));

                                POLine  poLine2   = copy1;
                                Decimal?orderQty1 = poLine2.OrderQty;
                                Decimal?orderQty2 = demand.OrderQty;
                                poLine2.OrderQty = orderQty1.HasValue & orderQty2.HasValue ? new Decimal?(orderQty1.GetValueOrDefault() + orderQty2.GetValueOrDefault()) : new Decimal?();
                            }
                            if (demand.PlanType == "6B" || demand.PlanType == "6E")
                            {
                                str1 = demand.PlanType == "6B" ? "66" : "6D";
                                demand.FixedSource = "P";
                                copy1.POType       = soLineSplit3.POType;
                                copy1.PONbr        = soLineSplit3.PONbr;
                                copy1.POLineNbr    = soLineSplit3.POLineNbr;
                                POLine poLine2 = (POLine)PXSelectBase <POLine, PXSelect <POLine, Where <POLine.orderType, Equal <Current <POLine.pOType> >, And <POLine.orderNbr, Equal <Current <POLine.pONbr> >, And <POLine.lineNbr, Equal <Current <POLine.pOLineNbr> > > > > > .Config> .SelectSingleBound((PXGraph)docgraph, new object[1]
                                {
                                    (object)copy1
                                });

                                if (poLine2 != null)
                                {
                                    Decimal?nullable2   = demand.PlanQty;
                                    Decimal?baseOpenQty = poLine2.BaseOpenQty;
                                    if (nullable2.GetValueOrDefault() > baseOpenQty.GetValueOrDefault() & (nullable2.HasValue & baseOpenQty.HasValue))
                                    {
                                        POLine  poLine3  = copy1;
                                        Decimal?orderQty = poLine3.OrderQty;
                                        nullable2        = demand.OrderQty;
                                        poLine3.OrderQty = orderQty.HasValue & nullable2.HasValue ? new Decimal?(orderQty.GetValueOrDefault() - nullable2.GetValueOrDefault()) : new Decimal?();
                                        if (string.Equals(copy1.UOM, poLine2.UOM))
                                        {
                                            POLine poLine4 = copy1;
                                            nullable2 = poLine4.OrderQty;
                                            Decimal?openQty = poLine2.OpenQty;
                                            poLine4.OrderQty = nullable2.HasValue & openQty.HasValue ? new Decimal?(nullable2.GetValueOrDefault() + openQty.GetValueOrDefault()) : new Decimal?();
                                        }
                                        else
                                        {
                                            PXDBQuantityAttribute.CalcBaseQty <POLine.orderQty>(docgraph.Transactions.Cache, (object)copy1);
                                            POLine  poLine4      = copy1;
                                            Decimal?baseOrderQty = poLine4.BaseOrderQty;
                                            nullable2            = poLine2.BaseOpenQty;
                                            poLine4.BaseOrderQty = baseOrderQty.HasValue & nullable2.HasValue ? new Decimal?(baseOrderQty.GetValueOrDefault() + nullable2.GetValueOrDefault()) : new Decimal?();
                                            PXDBQuantityAttribute.CalcTranQty <POLine.orderQty>(docgraph.Transactions.Cache, (object)copy1);
                                        }
                                        pxErrorLevel = PXErrorLevel.RowWarning;
                                        empty       += PXMessages.LocalizeFormatNoPrefixNLA("Order Quantity reduced to Blanket Order: '{0}' Open Qty. for this item", (object)copy1.PONbr);
                                    }
                                    copy1.CuryUnitCost = poLine2.CuryUnitCost;
                                    copy1.UnitCost     = poLine2.UnitCost;
                                }
                            }
                            copy1.SiteID = POCreate_Extension.GetWasrehouseByBranch((PXGraph)docgraph, copy1.BranchID);
                            short?       vleadTime = docgraph.location.Current.VLeadTime;
                            POLine       poLine5   = copy1;
                            DateTime     dateTime  = soLineSplit3.ShipDate.Value;
                            ref DateTime local     = ref dateTime;
                            short?       nullable7 = vleadTime;
                            nullable1 = nullable7.HasValue ? new int?((int)nullable7.GetValueOrDefault()) : new int?();
                            int      num3      = 0;
                            double   num4      = nullable1.GetValueOrDefault() > num3 & nullable1.HasValue ? (double)-vleadTime.Value : -14.0;
                            DateTime?nullable8 = new DateTime?(local.AddDays(num4));
                            poLine5.RequestedDate = nullable8;
                            POLine  poLine6 = docgraph.Transactions.Update(copy1);
                            PXCache cach    = docgraph.Caches[typeof(INItemPlan)];
                            POCreate_Extension.CreateSplitDemand2(cach, demand);
                            cach.SetStatus((object)demand, PXEntryStatus.Updated);
                            demand.SupplyPlanID = poLine6.PlanID;
                            if (str1 != null)
                            {
                                cach.RaiseRowDeleted((object)demand);
                                demand.PlanType = str1;
                                cach.RaiseRowInserted((object)demand);
                            }
                            if (soLineSplit3 != null)
                            {
                                int num2;
                                if (demand.AlternateID != null)
                                {
                                    nullable1 = demand.InventoryID;
                                    num2      = nullable1.HasValue ? 1 : 0;
                                }
                                else
                                {
                                    num2 = 0;
                                }
                                if (num2 != 0)
                                {
                                    PXSelectBase <INItemXRef> pxSelectBase = (PXSelectBase <INItemXRef>) new PXSelect <INItemXRef, Where <INItemXRef.inventoryID, Equal <Required <INItemXRef.inventoryID> >, And <INItemXRef.alternateID, Equal <Required <INItemXRef.alternateID> > > > >((PXGraph)docgraph);
                                    INItemXRef inItemXref1 = (INItemXRef)pxSelectBase.Select((object)demand.InventoryID, (object)demand.AlternateID);
                                    if (inItemXref1 != null && inItemXref1.AlternateType == "GLBL")
                                    {
                                        int num5;
                                        if (poLine6.AlternateID != null)
                                        {
                                            nullable1 = poLine6.InventoryID;
                                            num5      = nullable1.HasValue ? 1 : 0;
                                        }
                                        else
                                        {
                                            num5 = 0;
                                        }
                                        if (num5 != 0)
                                        {
                                            INItemXRef inItemXref2 = (INItemXRef)pxSelectBase.Select((object)poLine6.InventoryID, (object)poLine6.AlternateID);
                                            if (inItemXref2 != null && inItemXref2.AlternateType == "GLBL")
                                            {
                                                poLine6.AlternateID = demand.AlternateID;
                                            }
                                        }
                                        else
                                        {
                                            poLine6.AlternateID = demand.AlternateID;
                                        }
                                    }
                                }
                                soLineSplit3.POType    = poLine6.OrderType;
                                soLineSplit3.PONbr     = poLine6.OrderNbr;
                                soLineSplit3.POLineNbr = poLine6.LineNbr;
                                soLineSplit3.RefNoteID = docgraph.Document.Current.NoteID;
                                PX.Objects.SO.SOLine soLine = SelectFrom <PX.Objects.SO.SOLine> .Where <PX.Objects.SO.SOLine.orderType.IsEqual <P.AsString>
                                                                                                        .And <PX.Objects.SO.SOLine.orderNbr.IsEqual <P.AsString>
                                                                                                              .And <PX.Objects.SO.SOLine.lineNbr.IsEqual <P.AsInt> > > > .View.ReadOnly.Select((PXGraph)docgraph, (object)soLineSplit3.OrderType, (object)soLineSplit3.OrderNbr, (object)soLineSplit3.LineNbr);

                                POLineExt extension1 = poLine6.GetExtension <POLineExt>();
                                SOLineExt extension2 = soLine.GetExtension <SOLineExt>();
                                extension1.UsrEndCustomerID = extension2.UsrEndCustomerID;
                                extension1.UsrNonStockItem  = extension2.UsrNonStockItem;
                                extension1.UsrProjectNbr    = extension2.UsrProjectNbr;
                                if (!string.IsNullOrEmpty(extension2.UsrProjectNbr))
                                {
                                    FLXProject flxProject = SelectFrom <FLXProject> .Where <FLXProject.projectNbr.IsEqual <P.AsString> > .View.ReadOnly.Select((PXGraph)docgraph, (object)extension2.UsrProjectNbr);

                                    extension1.UsrCust2Factory = flxProject.Cust2Factory;
                                    extension1.UsrFactoryPN    = flxProject.FactoryPN;
                                }
                                docgraph.GetExtension <POOrderEntry_Extension>().UpdateSOLine(soLineSplit3, docgraph.Document.Current.VendorID, true);
                                docgraph.FixedDemand.Cache.SetStatus((object)soLineSplit3, PXEntryStatus.Updated);
                            }
                            if (docgraph.Transactions.Cache.IsInsertedUpdatedDeleted)
                            {
                                using (PXTransactionScope transactionScope = new PXTransactionScope())
                                {
                                    docgraph.Save.Press();
                                    if (demand.PlanType == "90")
                                    {
                                        docgraph.Replenihment.Current = (INReplenishmentOrder)docgraph.Replenihment.Search <INReplenishmentOrder.noteID>((object)demand.RefNoteID);
                                        if (docgraph.Replenihment.Current != null)
                                        {
                                            INReplenishmentLine copy2 = PXCache <INReplenishmentLine> .CreateCopy(docgraph.ReplenishmentLines.Insert(new INReplenishmentLine()));

                                            copy2.InventoryID      = poLine6.InventoryID;
                                            copy2.SubItemID        = poLine6.SubItemID;
                                            copy2.UOM              = poLine6.UOM;
                                            copy2.VendorID         = poLine6.VendorID;
                                            copy2.VendorLocationID = poLine6.VendorLocationID;
                                            copy2.Qty              = poLine6.OrderQty;
                                            copy2.POType           = poLine6.OrderType;
                                            copy2.PONbr            = docgraph.Document.Current.OrderNbr;
                                            copy2.POLineNbr        = poLine6.LineNbr;
                                            copy2.SiteID           = demand.POSiteID;
                                            copy2.PlanID           = demand.PlanID;
                                            docgraph.ReplenishmentLines.Update(copy2);
                                            docgraph.Caches[typeof(INItemPlan)].Delete((object)demand);
                                            docgraph.Save.Press();
                                        }
                                    }
                                    transactionScope.Complete();
                                }
                                if (pxErrorLevel == PXErrorLevel.RowInfo)
                                {
                                    PXProcessing <POFixedDemand> .SetInfo(list.IndexOf(demand), PXMessages.LocalizeFormatNoPrefixNLA("Purchase Order '{0}' created.", (object)docgraph.Document.Current.OrderNbr) + "\r\n" + empty);
                                }
                                else
                                {
                                    PXProcessing <POFixedDemand> .SetWarning(list.IndexOf(demand), PXMessages.LocalizeFormatNoPrefixNLA("Purchase Order '{0}' created.", (object)docgraph.Document.Current.OrderNbr) + "\r\n" + empty);
                                }
                                if (documentList1.Find((object)docgraph.Document.Current) == null)
                                {
                                    documentList1.Add(docgraph.Document.Current);
                                }
                            }
                        }
示例#14
0
        private void processLines(
            List <POEnabledFSSODet> originalItemList,
            PXGraph <CreatePurchaseOrderProcess> graphCreatePurchaseOrderByServiceOrder,
            List <List <POEnabledFSSODet> > groupedFSSODetRows)
        {
            if (groupedFSSODetRows.Count == 0)
            {
                return;
            }

            POOrder          poOrderRow = null;
            POLine           poLineRow  = null;
            POEnabledFSSODet firstPOEnabledFSSODetRow = null;

            PXGraph      processGraph      = new PXGraph();
            POOrderEntry graphPOOrderEntry = CreateInstance <POOrderEntry>();

            foreach (List <POEnabledFSSODet> itemGroup in groupedFSSODetRows)
            {
                if (!this.IsThisItemGroupValid(itemGroup, originalItemList))
                {
                    continue;
                }

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    try
                    {
                        processGraph.Clear(PXClearOption.ClearAll);
                        graphPOOrderEntry.Clear(PXClearOption.ClearAll);

                        this.CreatePOOrderDocument(graphPOOrderEntry, itemGroup, poOrderRow, poLineRow, firstPOEnabledFSSODetRow);

                        foreach (POEnabledFSSODet poEnabledFSSODetRow in itemGroup)
                        {
                            PXUpdate <
                                Set <FSSODet.poType, Required <FSSODet.poType>,
                                     Set <FSSODet.poNbr, Required <FSSODet.poNbr>,
                                          Set <FSSODet.poLineNbr, Required <FSSODet.poLineNbr>,
                                               Set <FSSODet.poStatus, Required <FSSODet.poStatus>,
                                                    Set <FSSODet.poCompleted, Required <FSSODet.poCompleted>,
                                                         Set <FSSODet.poVendorID, Required <FSSODet.poVendorID>,
                                                              Set <FSSODet.poVendorLocationID, Required <FSSODet.poVendorLocationID> > > > > > > >,
                                FSSODet,
                                Where <
                                    FSSODet.sODetID, Equal <Required <FSSODet.sODetID> >,
                                    And <FSSODet.poNbr, IsNull> > >
                            .Update(
                                processGraph,
                                poEnabledFSSODetRow.POType,
                                graphPOOrderEntry.Document.Current.OrderNbr,
                                poEnabledFSSODetRow.POLineNbr,
                                graphPOOrderEntry.Document.Current.Status,
                                poEnabledFSSODetRow.POCompleted,
                                poEnabledFSSODetRow.POVendorID,
                                poEnabledFSSODetRow.POVendorLocationID,
                                poEnabledFSSODetRow.SODetID);

                            PXProcessing <POEnabledFSSODet> .SetInfo(originalItemList.IndexOf(poEnabledFSSODetRow), TX.Messages.RECORD_PROCESSED_SUCCESSFULLY);

                            poEnabledFSSODetRow.PONbrCreated = graphPOOrderEntry.Document.Current.OrderNbr;
                        }

                        ts.Complete();
                    }
                    catch (Exception e)
                    {
                        ts.Dispose();

                        foreach (POEnabledFSSODet poEnabledFSSODetRow in itemGroup)
                        {
                            PXProcessing <POEnabledFSSODet> .SetError(originalItemList.IndexOf(poEnabledFSSODetRow), e);
                        }
                    }
                }
            }
        }