}//end of saveEditUpdate on click method private void btnDelete_Click(object sender, EventArgs e) { if (btnDelete.Text == "Delete") { btnFind.Enabled = false; btnEdit.Enabled = false; bool OkayFlag; string productFields; dbFunctions.SelectProductFromProduct(Convert.ToInt32(txtProductUPC.Text), out OkayFlag, out productFields); //returns out variable values string[] productFieldArray = handleFieldOutput(productFields); //splits and trims productFields //Product p = thisProductList.getAnItem(Convert.ToInt32(txtProductUPC.Text));// product to be found //sets textboxes to proper values in product field array txtProductPrice.Text = productFieldArray[1]; txtProductUPC.Text = productFieldArray[0]; txtProductQuantity.Text = productFieldArray[3]; txtProductTitle.Text = productFieldArray[2]; if (productFieldArray[4] == "CDChamber")//handles cd chamber { FormController.activateCDChamber(this); FormController.deactivateAllButCDChamber(this); FormController.deactivateAddButtons(this); txtCDClassicalLabel.Text = productFieldArray[5]; txtCDClassicalArtists.Text = productFieldArray[6]; txtCDChamberInstrumentList.Text = productFieldArray[7]; } else if (productFieldArray[4] == "CDOrchestra")//handles cd orchestra { FormController.activateCDOrchestra(this); FormController.deactivateAllButCDOrchestra(this); txtCDClassicalLabel.Text = productFieldArray[5]; txtCDClassicalArtists.Text = productFieldArray[6]; txtCDOrchestraConductor.Text = productFieldArray[7]; } else if (productFieldArray[4] == "Book")//handles book { FormController.activateBook(this); FormController.deactivateAllButBook(this); FormController.deactivateAddButtons(this); string leftISBN = ""; string rightISBN = ""; for (int j = 0; j < productFieldArray[5].Length; j++)//seperates ISBN for 2 seperate textboxes { if (leftISBN.Length != 3) { leftISBN += productFieldArray[5][j]; } else { rightISBN += productFieldArray[5][j]; } } txtBookISBNLeft.Text = leftISBN; txtBookISBNRight.Text = rightISBN; txtBookAuthor.Text = productFieldArray[6]; txtBookPages.Text = productFieldArray[7]; } else if (productFieldArray[4] == "BookCIS")//handles book cis { FormController.activateBookCIS(this); FormController.deactivateAllButBookCIS(this); string leftISBN = ""; string rightISBN = ""; for (int j = 0; j < productFieldArray[5].Length; j++)//seperates ISBN for 2 seperate textboxes { if (leftISBN.Length != 3) { leftISBN += productFieldArray[5][j]; } else { rightISBN += productFieldArray[5][j]; } } txtBookISBNLeft.Text = leftISBN; txtBookISBNRight.Text = rightISBN; txtBookAuthor.Text = productFieldArray[6]; txtBookPages.Text = productFieldArray[7]; txtBookCISCISArea.Text = productFieldArray[8]; } // end multiple alternative if else if (productFieldArray[4] == "DVD")//handles dvd { FormController.activateDVD(this); FormController.deactivateAllButDVD(this); txtDVDLeadActor.Text = productFieldArray[5]; txtDVDReleaseDate.Text = productFieldArray[6]; txtDVDRunTime.Text = productFieldArray[7]; } else { MessageBox.Show("Fatal error. Data type not Book, BookCIS, DVD, DC Chamber or CD Orchestra. Program Terminated. ", "Mis-typed Object", MessageBoxButtons.OK); this.Close(); } // end multiple alternative if FormController.disableTextBoxes(this);//make sure user cannot change info during delete MessageBox.Show("Are you sure you want to delete this product? Confirm delete action below."); btnDelete.Text = "Confirm Delete"; } else//confirm { //Product p = thisProductList.getAnItem(Convert.ToInt32(txtProductUPC.Text));// product to be deleted //thisProductList.removeAnItem(p); dbFunctions.Delete(Convert.ToInt32(txtProductUPC.Text)); btnDelete.Enabled = false; MessageBox.Show("Product Deleted"); } }//end of delete click method