protected void btnSubmit_Click(object sender, EventArgs e) { //Inspection is technically already created. The only data that needs to be added //iS the finish date and the hazard items string messageBoxText = "Are you sure you want to insert this corrective action?"; string caption = "Corrective Action Warning"; MessageBoxButton button = MessageBoxButton.YesNoCancel; MessageBoxImage icon = MessageBoxImage.Warning; MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon); if (result == MessageBoxResult.Yes) { //Get the inspectionID int inspectionID = Convert.ToInt32(Request.QueryString["ID"]); //Create a new SQL connection SqlConnection conn = new SqlConnection(connectionString); //Create a new SQL command SqlCommand comm = conn.CreateCommand(); //Assign the query to the command comm.CommandText = "UPDATE Inspection SET StartDate=@startDate, isStarted=1 WHERE ID = " + inspectionID; //Assign the current date time to the query comm.Parameters.AddWithValue("@startDate", DateTime.Now); //Open the connection conn.Open(); //Execute the command comm.ExecuteNonQuery(); //Close the connection conn.Close(); //Gather data to create insert query for hazard item int labID = Convert.ToInt32(lblRoomID.Text); int technicianID = Convert.ToInt32(lblTechnicianID.Text); string hazard = ddlHazard.SelectedItem.Text; var splitValueHazard = hazard.Split('-'); int hazardID = Convert.ToInt16(splitValueHazard[0]); string area = ddlArea.SelectedItem.Text; var splitValueArea = area.Split('-'); int areaID = Convert.ToInt16(splitValueArea[0]); string hazardOther = txtHazardOther.Text; string areaOther = txtArea.Text; string hazardDesc = txtHazardDesc.Text; string actionDesc = txtActionDesc.Text; DateTime dueDate = calDueDate.SelectedDate; //Execute the public method for inserting a hazard to an inspection int rows = DataLookup.InsertAction(inspectionID, labID, technicianID, hazardID, areaID, hazardDesc, actionDesc, dueDate, hazardOther, areaOther); //Shows feedback based on the success of the transaction if (rows > 0) { MessageBox.Show("Hazard has been added to Inspection #" + inspectionID); } else { MessageBox.Show("Error. No changes have been made."); } //Reload the page so another corrective action can be added Response.Redirect("InspectionCreateStatic.aspx?ID=" + inspectionID); } if (result == MessageBoxResult.No | result == MessageBoxResult.Cancel) { MessageBox.Show("No Action Taken"); } }