我試圖通過圖表插入銷售訂單 我的代碼正常,但無法插入數據庫 這是我創建銷售訂單的代碼。我正在使用Acumatica 4.0在Acumatica中插入銷售訂單圖表
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();
}
}
感謝您的幫助。
您是否收到任何錯誤?或者它什麼都不做? – Gabriel 2014-10-08 17:09:12
不是。但是數據無法插入到數據庫中 – 2014-10-09 00:59:02
我可以發現這個代碼的一些問題,但它在4.2中正常工作並且插入了一個訂單。首先,你應該用DateTime.Today替換DateTime.Now。 – Gabriel 2014-10-09 02:00:28