protected void Update_Mark(object sender, EventArgs e) { SqlDataSourcePublication.UpdateCommand = "UPDATE MARK_PUBLICATION SET [mark]= @mark, [myra2] = @myra2, [type_authorship]=@typeAuthorship,[index]=@index, [status_paper]=@statusPaper, [affiliation_UTM]=@affiliationUTM WHERE id = @id"; SqlDataSourcePublication.UpdateParameters.Add("mark", null); SqlDataSourcePublication.UpdateParameters.Add("myra2", null); SqlDataSourcePublication.UpdateParameters.Add("id", null); SqlDataSourcePublication.UpdateParameters.Add("typeAuthorship", null); SqlDataSourcePublication.UpdateParameters.Add("index", null); SqlDataSourcePublication.UpdateParameters.Add("statusPaper", null); SqlDataSourcePublication.UpdateParameters.Add("affiliationUTM", null); foreach (GridViewRow row in GridView1.Rows) { //get updated marks TextBox mark = row.FindControl("tbMark") as TextBox; TextBox myra2 = row.FindControl("tbMyra2") as TextBox; DropDownList typeAuthorship = row.FindControl("ddlTypeAuthorship") as DropDownList; DropDownList index = row.FindControl("ddlIndex") as DropDownList; DropDownList statusPaper = row.FindControl("ddlStatusPaper") as DropDownList; DropDownList affiliationUTM = row.FindControl("ddlAffiliationUTM") as DropDownList; //get ID from row. int id = (int)GridView1.DataKeys[row.DataItemIndex]["id"]; //GridView1.DataKeys[e.Row.DataItemIndex]["App_No"].ToString().Trim(), GridView1.DataKeys[e.Row.DataItemIndex]["Short_Name"].ToString().Trim()) SqlDataSourcePublication.UpdateParameters["mark"].DefaultValue = mark.Text; SqlDataSourcePublication.UpdateParameters["myra2"].DefaultValue = myra2.Text; SqlDataSourcePublication.UpdateParameters["typeAuthorship"].DefaultValue = typeAuthorship.SelectedValue; SqlDataSourcePublication.UpdateParameters["index"].DefaultValue = index.SelectedValue; SqlDataSourcePublication.UpdateParameters["statusPaper"].DefaultValue = statusPaper.SelectedValue; SqlDataSourcePublication.UpdateParameters["affiliationUTM"].DefaultValue = affiliationUTM.Text; SqlDataSourcePublication.UpdateParameters["id"].DefaultValue = GridView1.DataKeys[row.DataItemIndex]["id"].ToString(); SqlDataSourcePublication.Update(); } ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "refreshParent()", true); }
protected void getData() { //Get matrix no and type from Http POST data appNo = Request.QueryString["appNo"]; String type = Request.QueryString["type"]; String appQuery = ""; if (type == "Zamalah") { //Creating several database queries mark table undecided appQuery = String.Format("SELECT * FROM [vw_zamalah] WHERE [App_No] = '{0}' ", appNo); } else if (type == "PNF") { //Creating several database queries mark table undecided appQuery = String.Format("SELECT * FROM [vw_PNF] WHERE [App_No] = '{0}' ", appNo); } //Creating data adapter for each query SqlDataAdapter appAdapter = new SqlDataAdapter(appQuery, con); //Add all query results into dataset with specific datatable name ds = new DataSet(); appAdapter.Fill(ds, "appInfo"); //Fill in student info from dataset dt = ds.Tables["appInfo"]; Decimal mark = 0; foreach (DataRow dr in dt.Rows) { if (type == "Zamalah") { //marks for zamalah //RU University / RU None UTM / None RU RU.Text = dr["RU"].ToString(); //proposal attached lampiran.Text = dr["attachment"].ToString(); //academic awards anugerahChancellor.Text = dr["chancellor"].ToString(); anugerahPChancellor.Text = dr["pro_chancellor"].ToString(); alumni.Text = dr["alumni"].ToString(); company.Text = dr["special_company"].ToString(); dean.Text = dr["dean"].ToString(); mark += Decimal.Parse(RU.Text); mark += Decimal.Parse(lampiran.Text); mark += Decimal.Parse(anugerahChancellor.Text); mark += Decimal.Parse(anugerahPChancellor.Text); mark += Decimal.Parse(alumni.Text); mark += Decimal.Parse(company.Text); mark += Decimal.Parse(dean.Text); } else if (type == "PNF") { //marks for PNF //master qualification either UTM or Other MQ.Text = dr["master_qualification"].ToString(); //Academic Awards aaAlumni.Text = dr["alumni"].ToString(); aaSpecialCompany.Text = dr["special_company"].ToString(); aaBestStudentSPS.Text = dr["best_student_sps"].ToString(); aaBestStudentFaculty.Text = dr["best_student_faculty"].ToString(); //Research Award raBestPaper.Text = dr["best_paper"].ToString(); raBestSpeaker.Text = dr["best_speaker"].ToString(); raResearch.Text = dr["research"].ToString(); raOthers.Text = dr["others"].ToString(); //Co-curricular acftivities coPresident.Text = dr["president"].ToString(); coPresidentLevel.Text = dr["president_level"].ToString(); coVicePresident.Text = dr["vice_president"].ToString(); coVicePresidentLevel.Text = dr["vice_president_level"].ToString(); coBursar.Text = dr["bursar"].ToString(); coBursarLevel.Text = dr["bursar_level"].ToString(); coSecretary.Text = dr["secretary"].ToString(); coSecretaryLevel.Text = dr["secretary_level"].ToString(); coCommittee.Text = dr["committee"].ToString(); coCommitteeLevel.Text = dr["committee_level"].ToString(); mark += Decimal.Parse(aaAlumni.Text); mark += Decimal.Parse(MQ.Text); mark += Decimal.Parse(aaSpecialCompany.Text); mark += Decimal.Parse(aaBestStudentSPS.Text); mark += Decimal.Parse(aaBestStudentFaculty.Text); mark += Decimal.Parse(raBestPaper.Text); mark += Decimal.Parse(raBestSpeaker.Text); mark += Decimal.Parse(raResearch.Text); mark += Decimal.Parse(raOthers.Text); mark += Decimal.Parse(coPresident.Text); mark += Decimal.Parse(coPresidentLevel.Text); mark += Decimal.Parse(coVicePresident.Text); mark += Decimal.Parse(coVicePresidentLevel.Text); mark += Decimal.Parse(coBursar.Text); mark += Decimal.Parse(coBursarLevel.Text); mark += Decimal.Parse(coSecretary.Text); mark += Decimal.Parse(coSecretaryLevel.Text); mark += Decimal.Parse(coCommittee.Text); mark += Decimal.Parse(coCommitteeLevel.Text); } //Calculate publication marks. //declare variable Decimal markJournal = 0; Decimal myra2Journal = 0; Decimal markConference = 0; Decimal myra2Conference = 0; Decimal markBook = 0; Decimal myra2Book = 0; Decimal markBookC = 0; Decimal myra2BookC = 0; Decimal totalMarkPub = 0; Decimal totalMyra2Pub = 0; //gets dataview selected by sqldatasourcepublication DataView publication = (DataView)SqlDataSourcePublication.Select(DataSourceSelectArguments.Empty); //loop through each row foreach (DataRowView drv in publication) { DataRow row = drv.Row; switch (row["type"].ToString()) { case "Conference": markConference += (Decimal)row["mark"]; myra2Conference += (Decimal)row["myra2"]; break; case "Journal": markJournal += (Decimal)row["mark"]; myra2Journal += (Decimal)row["myra2"]; break; case "Book": markBook += (Decimal)row["mark"]; myra2Book += (Decimal)row["myra2"]; break; case "Book Chapter": markBookC += (Decimal)row["mark"]; myra2BookC += (Decimal)row["myra2"]; break; } } //calculate total publication marks and overall marks totalMarkPub += markConference + markJournal + markBook + markBookC; totalMyra2Pub += myra2Conference + myra2Journal + myra2Book + myra2BookC; mark += totalMarkPub; //display in label //journal jurnalMarkSA.Text = markJournal.ToString(); jurnalMarkMY.Text = myra2Journal.ToString(); //conference persidanganMarkSA.Text = markConference.ToString(); persidanganMarkMY.Text = myra2Conference.ToString(); //books bukuMarkSA.Text = markBook.ToString(); bukuMarkMY.Text = myra2Book.ToString(); //book chapter bukuCMarkSA.Text = markBookC.ToString(); bukuCMarkMY.Text = myra2BookC.ToString(); //total publication mark totalMarkPubSA.Text = totalMarkPub.ToString(); totalMarkPubMY.Text = totalMyra2Pub.ToString(); //overall total mark overallMark.Text = mark.ToString(); overallMarkMY.Text = totalMyra2Pub.ToString(); } }