I have a custom screen with PO OCX on a .NET form. I replaced the Post button with my own new Post button. I wanted to validate only the Items of the vendor can be posted. I could get to the point where the Post did not get fired even when the Items are valid. Below is my code. At the end of the code where I commented "//This event never fires" is the issue. I want "vPostButton.Value = true" to run the Post of the PO. Can you help please. Appreciate your input.
private void btnNewPost_Click(object sender, EventArgs e)
{
//vPostButton = acPO.UIAppControls["APP_Post_Button"];
//vPostButton.Value = false;
bool bOkay = true;
List<string> lstMsg = new List<string>();
string sVendor = dsPOHeader.Fields.FieldByName["VDCODE"].get_Value().ToString();
dsPODetail.GoTop();
dsPODetail.Read();
if (dsPODetail.Exists == true)
{
if (dsPODetail.Fetch())
{
do
{
string sItem = dsPODetail.Fields.FieldByName["ITEMNO"].get_Value().ToString();
string sUnitCost = dsPODetail.Fields.FieldByName["UNITCOST"].get_Value().ToString();
if (Is_Item_In_VendorItems(sItem, sVendor) == false)
{
string sMsg = "Item : " + sItem;
lstMsg.Add(sMsg);
bOkay = false;
}
} while (dsPODetail.Fetch());
}
}
if (bOkay == false)
{
string sMsg = "";
for (int i = 0; i < lstMsg.Count; i++)
{
sMsg = sMsg + lstMsg + "\n";
}
MessageBox.Show("Can't Post. The below PO line items are not for Vendor " + sVendor + "\n\n" + sMsg);
// vPostButton = Accpac acPO.UIAppControls["APP_Post_Button"].GetControl();
vPostButton.Value = false; //This event never fires
}
else
{
//vPostButton = acPO.UIAppControls["APP_Post_Button"];
vPostButton.Value = true; //This event never fires
}
}
private void btnNewPost_Click(object sender, EventArgs e)
{
//vPostButton = acPO.UIAppControls["APP_Post_Button"];
//vPostButton.Value = false;
bool bOkay = true;
List<string> lstMsg = new List<string>();
string sVendor = dsPOHeader.Fields.FieldByName["VDCODE"].get_Value().ToString();
dsPODetail.GoTop();
dsPODetail.Read();
if (dsPODetail.Exists == true)
{
if (dsPODetail.Fetch())
{
do
{
string sItem = dsPODetail.Fields.FieldByName["ITEMNO"].get_Value().ToString();
string sUnitCost = dsPODetail.Fields.FieldByName["UNITCOST"].get_Value().ToString();
if (Is_Item_In_VendorItems(sItem, sVendor) == false)
{
string sMsg = "Item : " + sItem;
lstMsg.Add(sMsg);
bOkay = false;
}
} while (dsPODetail.Fetch());
}
}
if (bOkay == false)
{
string sMsg = "";
for (int i = 0; i < lstMsg.Count; i++)
{
sMsg = sMsg + lstMsg + "\n";
}
MessageBox.Show("Can't Post. The below PO line items are not for Vendor " + sVendor + "\n\n" + sMsg);
// vPostButton = Accpac acPO.UIAppControls["APP_Post_Button"].GetControl();
vPostButton.Value = false; //This event never fires
}
else
{
//vPostButton = acPO.UIAppControls["APP_Post_Button"];
vPostButton.Value = true; //This event never fires
}
}