Пример #1
0
        }//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
Пример #2
0
        //Edit button - Checks to see what type of object is being edited.
        private void btnEditUpdate_Click(object sender, EventArgs e)
        {
            bool success;

            btnDelete.Enabled = false;
            btnSave.Enabled   = false;
            success           = findAnItem("Edit/Update");
            if (success)
            {
                btnSave.Enabled       = true;
                btnEditUpdate.Enabled = false;

                txtProductUPC.ReadOnly      = false;
                txtProductTitle.ReadOnly    = false;
                txtProductQuantity.ReadOnly = false;
                txtProductPrice.ReadOnly    = false;
                Product p = thisProductList.getAnItem(currentIndex);
                txtProductPrice.Text    = p.ProductPrice.ToString();
                txtProductUPC.Text      = p.ProductUPC.ToString();
                txtProductQuantity.Text = p.ProductQuantity.ToString();
                txtProductTitle.Text    = p.ProductTitle.ToString();
                MessageBox.Show("Edit/UPDATE current Product (as shown). Press Save Updates Button", "Edit/Update Notice",
                                MessageBoxButtons.OK);
                if (p.GetType() == typeof(CDChamber))
                {
                    FormController.activateCDChamber(this);
                    FormController.deactivateAllButCDChamber(this);
                    FormController.deactivateAddButtons(this);

                    txtCDClassicalArtists.ReadOnly      = false;
                    txtCDClassicalLabel.ReadOnly        = false;
                    txtCDChamberInstrumentList.ReadOnly = false;
                    txtCDClassicalLabel.Text            = ((CDClassical)p).CDClassicalLabel;
                    txtCDClassicalArtists.Text          = ((CDClassical)p).CDClassicalArtists;
                    txtCDChamberInstrumentList.Text     = ((CDChamber)p).getCDChamberInstrumentList();
                    recordsProcessedCount++;
                }
                else if (p.GetType() == typeof(CDOrchestra))
                {
                    FormController.activateCDOrchestra(this);
                    FormController.deactivateAllButCDOrchestra(this);

                    txtCDClassicalArtists.ReadOnly   = false;
                    txtCDClassicalLabel.ReadOnly     = false;
                    txtCDOrchestraConductor.ReadOnly = false;
                    txtCDClassicalLabel.Text         = ((CDClassical)p).CDClassicalLabel;
                    txtCDClassicalArtists.Text       = ((CDClassical)p).CDClassicalArtists;
                    txtCDOrchestraConductor.Text     = ((CDOrchestra)p).getCDOrchestraConductor();
                    recordsProcessedCount++;
                }
                else if (p.GetType() == typeof(Book))
                {
                    FormController.activateBook(this);
                    FormController.deactivateAllButBook(this);
                    FormController.deactivateAddButtons(this);

                    txtBookISBNLeft.ReadOnly  = false;
                    txtBookISBNRight.ReadOnly = false;
                    txtBookAuthor.ReadOnly    = false;
                    txtBookPages.ReadOnly     = false;
                    txtBookISBNLeft.Text      = (((Book)p).BookISBNLeft).ToString();
                    txtBookISBNRight.Text     = (((Book)p).BookISBNRight).ToString();
                    txtBookAuthor.Text        = ((Book)p).BookAuthor;
                    txtBookPages.Text         = ((Book)p).BookPages.ToString();
                    recordsProcessedCount++;
                }
                else if (p.GetType() == typeof(BookCIS))
                {
                    FormController.activateBookCIS(this);
                    FormController.deactivateAllButBookCIS(this);

                    txtBookISBNLeft.ReadOnly   = false;
                    txtBookISBNRight.ReadOnly  = false;
                    txtBookAuthor.ReadOnly     = false;
                    txtBookPages.ReadOnly      = false;
                    txtBookCISCISArea.ReadOnly = false;
                    txtBookISBNLeft.Text       = (((Book)p).BookISBNLeft).ToString();
                    txtBookISBNRight.Text      = (((Book)p).BookISBNRight).ToString();
                    txtBookAuthor.Text         = ((Book)p).BookAuthor;
                    txtBookPages.Text          = (((Book)p).BookPages).ToString();
                    txtBookCISCISArea.Text     = ((BookCIS)p).BookCISCISArea;
                    recordsProcessedCount++;
                }  // end multiple alternative if

                else if (p.GetType() == typeof(DVD))
                {
                    FormController.activateDVD(this);
                    FormController.deactivateAllButDVD(this);

                    txtDVDLeadActor.ReadOnly   = false;
                    txtDVDReleaseDate.ReadOnly = false;
                    txtDVDRunTime.ReadOnly     = false;
                    txtDVDLeadActor.Text       = ((DVD)p).DVDLeadActor;
                    txtDVDReleaseDate.Text     = ((DateTime)((DVD)p).DVDReleaseDate).ToString("MM/dd/yyyy");
                    txtDVDRunTime.Text         = (((DVD)p).DVDRunTime).ToString();
                    recordsProcessedCount++;
                }
                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
            }     // end if on success
        }
Пример #3
0
        }//end display CD Orchestra

        private void btnEdit_Click(object sender, EventArgs e)
        {
            bool   OkayFlag;
            string productFields;

            btnFind.Enabled           = false;
            btnDelete.Enabled         = false;
            btnSaveEditUpdate.Enabled = false;

            dbFunctions.SelectProductFromProduct(Convert.ToInt32(txtProductUPC.Text), out OkayFlag, out productFields); //returns values to out parameters

            string[] productFieldArray = handleFieldOutput(productFields);                                              //splits and trims productFields

            if (OkayFlag)                                                                                               //if a product was found
            {
                btnSaveEditUpdate.Enabled = true;
                btnEdit.Enabled           = false;


                //setting textboxes to correct values in field array
                txtProductPrice.Text    = productFieldArray[1];
                txtProductUPC.Text      = productFieldArray[0];
                txtProductQuantity.Text = productFieldArray[3];
                txtProductTitle.Text    = productFieldArray[2];
                MessageBox.Show("Edit/UPDATE current Product (as shown). Press Save Updates Button", "Edit/Update Notice",
                                MessageBoxButtons.OK);
                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
            }     // end if on success
        }         //end of edit on click method