I am trying to create purchase orders through coding, everything works except that the unit cost never gets saved! Here is my code snippet:
try
{
bo.GetNewPOHeader(ds);
ds.Tables["POHeader"].Rows[0]["VendorNum"] = vendorNum;
ds.Tables["POHeader"].Rows[0]["ShipViaCode"] = shipViaCode;
bo.Update(ds);
poNum = int.Parse(ds.Tables[0].Rows[0]["PONum"].ToString());
for (int itr = 0; itr < dtLines.Rows.Count; itr++)
{
bo.GetNewPODetail(ds, poNum);
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["PartNum"] = dtLines.Rows[itr]["Part"].ToString().Trim();
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["CalcOurQty"] = decimal.Parse(dtLines.Rows[itr]["Qty"].ToString());
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["CalcVendQty"] = decimal.Parse(dtLines.Rows[itr]["Qty"].ToString());
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["cf_ShopOrderNum_C1380_c"] = int.Parse(dtLines.Rows[itr]["ShopOrderNum"].ToString());
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["UnitCost"] = 1;
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["DocUnitCost"] = 1;
ds.Tables["PODetail"].Rows[ds.Tables["PODetail"].Rows.Count - 1]["DocScrUnitCost"] = 1;
bo.Update(ds);
}
}
catch(Exception e)
{
_log.Log(e.Message);
_log.Log(e.ToString());
errMessage = string.Format("{0}{1}{1}{2}", e.Message, Environment.NewLine, e.ToString());
}
Any idea what I am missing? As you can see I have tried three different fields and have also tried them individually but no luck.