UD110A Record Creation

I am trying to get a new UD110A Record. I have a new UD110 record and that is working correctly. However, when I try to create a new UD110A I get the following error:
image

I would appreciate if someone can look at the code and help me out. I used the Wizard to add the code.

private void CallUD110AdapterGetaNewUD110aMethod()
	{
		try
		{
			// Declare and Initialize EpiDataView Variables
			EpiDataView edvGS_PMS_110Update = ((EpiDataView)(this.oTrans.EpiDataViews["GS_PMS_110Update"]));

			// Check if valid EpiDataView Row(s) are selected
			if ((edvGS_PMS_110Update.Row < 0))
			{
				return;
			}

			// Declare and create an instance of the Adapter.
			UD110Adapter adapterUD110 = new UD110Adapter(this.oTrans);
			adapterUD110.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 parentKey1 = "PMOPERATIONS";
			string parentKey2 = tbTypeCode1.Value.ToString();
			string parentKey3 = tbFreqCode1.Value.ToString();
			string parentKey4 = tbEquipTypeID.Text;
			string parentKey5 = string.Empty;
			string Key1 = "PMOPERATIONS";
			string Key2 = tbTypeCode1.Value.ToString();
			string Key3 = tbFreqCode1.Value.ToString();
			string Key4 = tbEquipTypeID.Text;
			string Key5 = string.Empty;
			string childKey1 = "OPERINSTRUCT";
			string childKey2 = tbInstNum1.Text;
			string childKey3 = string.Empty;
			string childKey4 = string.Empty;
			string childKey5 = string.Empty;
			// Call Adapter method
			bool result = adapterUD110.GetaNewUD110a(parentKey1, parentKey2, parentKey3, parentKey4, parentKey5);
			adapterUD110.UD110Data.UD110A[0].ChildKey1 = childKey1;
			adapterUD110.UD110Data.UD110A[0].ChildKey2 = childKey2;
	    	adapterUD110.UD110Data.UD110A[0].ChildKey3 = childKey3;
			adapterUD110.UD110Data.UD110A[0].Character01 = tbPMSpecialTools1.Text;
			adapterUD110.UD110Data.UD110A[0].Character02 = tbPMInstruction1.Text;
			adapterUD110.UD110Data.UD110A[0].CheckBox01 = epiCheckBox1.Checked;
			// Cleanup Adapter Reference
			adapterUD110.Update();
			adapterUD110.Dispose();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

This is my UD110 code that is working and creating a new record:

	{
		try
		{
			string Key1 = "PMOPERATIONS";
			string Key2 = tbTypeCode1.Value.ToString();
			string Key3 = tbFreqCode1.Value.ToString();
			string Key4 = tbEquipTypeID.Text;
			string Key5 = string.Empty;
			string childKey1 = "OPERINSTRUCT";
			string childKey2 = tbInstNum1.Text;
			string childKey3 = string.Empty;
			string childKey4 = string.Empty;
			string childKey5 = string.Empty;
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			UD110Adapter adapterUD110 = new UD110Adapter(this.oTrans);
			adapterUD110.BOConnect();
			
			
			// Call Adapter method
			bool result = adapterUD110.GetaNewUD110();
			adapterUD110.UD110Data.UD110[0].Key1 = Key1;
			adapterUD110.UD110Data.UD110[0].Key2 = Key2;
			adapterUD110.UD110Data.UD110[0].Key3 = Key3;
	    	adapterUD110.UD110Data.UD110[0].Key4 = Key4;
			adapterUD110.UD110Data.UD110[0].Key5 = Key5;
			adapterUD110.Update();
			// Cleanup Adapter Reference
			adapterUD110.Dispose();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

This is how I create UD100A records

private void AllocatePart(string sn, string part, int QuoteNum, int QuoteLine, int CustNum, string partType)
	{		
		UD100Adapter UDAdapter = new UD100Adapter(oTrans);
		UDAdapter.BOConnect();		
		try
		{
			if (UDAdapter.GetByID(sn,part, "", "",""))
			{
				DataRow dr = UDAdapter.UD100Data.UD100.Rows[0]; 
					dr.BeginEdit(); 
					dr["Checkbox01"] = true;
					dr["ShortChar04"] = QuoteNum.ToString();
					dr["Number20"] = QuoteLine;
					dr["RowMod"] = "U";
					dr.EndEdit(); 
				bool resultUpdate = UDAdapter.Update(); 
				bool _100A = UDAdapter.GetaNewUD100a(sn, part, "", "", "");
				int rc = UDAdapter.UD100Data.UD100A.Rows.Count -1;
				DataRow drA = UDAdapter.UD100Data.UD100A.Rows[rc];
				drA.BeginEdit();
					drA["ChildKey1"] = DateTime.Now.ToString();
					drA["ChildKey2"] = QuoteNum.ToString();
					drA["Character01"] = "Allocated";
					drA["Number01"] = CustNum;
				drA.EndEdit();
				resultUpdate = UDAdapter.Update(); 
				MessageBox.Show("Allocating Graft ID#: " + dr["Key1"].ToString());
				UDAdapter.Dispose();

				//send the allocation email			
				try
				{
					SendAllocationEmail(QuoteNum, sn, part, partType);
				}
				catch(Exception ex)
				{	
					MessageBox.Show("Allocation Email Error: " + ex.Message);
				}
				
				
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("Unable to allocate part: " + ex.Message);
		}
		MainController.Update();
		MainController.Refresh();
	}

Thank you Aaron! That worked. Here is my final working code.

private void CallUD110AdapterGetaNewUD110aMethod()
	{
		UD110Adapter adapterUD110 = new UD110Adapter(this.oTrans);
		adapterUD110.BOConnect();
		try
		{
			string parentKey1 = "PMOPERATIONS";
			string parentKey2 = tbTypeCode1.Value.ToString();
			string parentKey3 = tbFreqCode1.Value.ToString();
			string parentKey4 = tbEquipTypeID.Text;
			string parentKey5 = string.Empty;
			string Key1 = "PMOPERATIONS";
			string Key2 = tbTypeCode1.Value.ToString();
			string Key3 = tbFreqCode1.Value.ToString();
			string Key4 = tbEquipTypeID.Text;
			string Key5 = string.Empty;
			string childKey1 = "OPERINSTRUCT";
			string childKey2 = tbInstNum1.Text;
			string childKey3 = string.Empty;
			string childKey4 = string.Empty;
			string childKey5 = string.Empty;
			if (adapterUD110.GetByID(Key1, Key2, Key3, Key4, Key5))
			{
			// Call Adapter method
			bool _110A = adapterUD110.GetaNewUD110a(parentKey1, parentKey2, parentKey3, parentKey4, parentKey5);
			int rc = adapterUD110.UD110Data.UD110A.Rows.Count -1;
			DataRow drA = adapterUD110.UD110Data.UD110A.Rows[rc];
			drA.BeginEdit();
			drA["ChildKey1"] = childKey1;
			drA["ChildKey2"] = childKey2;
	    	drA["ChildKey3"] = childKey3;
			drA["Character01"] = tbPMSpecialTools1.Text;
			drA["Character02"] = tbPMInstruction1.Text;
			drA["CheckBox01"] = epiCheckBox1.Checked;
			drA.EndEdit();
			adapterUD110.Update();
			adapterUD110.Dispose();
}
		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}

	}

1 Like