private void ChangeToFlowerProfileBtn_Click(object sender, EventArgs e)
        {
            Database_Manager DBMngrInstance = new Database_Manager();

            new flowerProfile(DBMngrInstance.FetchEnglish(copyOfFlowerId), DBMngrInstance.FetchLatin(copyOfFlowerId), DBMngrInstance.FetchBotan(copyOfFlowerId), DBMngrInstance.FetchNote(copyOfFlowerId), DBMngrInstance.FetchFilePath(copyOfFlowerId), copyOfFlowerId, userAcctType).Show();
            this.Hide();
        }
        // member functions


        // This version of verifyFlower() will verify that the flower entry
        // passed as an argument does not exist within the database, rather than
        // comparing with the contents of a pseudo-database, or a dummy Flower instantiation,
        // like what was done for Iteration I.
        public string verifyFlower(string userEnteredEnglish, string userEnteredLatin, string userEnteredBotan, string userEnteredNote, string userEnteredImgPath)
        {
            string           msgToDisplay;
            Database_Manager DBMngr = new Database_Manager();

            // need to be able to get the flower entry from the database
            // which matches the id of 'customFlower'


            // if a change is made to the english name AND that change does not result in it being blank
            if ((userEnteredEnglish != DBMngr.FetchEnglish(flowerId)) && (userEnteredEnglish != ""))
            {
                DBMngr.changeEnglishName(userEnteredEnglish, flowerId);
                msgToDisplay = "Changes successfully saved!";
            }
            else
            {
                msgToDisplay = "Changes unable to be saved: One of the three minimum attributes is missing.";
            }
            // same structure for latin name and botanical family
            if ((userEnteredLatin != DBMngr.FetchLatin(flowerId)) && (userEnteredLatin != ""))
            {
                DBMngr.changeLatinName(userEnteredLatin, flowerId);
                msgToDisplay = "Changes successfully saved!";
            }
            else
            {
                msgToDisplay = "Changes unable to be saved: One of the three minimum attributes is missing.";
            }
            if ((userEnteredBotan != DBMngr.FetchBotan(flowerId)) && (userEnteredBotan != ""))
            {
                DBMngr.changeBotanicalFam(userEnteredBotan, flowerId);
                msgToDisplay = "Changes successfully saved!";
            }
            else
            {
                msgToDisplay = "Changes unable to be saved: One of the three minimum attributes is missing.";
            }


            if (userEnteredNote != DBMngr.FetchNote(flowerId) && userEnteredNote != "")
            {
                DBMngr.changeNote(userEnteredNote, flowerId);
                msgToDisplay = "Changes successfully saved!";
            }

            if (userEnteredImgPath != DBMngr.FetchFilePath(flowerId) && userEnteredImgPath != "")
            {
                userEnteredImgPath = ChangeFilePath(userEnteredImgPath);
                DBMngr.changeImgPath(userEnteredImgPath, flowerId);
                msgToDisplay = "Changes successfully saved!";
            }


            return(msgToDisplay);
        }
예제 #3
0
        private void FetchNames(int[] id, ref bool res1, ref bool res2, ref bool res3)
        {
            ////////////////////////////////////////////////////////
            string query = "SELECT English, Latin, Botanical FROM Flower WHERE id = " + id[0];

            try
            {
                Database_Manager db = new Database_Manager();
                if (id[0] != 0)
                {
                    res1 = true;
                    flowers[0].setEnglishName(db.FetchEnglish(id[0]));
                    flowers[0].setLatinName(db.FetchLatin(id[0]));
                    flowers[0].setBotanicalFam(db.FetchBotan(id[0]));
                    if (id[1] != 0)
                    {
                        res2 = true;
                        flowers[1].setEnglishName(db.FetchEnglish(id[1]));
                        flowers[1].setLatinName(db.FetchLatin(id[1]));
                        flowers[1].setBotanicalFam(db.FetchBotan(id[1]));
                        if (id[2] != 0)
                        {
                            res3 = true;
                            flowers[2].setEnglishName(db.FetchEnglish(id[2]));
                            flowers[2].setLatinName(db.FetchLatin(id[2]));
                            flowers[2].setBotanicalFam(db.FetchBotan(id[2]));
                        }
                    }
                }

                //TODO
                //When database is implemented this method will pull name, botanical, and latin for each result
                //from the database and put it in each flower object
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
                throw;
            }
        }