protected void btnSaveInterviewResult_Click(object sender, EventArgs e) { string js = ""; try { int iCrewID = GetCrewID(); int iUserID = GetSessionUserID(); int InterviewID = UDFLib.ConvertToInteger(Request.QueryString["ID"]); int InterviewerID = GetSessionUserID(); int QustionAnswered = 0; if (InterviewID > 0) { DataTable dt = new DataTable(); dt.Columns.Add("QID"); dt.Columns.Add("SelectedOptionID"); dt.Columns.Add("NotApplicable"); dt.Columns.Add("Remarks"); foreach (GridViewRow gvr in GridView_AssignedCriteria.Rows) { CheckBox chk = (CheckBox)gvr.FindControl("chkNA"); RadioButtonList rdoOptions = (RadioButtonList)gvr.FindControl("rdoOptions"); TextBox txtRemarks = (TextBox)gvr.FindControl("txtRemarks"); int QID = UDFLib.ConvertToInteger(GridView_AssignedCriteria.DataKeys[gvr.RowIndex].Value); int NotApplicable = -1; if (chk != null) { NotApplicable = chk.Checked == true ? 1 : 0; if (NotApplicable == 1) { QustionAnswered = 1; } } int SelectedOptionID = 0; if (rdoOptions != null) { if (rdoOptions.SelectedIndex != -1) { SelectedOptionID = UDFLib.ConvertToInteger(rdoOptions.SelectedValue.Split(',')[0]); QustionAnswered = 1; } } string Remarks = ""; if (txtRemarks != null) { Remarks = txtRemarks.Text; } DataRow dr = dt.NewRow(); dr["QID"] = QID; dr["SelectedOptionID"] = SelectedOptionID; dr["NotApplicable"] = NotApplicable; dr["Remarks"] = Remarks; dt.Rows.Add(dr); } if (QustionAnswered > 0) { string InterviewDate = UDFLib.ConvertToDate(Convert.ToString(txtInterviewDate.Text), UDFLib.GetDateFormat()).ToString(); int Ret = BLL_Crew_Interview.UPDATE_CrewInterviewResult(iCrewID, InterviewID, InterviewerID, InterviewDate, 0, "", "", "", "", iUserID, dt); js = "Briefing result updated"; btnSaveInterviewResult.Enabled = false; } else { js = "Answer atleast one question before saving briefing"; } } else { lblMessage.Text = "Please select the crew again to fill the interview result."; } } catch (Exception ex) { lblMessage.Text = ex.Message; } if (js.Length > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser3", "alert('" + js + "');", true); } }
protected void btnSaveInterviewResult_Click(object sender, EventArgs e) { string js = ""; int QustionAnswered = 0; try { foreach (GridViewRow gvr in GridView_AssignedCriteria.Rows) { QustionAnswered = 0; string TextAnswer = ""; CheckBox chk = (CheckBox)gvr.FindControl("chkNA"); RadioButtonList rdoOptions = (RadioButtonList)gvr.FindControl("rdoOptions"); int QID = UDFLib.ConvertToInteger(GridView_AssignedCriteria.DataKeys[gvr.RowIndex].Value); int NotApplicable = -1; if (chk != null) { NotApplicable = chk.Checked == true ? 1 : 0; if (NotApplicable == 1) { QustionAnswered = 1; } } string Remarks = ((TextBox)(gvr.FindControl("txtRemarks"))).Text; ((TextBox)(gvr.FindControl("txtRemarks"))).BackColor = System.Drawing.Color.White; TextBox txtAns = (TextBox)gvr.FindControl("txtAnswer"); if (txtAns != null) { TextAnswer = txtAns.Text; } int SelectedOptionID = 0; if (rdoOptions != null) { if (rdoOptions.SelectedIndex != -1) { SelectedOptionID = UDFLib.ConvertToInteger(rdoOptions.SelectedValue.Split(',')[0]); QustionAnswered = 1; } } if (QustionAnswered == 0 && TextAnswer.Length == 0 && Remarks.Length == 0) { js = "All interview questions are mandatory"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser3", "alert('" + js + "');", true); break; } else { QustionAnswered = 1; } } if (QustionAnswered == 1 && ValidateSaving() == true) { int iCrewID = GetCrewID(); int iUserID = GetSessionUserID(); int InterviewID = UDFLib.ConvertToInteger(Request.QueryString["ID"]); int InterviewerID = GetSessionUserID(); if (InterviewID > 0) { DataTable dt = new DataTable(); dt.Columns.Add("QID"); dt.Columns.Add("SelectedOptionID"); dt.Columns.Add("NotApplicable"); dt.Columns.Add("Remarks"); foreach (GridViewRow gvr in GridView_AssignedCriteria.Rows) { CheckBox chk = (CheckBox)gvr.FindControl("chkNA"); RadioButtonList rdoOptions = (RadioButtonList)gvr.FindControl("rdoOptions"); TextBox txtRemarks = (TextBox)gvr.FindControl("txtRemarks"); int QID = UDFLib.ConvertToInteger(GridView_AssignedCriteria.DataKeys[gvr.RowIndex].Value); int NotApplicable = -1; if (chk != null) { NotApplicable = chk.Checked == true ? 1 : 0; } int SelectedOptionID = 0; if (rdoOptions != null) { if (rdoOptions.SelectedIndex != -1) { SelectedOptionID = UDFLib.ConvertToInteger(rdoOptions.SelectedValue.Split(',')[0]); } } string Remarks = ""; if (txtRemarks != null) { Remarks = txtRemarks.Text; } DataRow dr = dt.NewRow(); dr["QID"] = QID; dr["SelectedOptionID"] = SelectedOptionID; dr["NotApplicable"] = NotApplicable; dr["Remarks"] = Remarks; dt.Rows.Add(dr); } int Ret = BLL_Crew_Interview.UPDATE_CrewInterviewResult(iCrewID, InterviewID, InterviewerID, UDFLib.ConvertToDefaultDt(txtInterviewDate.Text), int.Parse(ddlRank.SelectedValue), "", txtResultText.Text, rdoSelected.SelectedValue, "", iUserID, dt); if (lstVessels.Items[0].Selected == true) { for (var i = 1; i < lstVessels.Items.Count; i++) { objCrewBLL.INS_Crew_RecomendedVessels(iCrewID, InterviewID, int.Parse(lstVessels.Items[i].Value), iUserID); } } else { for (var i = 1; i < lstVessels.Items.Count; i++) { if (lstVessels.Items[i].Selected == true) { objCrewBLL.INS_Crew_RecomendedVessels(iCrewID, InterviewID, int.Parse(lstVessels.Items[i].Value), iUserID); } } } for (var j = 0; j < chkTradingArea.Items.Count; j++) { if (chkTradingArea.Items[j].Selected == true) { int ZoneID = UDFLib.ConvertToInteger(chkTradingArea.Items[j].Value); objCrewBLL.INS_Crew_RecomendedZones(iCrewID, InterviewID, ZoneID, iUserID); } } js = "Interview result updated"; btnSaveInterviewResult.Enabled = false; lnkEditSchedule.Visible = false; UpdatePanel4.Update(); } else { lblMessage.Text = "Please select the crew again to fill the interview result."; } } } catch (Exception ex) { lblMessage.Text = ex.Message; } if (js.Length > 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser3", "alert('" + js + "');", true); } }