protected void btnSaveAuthorship_Click(object sender, EventArgs e) { List <pubid_ours> pubid_oursList = new List <pubid_ours>(); List <int> yesNoIdList = new List <int>(); for (int i = 0; i < gvPublication.Rows.Count; i++) { pubid_ours mp = new pubid_ours(); RadioButtonList ralist = gvPublication.Rows[i].FindControl("rblFinal") as RadioButtonList; if (ralist == null) { return; } if (ralist.SelectedIndex == -1) { continue; } mp.yesNoId = Convert.ToInt32(ralist.SelectedValue.ToString()); ErrorMessage.Text = ""; int id; Label lblIdTemp = null; lblIdTemp = (Label)gvPublication.Rows[i].FindControl("lblId"); if (lblIdTemp != null) { id = Convert.ToInt32(lblIdTemp.Text); } else { return; } mp.pubId = id; pubid_oursList.Add(mp); } foreach (pubid_ours mp in pubid_oursList) { SaveYesNoSelection(mp); } string msg = "Publication is updated."; //ErrorMessage.Text = msg; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + msg + "');", true); ErrorMessage.Text = "Final authorship is saved."; }
protected void SaveYesNoSelection(pubid_ours mp) { int publicationId = mp.pubId; int yesNoId = mp.yesNoId; string sqlStatement; if (yesNoId == 2) { string connectionStr = ConfigurationManager.ConnectionStrings["UcccPubMedDB"].ConnectionString; SqlConnection myConnection = new SqlConnection(connectionStr); ProcessPub.SaveRejectOnPubId(publicationId); sqlStatement = "delete from publication_processing where publication_id = @publication_id" + "; delete from publication_author where publication_id = @publication_id" + "; delete from publication_program where publication_id = @publication_id" + "; delete from publication_programmatic where publication_id = @publication_id" + "; delete from publication_pubtype where publication_id = @publication_id" + "; delete from publication_resource where publication_id = @publication_id" + "; delete from publication where publication_id = @publication_id" + "; delete from author where author_id not in (select author_id from publication_author)"; SqlCommand command = new SqlCommand(sqlStatement, myConnection); SqlParameter publication_idParameter = new SqlParameter(); publication_idParameter.ParameterName = "@publication_id"; publication_idParameter.SqlDbType = SqlDbType.Int; publication_idParameter.Value = publicationId; command.Parameters.Add(publication_idParameter); myConnection.Open(); command.ExecuteNonQuery(); myConnection.Close(); } else { sqlStatement = "Update publication_processing" + " SET final_confirm_id=@final_confirm_id" + " WHERE (publication_id = @publication_id)"; string connectionStr = ConfigurationManager.ConnectionStrings["UcccPubMedDB"].ConnectionString; SqlConnection myConnection = new SqlConnection(connectionStr); SqlCommand command = new SqlCommand(sqlStatement, myConnection); SqlParameter final_confirm_idParameter = new SqlParameter(); final_confirm_idParameter.ParameterName = "@final_confirm_id"; final_confirm_idParameter.SqlDbType = SqlDbType.Int; final_confirm_idParameter.Value = yesNoId; command.Parameters.Add(final_confirm_idParameter); SqlParameter publication_idParameter = new SqlParameter(); publication_idParameter.ParameterName = "@publication_id"; publication_idParameter.SqlDbType = SqlDbType.Int; publication_idParameter.Value = publicationId; command.Parameters.Add(publication_idParameter); myConnection.Open(); command.ExecuteNonQuery(); myConnection.Close(); } gvPublication.EditIndex = -1; FillPublicationGrid(); }