Delete UD102A row from customization (Not deleting)

Hi there,

I have the code below in a quote entry customization. Similar routines that update the same record and add new records work okay.

I’m trying to delete a record from UD102A using the adapter and marking the RowMod to “D” and running the update.

The message boxes show me I’m hitting all the marks with the right record. It’s just not deleting the record.

Have an idea? Reckon the way I’m using the dataview might have something to do with it?

Thanks,

Joe

	private void btnDeleteAccessory_Click(object sender, System.EventArgs args)
	{
		if (grdAccessoryHead.Rows.Count >  0) 
		{
			getFSOrderAccessoryDetail(Convert.ToInt32(this.grdAccessoryHead.ActiveRow.Index)); // display first row detail
	
			if (MessageBox.Show("Confirm: Delete selected accessory?", "Delete Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
			{
				string headerExternalReferenceID = edvQuoteHed.CurrentDataRow["ExternalReferenceID_c"].ToString();

				UD102Adapter ud102Adapter = new UD102Adapter(oTrans);
				ud102Adapter.BOConnect();

				bool result = ud102Adapter.GetByID(headerExternalReferenceID,"","","","");

				if (result)
				{
					edvUD102A = new EpiDataView();

					edvUD102A.dataView = new DataView(ud102Adapter.UD102Data.UD102A);

					edvUD102A.dataView.RowFilter = "ChildKey1 = '" + "Accessories"  + "' or ChildKey1 = '" + "AccessoryNotes"  + "'";

					//MessageBox.Show("row filter " + edvUD102A.dataView.RowFilter);

					bool ud102AUpdated = false;

					if (edvUD102A.dataView.Count > 0)
					{
						for (int i = 0; i < edvUD102A.dataView.Count; i++)
						{
							if (edvUD102A.dataView[i]["ChildKey2"].ToString() == this.grdAccessoryHead.ActiveRow.Cells["UD102A_ChildKey2"].Value.ToString() && 
								edvUD102A.dataView[i]["ChildKey3"].ToString() == this.grdAccessoryHead.ActiveRow.Cells["UD102A_ChildKey3"].Value.ToString())
							{
								MessageBox.Show("deleting child key1 " + edvUD102A.dataView[i]["ChildKey1"].ToString() + " child key2 " + edvUD102A.dataView[i]["ChildKey2"].ToString() + " child key3 " + 
									edvUD102A.dataView[i]["ChildKey3"].ToString() + " code " + edvUD102A.dataView[i]["Code_c"].ToString());  // **hits here**

								edvUD102A.dataView[i]["RowMod"] = "D";

								ud102AUpdated = true;
							}
						}

						if (ud102AUpdated)
						{
							ud102Adapter.Update();

							MessageBox.Show("Deleted"); // **hits here**

							getFSOrderAccessory();
							dataBindFSOrderAccessory();
						}
					}
				}
			}
		}
	}

Try the following instead of RowMod = “D”

edvUD102A.dataView[i].Delete();
1 Like
edvUD102A.dataView[i].BeginEdit();
edvUD102A.dataView[i].RowMod = "D";
edvUD102A.dataView[i].EndEdit();

ud102Adapter.Update();

However, what about ud102Adapter.DeleteByID(...) ?

Jon,

I don’t see a way to delete only a child row in UD102A with a DeleteByID. It takes only the main Key1-Key5 values for UD102. Something I’m missing?

Thanks,

Joe

That did it!

Thanks,

Joe