private void FetchImages(int[] id) { //FOR TESTING ONLY// images1 = new string[3]; //images1[0] = images1[1] = images1[2] = "flower.jpg"; //FOR TESTING ONLY// try { //TODO //first the number of images for each flower must be gotten from the database //then the arrays for the images of each flower must be initialized. } catch (Exception) { throw; } try { Database_Manager db = new Database_Manager(); //TODO //Next all 3 arrays must be populated with filepaths from the database. //for (int i = 0; i < 3; i++) //{ // images1[i] = db.FetchFilePath(id[i]); //} if (id[0] != 0) { images1[0] = db.FetchFilePath(id[0]); if (id[1] != 0) { images1[1] = db.FetchFilePath(id[1]); if (id[2] != 0) { images1[2] = db.FetchFilePath(id[2]); } } } } catch (Exception) { throw; } }
// 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); }
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(); }