示例#1
0
        static void LoadSalesOrder(SalesOrderSvcContractClient salesOrderClient, SalesOrder so, out string result)
        {
            var ts = new SalesOrderTableset();
            result = "p_";
            salesOrderClient.GetNewOrderHed(ref ts);

            var newRow = ts.OrderHed.Where(n => n.RowMod.Equals("A", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            // Guid rowID = newRow.SysRowID;

            // FastLoad.SalesOrder so = new FastLoad.SalesOrder();
            E10Lookup look = new E10Lookup();
            int custNum = look.GetCustomerNum(so.CustomerID);

            if (newRow != null)
            {
                newRow.Company = so.Company;

                Epicor.SalesOrderSvc.UserDefinedColumns columns = newRow.UserDefinedColumns;

                /*
                foreach (KeyValuePair<string, object> kvp in columns)
                {
                    Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                }
                */
                columns["OrderType_c"] = "EDI";
                columns["EDIHeadChar11_c"] = "";
                // columns["EDIHeadChar11_c"] = "hello";

                // newRow.BTCustID = so.CustomerID;
                
                newRow.CustNum = custNum;
                newRow.BTCustNum = custNum;
                if (so.ShipVia.Equals("UGND"))
                {
                    newRow.ShipViaCode = "UPGD";
                }
                else
                {
                    newRow.ShipViaCode = so.ShipVia;
                }

                newRow.PONum = so.PoNo;
                newRow.TermsCode = so.TermsCode;
                newRow.ShipToNum = so.ShipToNum;
                newRow.ShipToCustNum = custNum;
                newRow.NeedByDate = so.NeedByDate;
                
                newRow.OrderDate = so.OrderDate;
                newRow.RequestDate = so.RequestDate;
                newRow.ReadyToCalc = true;
                
#if STEINMART
                newRow.PickListComment = so.ediMarkingNotes;
                newRow.RefNotes = so.ediMarkingNotes;
                newRow.ShipComment = so.ediMarkingNotes;

#endif
                newRow.RowMod = "A";
                try
                {
                    salesOrderClient.Update(ref ts);
                }
                catch (Exception e)
                {
                    string message = e.Message;
                    result = message.Substring(0, 3);
                    bool AllOk = false;
                }
            }

            int orderNum = ts.OrderHed[0].OrderNum;

            ts = salesOrderClient.GetByID(orderNum);

            if (ts != null)
            {
                result = orderNum.ToString();
                foreach (OrderLine line in so.lines)
                {
                    bool Inactive = look.IsPartInActive(line.Upc);
                    if (Inactive)
                    {
                        continue;
                    }
                    salesOrderClient.GetNewOrderDtl(ref ts, orderNum);
                    string PartDescription = look.GetPartDescr(line.Upc);
                    //  ts = salesOrderClient.GetByID(orderNum);
                    string dtlrow = ts.OrderDtl[0].RowMod;
                    var newDtlRow = ts.OrderDtl.Where(n => n.RowMod.Equals("A", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                    newDtlRow.PartNum = line.Upc;
                    
                    newDtlRow.PartNumPartDescription = PartDescription;
                    newDtlRow.LineDesc = PartDescription;
                    newDtlRow.XPartNum = line.CustomerPart;
                    newDtlRow.OrderLine = line.LineNum;
                    newDtlRow.OrderQty = line.OrderQty;
                    newDtlRow.PricingQty = line.OrderQty;
                    newDtlRow.SellingQuantity = line.OrderQty;
                    newDtlRow.SalesUM = so.Get_UOM_FromSellingFactor(line.SellingFactor);

                    // newDtlRow.DocInUnitPrice = line.UnitPrice;
                    newDtlRow.DocUnitPrice = line.UnitPrice;
                    // newDtlRow.Reference = "123456";
                    newDtlRow.UnitPrice = line.UnitPrice;
                    newDtlRow.SellingFactor = line.SellingFactor;
                    // newDtlRow.RevisionNum = "PCK";
                    newDtlRow.RowMod = "A";
                    // newRow.RowMod = "U";
                    try
                    {
                        salesOrderClient.Update(ref ts);
                        ts = salesOrderClient.GetByID(orderNum);
                    }
                    catch (Exception ex2)
                    {
                        string mess2 = ex2.Message;
                        // result = ex2.Message;
                    }

                }
                try
                {
                    ts = salesOrderClient.GetByID(orderNum);
                    TaxConnectStatusRow taxrow = ts.TaxConnectStatus.First();
                    taxrow.ETCOffline = true;
                    salesOrderClient.Update(ref ts);
                }
                catch (Exception ex2)
                {
                    string messtaxOffline = ex2.Message;
                    // result = ex2.Message;
                }
            }
        }