Has anyone found a way to delete a PackNum record in the SubShipH table from a c# customization?
The only way we could do it was to Launch the Subcontractor Shipment Entry form and manually delete it.
We tried this code and got the exception in the image below.
if (PackingSlipNum > 0)
{
SubConShipEntryAdapter shpAdpt = new Erp.Adapters.SubConShipEntryAdapter(UD110Form);
shpAdpt.BOConnect();
shpAdpt.DeleteByID(PackingSlipNum);
shpAdpt.Dispose();
//Reset the load list items
foreach (DataRow dRow in PSGridTbl.Rows)
{
string Key1 = dRow["UD110_Key1"].ToString();
string Key2 = dRow["UD110_Key2"].ToString();
string Key3 = dRow["UD110_Key3"].ToString();
int origQty = Convert.ToInt32(Convert.ToDouble(dRow["Calculated_CalQty"].ToString()));
DateTime EmptyDate = new DateTime();
UD110Adapter udAdpt = new UD110Adapter(UD110Form);
udAdpt.BOConnect();
bool GotRow = udAdpt.GetByID(Key1, Key2, Key3, "", "");
if (GotRow == true)
{
foreach(DataRow aRow in udAdpt.UD110Data.UD110A.Rows)
{
if (Convert.ToInt32(Convert.ToDouble(aRow["Number13"].ToString())) == PackingSlipNum)
{
udAdpt.UD110Data.UD110A.Rows[0]["Date07"] = EmptyDate;
udAdpt.UD110Data.UD110A.Rows[0]["Number13"] = 0;
udAdpt.Update();
}
}
}
udAdpt.Dispose();
}
//If we are able to get the delete code above to work, this can be commented out
MessageBox.Show("The packing slip needs to be deleted. Opening the packing slip for you to delete.");
LaunchFormOptions LFO = new LaunchFormOptions();
LFO.ContextValue = PackingSlipNum.ToString();
LFO.ValueIn = PackingSlipNum.ToString();
ProcessCaller.LaunchForm(oTrans, "SRGO0010", LFO);
}