private void ConfirmSectionTitleButton_Click(object sender, EventArgs e) { CreateTemplateSections cts = new CreateTemplateSections(); addToSection input = new addToSection(); input.getLatestTemplateID(); input.addSectionName(sectionTitleTextbox.Text); input.writeNameToDB(); Close(); cts.Show(); }
//A method that gets the lastest Template ID, which will be used as a foriegn key for the section table public void getTempTemplateID(string sqlQuery) { //Create SQL Command object. SqlCommand command = new SqlCommand(); addToSection getID = new addToSection(); command.CommandType = CommandType.Text; command.CommandText = sqlQuery; //Opens Connection to the Database. openConnection(); command.Connection = connectionToDB; //executes the sql statement and parses the template ID as a interger int ID = Convert.ToInt32(command.ExecuteScalar().ToString()); //calls the method to pass the ID variable to the secID from createTemplate getID.turn_to_ID(ID); //Closes the Database Connection. closeConnection(); }