}//GoBtn //defined method. private void AddNewPublisher() { // Backend codes for AddNewAuthor Page Button. //Error Handling and Validation codes for the database. try { //connecting the AuthorManagement Page to the database. SqlConnection con = new SqlConnection(strcon); //checking if the AuthorManagement Page is connected to the database. if (con.State == ConnectionState.Closed) { con.Open(); }//if_con //Firing the SQl Query SqlCommand cmd = new SqlCommand("INSERT INTO tbl_publisher(publisher_id,publisher_name) values(@publisher_id,@publisher_name)", con); SqlParameter sqlParameterId = cmd.Parameters.AddWithValue("@publisher_id", PublisherID.Text.Trim()); SqlParameter sqlParameterName = cmd.Parameters.AddWithValue("@publisher_name", PublisherName.Text.Trim()); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('" + PublisherName.Text.Trim() + "' + ' Successfully added.' ); </script>"); ClearForm(); GridPublisher.DataBind(); }//try catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "'); </script>"); ClearForm(); } //catch } //AddNewAuthor
} //UpdateAuthor private void DeletePublisher() { // Backend codes for UpdateAuthor Page Button. //Error Handling and Validation codes for the database. try { //connecting the UpdateAuthor Page to the database. SqlConnection con = new SqlConnection(strcon); //checking if the UpdateAuthor Page is connected to the database. if (con.State == ConnectionState.Closed) { con.Open(); }//if_con //Firing the SQl Query SqlCommand cmd = new SqlCommand("DELETE from tbl_publisher WHERE publisher_id='" + PublisherID.Text.Trim() + "'", con); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('" + PublisherName.Text.Trim() + "' + ' is successfully deleted.' ); </script>"); ClearForm(); GridPublisher.DataBind(); }//try catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "'); </script>"); ClearForm(); } //catch } //DeleteAuthor
protected void Page_Load(object sender, EventArgs e) { //Databind code_Refresh. GridPublisher.DataBind(); }