We have a customization for Job Entry that requires adding an EpiButton that fires off the “Add Operation” function as if it were right-clicked from the tree menu.
I used the “Business Logic Method Call” customization wizard with the JobEntryAdapter and the GetNewJobOper method, passing the job number from the DataView (after the job has been created) and assembly seq value of 0 into the method, called by the button click event:
private void btnAddNewOp_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
CallJobEntryAdapterGetNewJobOperMethod();
}
private void CallJobEntryAdapterGetNewJobOperMethod()
{
try
{
// Declare and Initialize EpiDataView Variables
EpiDataView edvJobHead = ((EpiDataView)(this.oTrans.EpiDataViews["JobHead"]));
// Check if valid EpiDataView Row(s) are selected
if ((edvJobHead.Row < 0))
{
return;
}
// Declare and create an instance of the Adapter.
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();
// Declare and Initialize Variables
// TODO: You may need to replace the default initialization with valid values as required for the BL method call.
string jobNum = ((string)(edvJobHead.dataView[edvJobHead.Row]["JobNum"]));
int assemblySeq = 0;
// Call Adapter method
bool result = adapterJobEntry.GetNewJobOper(jobNum, assemblySeq);
// Cleanup Adapter Reference
adapterJobEntry.Dispose();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
But when I create a new job, add a part and product group, save, then hit the button, I get this error message:
The summary is : "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Table: JobOper
Company=‘DCS’ JobNum=‘500925’ AssemblySeq=‘0’ OprSeq=‘10’ SysRowID=‘00000000-0000-0000-0000-000000000000’: ForeignKeyConstraint AsmblOper requires the child key values (DCS, 500925, 0) to exist in the parent table."
What is this referring to? I’ve tried BPMs (pre and post) on the GetNewJobOper method to set those fields on the JobHead, JobOper, and JobAsmbl tables to no avail. What else should I do?