Exemplo n.º 1
0
        private void addFlowerToDBBtn_Click(object sender, EventArgs e)
        {
            // grab the entered English name, Latin name, and botanical family from the text boxes
            string enteredEnglishName = englishNameEntryBox.Text;

            string enteredLatinName = latinNameEntryBox.Text;

            string enteredBotanicalFamily = botanicalFamEntryBox.Text;

            string enteredNote = noteEntryBox.Text;

            string enteredImgPath = imgPathView.Text;

            // instantiate a Flower object from the user entries
            Flower flowerToAdd = new Flower(enteredLatinName, enteredEnglishName, enteredBotanicalFamily, enteredNote, enteredImgPath);

            // checks the database for existence of a Flower object with the same attributes
            bool displayedMsg = AddFlowerCtlr.verifyFlower(flowerToAdd);

            //MessageBox.Show(displayedMsg);

            // reset the data in the textboxes
            englishNameEntryBox.Text  = "";
            latinNameEntryBox.Text    = "";
            botanicalFamEntryBox.Text = "";
            noteEntryBox.Text         = "";
            imgPathView.Text          = "";

            // flower entry will NOT be added in the GUI; will be added in verifyFlower() using an instantiation of the DBMngr class

            //testDB TDB = new testDB();
            //TDB.addIt(enteredEnglishName, enteredLatinName, enteredBotanicalFamily);
            //MessageBox.Show("Flower successfuly added!");
        }
Exemplo n.º 2
0
        private void AddFlowerSubmitButton_Click_1(object sender, EventArgs e)
        {
            // grab the entered English name, Latin name, and botanical family from the text boxes
            string enteredEnglishName     = EnglishNameTextbox.Text;
            string enteredLatinName       = LatinNameTextbox.Text;
            string enteredBotanicalFamily = BotanicalFamilyTextbox.Text;
            string enteredNote            = NotesTextbox.Text;
            string enteredImgPath         = AddFlowerPicFileExt;

            // instantiate a Flower object from the user entries
            Flower flowerToAdd = new Flower(enteredLatinName, enteredEnglishName, enteredBotanicalFamily, enteredNote, enteredImgPath);

            bool added = AddFlowerCtlr.verifyFlower(flowerToAdd);

            if (added)
            {
                MessageBox.Show("Flower added to the database!");
                EnglishNameTextbox.Text       = "";
                LatinNameTextbox.Text         = "";
                BotanicalFamilyTextbox.Text   = "";
                NotesTextbox.Text             = "";
                AddFlowerPicFileExt           = "";
                AddFlowerImageDisplay.Image   = null;
                AddFlowerSubmitButton.Enabled = false;
            }
            else
            {
                MessageBox.Show("Flower was not added, it might already be in the database.");
            }
        }