protected void btnSaveEvaluation_Click(object sender, EventArgs e) { try { int CrewID = UDFLib.ConvertToInteger(Request.QueryString["CrewID"].ToString()); //int CrewRank = UDFLib.ConvertToInteger(hdnCrewrank.Value); int EID = UDFLib.ConvertToInteger(Request.QueryString["EID"].ToString()); string DueDate = UDFLib.ConvertStringToNull(Request.QueryString["DueDate"]); if (!string.IsNullOrEmpty(DueDate)) { // DueDate = DueDate.ToString().Replace('-', '/'); } else if (txtEvaDate.Text != "") { DueDate = txtEvaDate.Text; } int Schedule_ID = 0; if (Request.QueryString["SchID"] != null) { Schedule_ID = UDFLib.ConvertToInteger(Request.QueryString["SchID"].ToString()); } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Criteria_ID", typeof(int))); dt.Columns.Add(new DataColumn("UserAnswer", typeof(int))); dt.Columns.Add(new DataColumn("TextAnswer", typeof(string))); dt.Columns.Add(new DataColumn("Remarks", typeof(string))); dt.Columns.Add(new DataColumn("NotApplicable", typeof(int))); int QustionAnswered = 0; foreach (GridViewRow row in GridView_AssignedCriteria.Rows) { QustionAnswered = 0; int UserAnswer = 0; string TextAnswer = ""; HiddenField hdnCriteria_ID = (HiddenField)row.FindControl("hdnCriteria_ID"); int Criteria_ID = UDFLib.ConvertToInteger(hdnCriteria_ID.Value); RadioButtonList rdoOptions = (RadioButtonList)row.FindControl("rdoOptions"); if (rdoOptions != null) { UserAnswer = UDFLib.ConvertToInteger(rdoOptions.SelectedValue); } string Remarks = ((TextBox)(row.FindControl("txtRemarks"))).Text; ((TextBox)(row.FindControl("txtRemarks"))).BackColor = System.Drawing.Color.White; TextBox txtAns = (TextBox)row.FindControl("txtAnswer"); if (txtAns != null) { TextAnswer = txtAns.Text; } CheckBox chkNA = (CheckBox)row.FindControl("chkNA"); if (chkNA.Checked == true) { UserAnswer = 0; TextAnswer = ""; } if (chkNA.Checked == true || UserAnswer > 0 || TextAnswer.Length > 0) { QustionAnswered = 1; } if (QustionAnswered == 0) { QustionAnswered = -1; break; } DataRow dr = dt.NewRow(); dr[0] = Criteria_ID; dr[1] = UserAnswer; dr[2] = TextAnswer; dr[3] = Remarks; dr[4] = (chkNA.Checked == true ? 1 : 0); dt.Rows.Add(dr); } string js = ""; if (QustionAnswered > 0) { int C_EID = BLL_Crew_Evaluation.INSERT_Crew_Evaluation(CrewID, EID, GetSessionUserID(), UDFLib.ConvertToDate(txtEvaDate.Text).ToShortDateString(), GetSessionUserID(), UDFLib.ConvertToDate(DueDate).ToShortDateString(), Schedule_ID); if (C_EID > 0) { BLL_Crew_Evaluation.INSERT_Crew_Evaluation_Answer(C_EID, dt, GetSessionUserID()); } js = "alert('Evaluation Saved');window.open('','_self','');window.close();"; btnSaveEvaluation.Enabled = false; } else if (QustionAnswered == -1) { js = "alert('All evalution question are mandatory');chkNA_Checked();"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "status", js, true); } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }