//Gets the option ID of the user chosen template public void getRemoveOptionId(string sqlQuery, int SID) { //Create SQL Command object. SqlCommand command = new SqlCommand(); removeTemplate getID = new removeTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; //adds the sectionID to the command parameters command.Parameters.AddWithValue("@temporarySectId", 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()) { optionOriginalID.Add(reader.GetInt32(0)); } } //Closes the Database Connection. closeConnection(); //Turns the opID list equal to the temporary list getID.turn_to_Remove_Option_ID(optionOriginalID); }
/* 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 removed public void getRemoveTemplateID(string sqlQuery, string Rname) { //Create SQL Command object. SqlCommand command = new SqlCommand(); removeTemplate getID = new removeTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; //adds the template name to the parameters. command.Parameters.AddWithValue("@templateRemoveName", Rname); //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 removeTemplate getID.turn_to_Remove_ID(ID); //Closes the Database Connection. closeConnection(); }
private void Remove_button_Click(object sender, EventArgs e) { removeTemplate remove = new removeTemplate(); removeTemplateWarning removeWarning = new removeTemplateWarning(); remove.addTemplateName(cbCl.Text); removeWarning.ShowDialog(); }
private void yesButton_Click(object sender, EventArgs e) { removeTemplate remove = new removeTemplate(); remove.getLatestRemoveTemplateID(); remove.getLatestRemoveSectionID(); remove.getLastestRemoveOptionsID(); remove.removeChosenTemplate(); this.Close(); }
private void yesButton_Click(object sender, EventArgs e) { TemplateSelector test = new TemplateSelector(); removeTemplate remove = new removeTemplate(); remove.getLatestRemoveTemplateID(); remove.getLatestRemoveSectionID(); remove.getLastestRemoveOptionsID(); remove.removeChosenTemplate(); this.Close(); //test.Visible = true; }
//Finally, this method will remove the template from the database public void removeTemplate(string sqlQuery, int TID) { SqlCommand command = new SqlCommand(); removeTemplate getID = new removeTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; command.Parameters.AddWithValue("@tempID", TID); openConnection(); command.Connection = connectionToDB; ////Execute the sql statement. This is where the template will be removed from database command.ExecuteNonQuery(); closeConnection(); }
//The method that removes the options from the databse public void removeOption(string sqlQuery, int OID) { ////Create SQL Command object. SqlCommand command = new SqlCommand(); removeTemplate getID = new removeTemplate(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; command.Parameters.AddWithValue("@optionElement", OID); openConnection(); command.Connection = connectionToDB; //Execute the sql statement. This is where the options will be removed from database command.ExecuteNonQuery(); closeConnection(); }