I am getting the error
Order has been shipped, cannot add.
when I run some C# code. I have no idea what is causing this. I am creating the TFOrdHed record just fine, it just fails when it tries to create the lines for the order.
Here is my code where I create these. MessageBox "2" is as far as it gets when trying to create the dtl before the error. It never reaches 3:
private void CallTransferOrderEntryAdapterGetNewTFOrdHedMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
// Declare and create an instance of the Adapter.
TransferOrderEntryAdapter adapterTransferOrderEntry = new TransferOrderEntryAdapter(this.oTrans);
adapterTransferOrderEntry.BOConnect();
// Declare and Initialize Variables
string tfOrdNum="";
// Call Adapter method
//bool test = adapterTransferOrderEntry.GetByID(tfOrdNum);
// Call Adapter method
bool result = adapterTransferOrderEntry.GetNewTFOrdHed();
TransferOrderEntryDataSet toeds = adapterTransferOrderEntry.TransferOrderEntryData;
toeds.TFOrdHed[0].OrderDate = DateTime.Today;
toeds.TFOrdHed[0].ToPlant = cmbToWH.Value.ToString();
toeds.TFOrdHed[0].ShipViaCode = "101";
toeds.TFOrdHed[0].Plant = cmbFromWH.Value.ToString();
toeds.TFOrdHed[0].ToPlant = cmbToWH.Value.ToString();
toeds.TFOrdHed[0].Date01 = DateTime.Today;
toeds.TFOrdHed[0].Date02 = DateTime.Today;
toeds.TFOrdHed[0].Shipped = false;
//toeds.TFOrdHed[0].EntryPerson = DcdUserID;
bool test = adapterTransferOrderEntry.Update();
TransferOrderEntryDataSet toedsu = adapterTransferOrderEntry.TransferOrderEntryData;
string TFOrdNum = toeds.TFOrdHed[0].TFOrdNum;
EpiDataView tfoedv = (EpiDataView)oTrans.EpiDataViews["TFOrdHed"];
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in grdResults.Rows)
if (Convert.ToBoolean(row.Cells[0].Value))
CallTransferOrderEntryAdapterGetNewTFOrdDtlMethod(row,TFOrdNum ,tfoedv );
// Cleanup Adapter Reference
adapterTransferOrderEntry.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
private void CallTransferOrderEntryAdapterGetNewTFOrdDtlMethod(Infragistics.Win.UltraWinGrid.UltraGridRow row, String TFOrdNum,EpiDataView view )
{
MessageBox.Show("1");
try
{
// Declare and Initialize EpiDataView Variables
// Declare and create an instance of the Adapter.
TransferOrderEntryAdapter adapterTransferOrderEntry = new TransferOrderEntryAdapter(this.oTrans);
adapterTransferOrderEntry.BOConnect();
MessageBox.Show("2");
// Call Adapter method
adapterTransferOrderEntry.GetByID(TFOrdNum);
TransferOrderEntryDataSet datasettfo = adapterTransferOrderEntry.TransferOrderEntryData;
bool dtl = adapterTransferOrderEntry.GetNewTFOrdDtl();
TransferOrderEntryDataSet toedsdtl = adapterTransferOrderEntry.TransferOrderEntryData;
MessageBox.Show("3");
toedsdtl.TFOrdDtl[0].TFOrdNum =TFOrdNum;
toedsdtl.TFOrdDtl[0].OrderFirm = true;
toedsdtl.TFOrdDtl[0].CreateOrder = true;
toedsdtl.TFOrdDtl[0].RequiredQty = Convert.ToDecimal(row.Cells[8].Value);
toedsdtl.TFOrdDtl[0].OurStockQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].SellingQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].ThisOrderInvtyQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].Selected = true;
toedsdtl.TFOrdDtl[0].OrderFirm = true;
toedsdtl.TFOrdDtl[0].CreateOrder = true;
toedsdtl.TFOrdDtl[0].RequiredQty = Convert.ToDecimal(row.Cells[8].Value);
toedsdtl.TFOrdDtl[0].OurStockQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].SellingQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].ThisOrderInvtyQty = toedsdtl.TFOrdDtl[0].RequiredQty;
toedsdtl.TFOrdDtl[0].Selected = true;
toedsdtl.TFOrdDtl[0].PartNum =(row.Cells[1].Value.ToString());
toedsdtl.TFOrdDtl[0].SellingQtyUOM =(row.Cells[3].Value.ToString());
toedsdtl.TFOrdDtl[0].Shipped = false;
bool result = adapterTransferOrderEntry.Update();
// Cleanup Adapter Reference
MessageBox.Show("4");
adapterTransferOrderEntry.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}