//Gets the option ID of the user chosen template public void getEditOptionId(string sqlQuery, int SID) { //Create SQL Command object. SqlCommand command = new SqlCommand(); editTemplate getID = new editTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; //adds the sectionID to the command parameters command.Parameters.AddWithValue("@temporarySectEditId", SID); openConnection(); command.Connection = connectionToDB; /*Performs a command that reads the database and finds rows that fits the condition of the sql statement * the execution of the command itself will be used to find and add the optin ID's to the opID list*/ using (SqlDataReader reader = command.ExecuteReader()) { /*the read command performs sequentially. When the row is found that fits the conditions of the sql statement, * add that optionID to the temporary list*/ while (reader.Read()) { optionOriginalEditID.Add(reader.GetInt32(0)); } } //Closes the Database Connection. closeConnection(); //Turns the opID list equal to the temporary list getID.turn_to_Edit_Option_ID(optionOriginalEditID); }
/* The next 6 methods are to get the ID's of a template that the user selected, * and then deletes the rows associatied with the ID's from bottom to top * (options -> section -> template)*/ //Gets the templateID of the template that the user wants to edit public void getEditTemplateID(string sqlQuery, string eName) { //Create SQL Command object. SqlCommand command = new SqlCommand(); editTemplate getID = new editTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; //adds the template name to the parameters. command.Parameters.AddWithValue("@templateEditName", eName); //Opens Connection to the Database. openConnection(); command.Connection = connectionToDB; //executes the sql statement. The sql statement will find the TempId based on the name association int ID = Convert.ToInt32(command.ExecuteScalar()); //calls the method to pass the ID variable to the tempID from the editTemplate getID.turn_to_Edit_ID(ID); //Closes the Database Connection. closeConnection(); }
private void Edit_button_Click(object sender, EventArgs e) { editTemplate edit = new editTemplate(); editMenu fillEdit = new editMenu(); edit.addEditTemplateName(cbCl.Text); edit.getLatestEditTemplateID(); edit.getLatestEditSectionID(); edit.getLastestEditOptionsID(); fillEdit.createTBEditTemplate(); fillEdit.fillEditTemplate(); fillEdit.fillEditSection(); fillEdit.fillEditOption(); fillEdit.fillEditOptionComment(); fillEdit.ShowDialog(); }