Here is the example I created to see if I could get it to work. You enter the job#, and hit tab. It will then load all assemblies. You check the box next to the ones you want to add an FAI quantity to, and it will add an FAI qty of 1 to each operation with in that assembly.
This is my code below for the above form. You would have to create the form (Or use the code I provided as a guideline). In order to get this to work, you will have to load the jobentry adapter. you do this by going to tools>Assembly Reference Manager>Add Custom Reference then change the file type to all, and select “Erp.Adapters.JobEntry”,“Erp.Contracts.BO.JobEntry”,“ERP.UI.JobEntry”
I hope this helps. I know it is not as ideal as handing you a txt file, but, if you learn how to do this, and what it means, you can create a whole lot of customizations!
// Custom code for MainController
// Created: 5/24/2017 7:59:25 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Erp.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiTextBoxC2.AfterExitEditMode += new System.EventHandler(this.epiTextBoxC2_AfterExitEditMode);
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiTextBoxC2.AfterExitEditMode -= new System.EventHandler(this.epiTextBoxC2_AfterExitEditMode);
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
//This is what updates the assemblies after the job# is entered into the text box.
private void epiTextBoxC2_AfterExitEditMode(object sender, System.EventArgs args)
{
try
{
//Calls the job entry adapter
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();
//This is using the Job# entered in the textbox as a reference to find the record.
adapterJobEntry.GetByID(this.epiTextBoxC2.Text);
//This is creating a view based off of the record that we found above.
EpiDataView edvPA = new EpiDataView();
edvPA.dataView = new DataView(adapterJobEntry.JobEntryData.JobAsmbl);
//This is initiating the variable for the loop that takes place below.
int i = 0;
//This is finding out how many assemblies there are attached to the job that we entered.
int x = adapterJobEntry.JobEntryData.JobAsmbl.Rows.Count;
//This is enabling, or disabling the check boxes based off of how many assemblies there are for the job.
if (x < 1)
{
this.epiTextBox1.Text = "";
this.epiCheckBoxC1.Enabled = false;
this.epiCheckBoxC1.Checked = false;
MessageBox.Show("This Job does not have any assemblies, please add a method of manufacturing before using this feature.");
}
else
{
this.epiTextBox1.Text = "";
this.epiCheckBoxC1.Enabled = true;
this.epiCheckBoxC1.Checked = false;
}
if (x < 2)
{
this.epiTextBox2.Text = "";
this.epiCheckBox1.Enabled = false;
this.epiCheckBox1.Checked = false;
}
else
{
this.epiTextBox2.Text = "";
this.epiCheckBox1.Enabled = true;
this.epiCheckBox1.Checked = false;
}
if (x < 3)
{
this.epiTextBox3.Text = "";
this.epiCheckBox2.Enabled = false;
this.epiCheckBox2.Checked = false;
}
else
{
this.epiTextBox3.Text = "";
this.epiCheckBox2.Enabled = true;
this.epiCheckBox2.Checked = false;
}
if (x < 4)
{
this.epiTextBox4.Text = "";
this.epiCheckBox4.Enabled = false;
this.epiCheckBox4.Checked = false;
}
else
{
this.epiTextBox4.Text = "";
this.epiCheckBox4.Enabled = true;
this.epiCheckBox4.Checked = false;
}
if (x < 5)
{
this.epiTextBox5.Text = "";
this.epiCheckBox6.Enabled = false;
this.epiCheckBox6.Checked = false;
}
else
{
this.epiTextBox5.Text = "";
this.epiCheckBox6.Enabled = true;
this.epiCheckBox6.Checked = false;
}
if (x < 6)
{
this.epiTextBox6.Text = "";
this.epiCheckBox8.Enabled = false;
this.epiCheckBox8.Checked = false;
}
else
{
this.epiTextBox6.Text = "";
this.epiCheckBox8.Enabled = true;
this.epiCheckBox8.Checked = false;
}
if (x < 7)
{
this.epiTextBox7.Text = "";
this.epiCheckBox10.Enabled = false;
this.epiCheckBox10.Checked = false;
}
else
{
this.epiTextBox7.Text = "";
this.epiCheckBox10.Enabled = true;
this.epiCheckBox10.Checked = false;
}
if (x < 8)
{
this.epiTextBox8.Text = "";
this.epiCheckBox12.Enabled = false;
this.epiCheckBox12.Checked = false;
}
else
{
this.epiTextBox8.Text = "";
this.epiCheckBox12.Enabled = true;
this.epiCheckBox12.Checked = false;
}
//This loop is what fills in the text boxes with the assembly data.
while (i < x)
{
//This pulls in the assembly and the part# for the currently selected row of data.
string asm = Convert.ToString(edvPA.dataView[edvPA.Row+i]["AssemblySeq"]);
string part = Convert.ToString(edvPA.dataView[edvPA.Row+i]["PartNum"]);
//These fill the textboxes with the data.
if (i == 0)
{
this.epiTextBox1.Text = asm + "-" + part;
}
else if (i==1)
{
this.epiTextBox2.Text = asm + "-" + part;
}
else if (i==2)
{
this.epiTextBox3.Text = asm + "-" + part;
}
else if (i==3)
{
this.epiTextBox4.Text = asm + "-" + part;
}
if (i==4)
{
this.epiTextBox5.Text = asm + "-" + part;
}
else if (i==5)
{
this.epiTextBox6.Text = asm + "-" + part;
}
else if (i==6)
{
this.epiTextBox7.Text = asm + "-" + part;
}
else if (i==7)
{
this.epiTextBox8.Text = asm + "-" + part;
}
i = i+1;
}
adapterJobEntry.Dispose();
//Error Handling
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
//This is what sets up the form so that everything is empty when it is loaded.
private void MainController_Load(object sender, EventArgs args)
{
this.epiCheckBoxC1.Checked = false;
this.epiCheckBox1.Checked = false;
this.epiCheckBox2.Checked = false;
this.epiCheckBox4.Checked = false;
this.epiCheckBox6.Checked = false;
this.epiCheckBox8.Checked = false;
this.epiCheckBox10.Checked = false;
this.epiCheckBox12.Checked = false;
this.epiTextBox1.Text = "";
this.epiTextBox2.Text = "";
this.epiTextBox3.Text = "";
this.epiTextBox4.Text = "";
this.epiTextBox5.Text = "";
this.epiTextBox6.Text = "";
this.epiTextBox7.Text = "";
this.epiTextBox8.Text = "";
this.epiTextBox1.Value = "";
this.epiTextBox2.Value = "";
this.epiTextBox3.Value = "";
this.epiTextBox4.Value = "";
this.epiTextBox5.Value = "";
this.epiTextBox6.Value = "";
this.epiTextBox7.Value = "";
this.epiTextBox8.Value = "";
this.epiCheckBoxC1.Enabled = false;
this.epiCheckBox1.Enabled = false;
this.epiCheckBox2.Enabled = false;
this.epiCheckBox4.Enabled = false;
this.epiCheckBox6.Enabled = false;
this.epiCheckBox8.Enabled = false;
this.epiCheckBox10.Enabled = false;
this.epiCheckBox12.Enabled = false;
this.epiTextBox1.ReadOnly = true;
this.epiTextBox2.ReadOnly = true;
this.epiTextBox3.ReadOnly = true;
this.epiTextBox4.ReadOnly = true;
this.epiTextBox5.ReadOnly = true;
this.epiTextBox6.ReadOnly = true;
this.epiTextBox7.ReadOnly = true;
this.epiTextBox8.ReadOnly = true;
this.epiTextBoxC2.Text = "";
this.epiTextBoxC2.Value = "";
}
//This is the code for the button
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
try
{
//This checks to see if a Job has been entered, if not, it will give an error.
if (this.epiTextBoxC2.Text == "")
{
MessageBox.Show("Please enter a Job#.");
return;
}
//This checks to see if any of the check boxes are checked true when the button is clicked. If not, it will give an error.
if (this.epiCheckBoxC1.Checked)
{
}
else
{
if (this.epiCheckBox1.Checked)
{
}
else
{
if (this.epiCheckBox2.Checked)
{
}
else
{
if (this.epiCheckBox4.Checked)
{
}
else
{
if (this.epiCheckBox6.Checked)
{
}
else
{
if (this.epiCheckBox8.Checked)
{
}
else
{
if (this.epiCheckBox10.Checked)
{
}
else
{
if (this.epiCheckBox12.Checked)
{
}
else
{
MessageBox.Show("Please select an assembly to add FAI Quantities to.");
return;
}
}
}
}
}
}
}
}
//Loads the jobentry adapter
JobEntryAdapter adapterJobEntry = new JobEntryAdapter(this.oTrans);
adapterJobEntry.BOConnect();
//Finds our record based off of the job# we entered
adapterJobEntry.GetByID(this.epiTextBoxC2.Text);
//Initializes our variables
string[] separators = {"-"};
int x;
int i;
//This runs through every checkbox, if it is checked, then it will add an FAI qty to the operation.
if (this.epiCheckBoxC1.Checked)
{
//Finds the assembly that is currently selected
string text = this.epiTextBox1.Text;
string[] asm1text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm1 = asm1text[0];
//loads in the operations for the current assembly
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm1), Convert.ToInt32(asm1), true);
EpiDataView edvPA1 = new EpiDataView();
edvPA1.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
//counts how many operations there are for the current assembly
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
//Loops through all operations and changes the fai quantity to 1.
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox1.Checked)
{
string text = this.epiTextBox2.Text;
string[] asm2text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm2 = asm2text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm2), Convert.ToInt32(asm2), true);
EpiDataView edvPA2 = new EpiDataView();
edvPA2.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox2.Checked)
{
string text = this.epiTextBox3.Text;
string[] asm3text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm3 = asm3text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm3), Convert.ToInt32(asm3), true);
EpiDataView edvPA3 = new EpiDataView();
edvPA3.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox4.Checked)
{
string text = this.epiTextBox4.Text;
string[] asm4text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm4 = asm4text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm4), Convert.ToInt32(asm4), true);
EpiDataView edvPA4 = new EpiDataView();
edvPA4.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox6.Checked)
{
string text = this.epiTextBox5.Text;
string[] asm5text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm5 = asm5text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm5), Convert.ToInt32(asm5), true);
EpiDataView edvPA5 = new EpiDataView();
edvPA5.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox8.Checked)
{
string text = this.epiTextBox6.Text;
string[] asm6text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm6 = asm6text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm6), Convert.ToInt32(asm6), true);
EpiDataView edvPA6 = new EpiDataView();
edvPA6.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox10.Checked)
{
string text = this.epiTextBox7.Text;
string[] asm7text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm7 = asm7text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm7), Convert.ToInt32(asm7), true);
EpiDataView edvPA7 = new EpiDataView();
edvPA7.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
if (this.epiCheckBox12.Checked)
{
string text = this.epiTextBox8.Text;
string[] asm8text = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);
string asm8 = asm8text[0];
adapterJobEntry.GetDatasetForTree(this.epiTextBoxC2.Text, Convert.ToInt32(asm8), Convert.ToInt32(asm8), true);
EpiDataView edvPA8 = new EpiDataView();
edvPA8.dataView = new DataView(adapterJobEntry.JobEntryData.JobOper);
i = 0;
x = adapterJobEntry.JobEntryData.JobOper.Rows.Count;
while (i<x)
{
DataRow editRow = adapterJobEntry.JobEntryData.JobOper.Rows[i];
editRow.BeginEdit();
editRow["FAQty"] = 1;
editRow.EndEdit();
adapterJobEntry.Update();
i=i+1;
}
}
//Tells you it has been completed, and it clears the form
MessageBox.Show("FAI Quantities have been added!");
load();
} catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}
private void load()
{
this.epiCheckBoxC1.Checked = false;
this.epiCheckBox1.Checked = false;
this.epiCheckBox2.Checked = false;
this.epiCheckBox4.Checked = false;
this.epiCheckBox6.Checked = false;
this.epiCheckBox8.Checked = false;
this.epiCheckBox10.Checked = false;
this.epiCheckBox12.Checked = false;
this.epiTextBox1.Text = "";
this.epiTextBox2.Text = "";
this.epiTextBox3.Text = "";
this.epiTextBox4.Text = "";
this.epiTextBox5.Text = "";
this.epiTextBox6.Text = "";
this.epiTextBox7.Text = "";
this.epiTextBox8.Text = "";
this.epiTextBox1.Value = "";
this.epiTextBox2.Value = "";
this.epiTextBox3.Value = "";
this.epiTextBox4.Value = "";
this.epiTextBox5.Value = "";
this.epiTextBox6.Value = "";
this.epiTextBox7.Value = "";
this.epiTextBox8.Value = "";
this.epiCheckBoxC1.Enabled = false;
this.epiCheckBox1.Enabled = false;
this.epiCheckBox2.Enabled = false;
this.epiCheckBox4.Enabled = false;
this.epiCheckBox6.Enabled = false;
this.epiCheckBox8.Enabled = false;
this.epiCheckBox10.Enabled = false;
this.epiCheckBox12.Enabled = false;
this.epiTextBox1.ReadOnly = true;
this.epiTextBox2.ReadOnly = true;
this.epiTextBox3.ReadOnly = true;
this.epiTextBox4.ReadOnly = true;
this.epiTextBox5.ReadOnly = true;
this.epiTextBox6.ReadOnly = true;
this.epiTextBox7.ReadOnly = true;
this.epiTextBox8.ReadOnly = true;
this.epiTextBoxC2.Text = "";
this.epiTextBoxC2.Value = "";
}
}