0

我正在尝试通过图形插入销售订单我的代码可以使用,但无法插入数据库这是我创建销售订单的代码。我正在使用 Acumatica 4.0

void genSO(string outletCD,string salesmanCD)
{
            Customer cus =
                PXSelect<Customer, Where<Customer.acctCD, Equal<Required<Customer.acctCD>>>>
                    .Select(this, outletCD);

            SalesPerson salesman=
                PXSelect<SalesPerson, Where<SalesPerson.salesPersonCD, Equal<Required<SalesPerson.salesPersonCD>>>>
                    .Select(this, salesmanCD);


            if (cus != null && cus.BAccountID != null )
            {

                SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
                SOOrder newOrder = graph.Document.Insert();
                newOrder.OrderType = "SO";
                newOrder.OrderDate=DateTime.Now;
                newOrder.RequestDate = DateTime.Now;
                newOrder.CustomerID = cus.BAccountID;

                graph.Document.Cache.RaiseFieldUpdated<SOOrder.customerID>(newOrder, null);
                newOrder.SalesPersonID = smNPP.SalesPersonID;
                graph.Document.Cache.RaiseFieldUpdated<SOOrder.salesPersonID>(newOrder, null);


                newOrder.Status = "N";
                graph.Document.Current = newOrder;

                graph.Document.Cache.Update(newOrder);
                graph.Actions.PressSave();
            }
}

谢谢你的帮助。

4

2 回答 2

0

尝试这个:

SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
SOOrder newOrder = (SOOrder)graph.Document.Cache.CreateInstance();
//Fill only keys.
newOrder.OrderType = "SO";    
newOrder = sograph.Document.Insert(newOrder);
//Apply automation step.
newOrder = PXCache<SOOrder>.CreateCopy(graph.Document.Search<SOOrder.orderNbr>(newOrder.OrderNbr));
newOrder.OrderDate=DateTime.Now;
newOrder.RequestDate = DateTime.Now;
newOrder.CustomerID = cus.BAccountID;
newOrder.SalesPersonID = smNPP.SalesPersonID;
graph.Document.Update(newOrder);
graph.Actions.PressSave();
于 2014-10-09T04:44:42.333 回答
0

图.文档.插入(新订单);图.Persist();

于 2014-10-15T15:55:28.527 回答