protected void BtnSave_Click(object sender, EventArgs e) { try { int VESSEL_ID = Convert.ToInt32(Request.QueryString["VesselID"].ToString()); DataSet dsInsp = objInsp.GetVesselInspectionDetails(Convert.ToInt32(Request.QueryString["InspID"].ToString())); string WL_TYPE; if (ddlType.SelectedItem.Text == "-Select-") { WL_TYPE = ""; } else { WL_TYPE = ddlType.SelectedValue; } string JOB_DESCRIPTION = txtDesc.Text; string DATE_RAISED = DateTime.Today.ToString("dd/MM/yyyy"); string DATE_ESTMTD_CMPLTN = txtExpectedComp.Text; if (txtExpectedComp.Text.Trim() != "") { DATE_ESTMTD_CMPLTN = txtExpectedComp.Text; } else { DATE_ESTMTD_CMPLTN = "1900/01/01"; } string DATE_COMPLETED = "1900/01/01"; int PRIORITY = 1; //int.Parse(ddlPriority.SelectedValue); int ASSIGNOR = 0; // int.Parse(ddlAssignedBy.SelectedValue); int NCR_YN = 0; //int.Parse(rdoNCR.SelectedValue); int DEPT_SHIP = int.Parse(ddlDeptShip.SelectedValue); int DEPT_OFFICE = int.Parse(ddlDeptOff.SelectedValue); string REQSN_MSG_REF = ""; // uc_ReqRef.SelectedValue; int DEFER_TO_DD = 0; // int.Parse(rdoDeferToDrydock.SelectedValue); int CATEGORY_NATURE = 0; //int.Parse(ddlNature.SelectedValue); int CATEGORY_PRIMARY = 0; // int.Parse(ddlPrimary.SelectedValue); int CATEGORY_SECONDARY = 0; // int.Parse(ddlSecondary.SelectedValue); int CATEGORY_MINOR = 0; // int.Parse(ddlMinorCat.SelectedValue); int PIC = 0; //if (ddlPIC.SelectedIndex > 0) // PIC = int.Parse(ddlPIC.SelectedValue.ToString()); int CREATED_BY = int.Parse(Session["USERID"].ToString()); int Inspector = 0;//UDFLib.ConvertToInteger(ddlInspector.SelectedValue); string InspectionDate = dsInsp.Tables[0].Rows[0]["InspectionDate"].ToString(); //if (InspectionDate.Trim() != "") //{ // DATE_COMPLETED = InspectionDate; // txtCompletedOn.Text = InspectionDate; //} //else //{ // DATE_COMPLETED = "1900/01/01"; // InspectionDate = "1900/01/01"; //} int TOSYNC = 0; string Causes = ""; string CorrectiveAction = ""; string PreventiveAction = ""; if (ddlType.SelectedValue.ToString() == "NCR") //This if block is added by Hadish on 24-Nov-16 JIT:11076 ,Guided by Pranav { NCR_YN = -1; } else { NCR_YN = 0; } if (NCR_YN == -1) { Causes = ""; CorrectiveAction = ""; PreventiveAction = ""; } if (objInsp.IsVessel(VESSEL_ID) == 1) { TOSYNC = 1; } DataTable dtNewRecord = new DataTable(); if (Session["Mode"].ToString() == "ADD") { //dtNewRecord = objInsp.Insert_NewJob(VESSEL_ID, JOB_DESCRIPTION, DATE_RAISED, DATE_ESTMTD_CMPLTN, DATE_COMPLETED, PRIORITY, ASSIGNOR, NCR_YN, DEPT_SHIP, DEPT_OFFICE, REQSN_MSG_REF, DEFER_TO_DD, CATEGORY_NATURE, CATEGORY_PRIMARY, CATEGORY_SECONDARY, CATEGORY_MINOR, PIC, CREATED_BY, TOSYNC, Causes, CorrectiveAction, PreventiveAction, Inspector, InspectionDate, WL_TYPE); string typeStr = "0"; //if (WL_TYPE == "DEFECT") //{ // typeStr = "1"; //} //else //{ // typeStr = "2"; //} //string Activity_ID= objInsp.TEC_WL_INS_Acivity(VESSEL_ID, UDFLib.ConvertDateToNull(DATE_RAISED), UDFLib.ConvertDateToNull(DATE_ESTMTD_CMPLTN), 0, UDFLib.ConvertIntegerToNull(Request.QueryString["LocationID"].ToString()), DEPT_SHIP, DEPT_OFFICE, JOB_DESCRIPTION, typeStr, CREATED_BY); dtNewRecord = objInsp.Insert_NewJob(VESSEL_ID, JOB_DESCRIPTION, DATE_RAISED, DATE_ESTMTD_CMPLTN, DATE_COMPLETED, PRIORITY, ASSIGNOR, NCR_YN, DEPT_SHIP, DEPT_OFFICE, REQSN_MSG_REF, DEFER_TO_DD, CATEGORY_NATURE, CATEGORY_PRIMARY, CATEGORY_SECONDARY, CATEGORY_MINOR, PIC, CREATED_BY, TOSYNC, Causes, CorrectiveAction, PreventiveAction, Inspector, InspectionDate, WL_TYPE, "", typeStr, UDFLib.ConvertIntegerToNull(Request.QueryString["LocationID"].ToString()), null, 1); if (dtNewRecord.Rows.Count > 0) { //if (rdoNCR.SelectedValue == "-1") //{ // txtNCRNo.Text = dtNewRecord.Rows[0]["NCR_NUM"].ToString(); // txtNCRNo_Year.Text = dtNewRecord.Rows[0]["NCR_YEAR"].ToString(); //} //txtOfficeID.Value = dtNewRecord.Rows[0]["OFFICE_ID"].ToString(); //txtJobCode.Text = "0"; if (Request.QueryString["InspID"] != null && Request.QueryString["LocationID"] != null) { int inspID = Convert.ToInt32(Request.QueryString["InspID"]); int WorlistID = Convert.ToInt32(dtNewRecord.Rows[0]["WORKLIST_ID"].ToString()); int OfficeID = Convert.ToInt32(dtNewRecord.Rows[0]["OFFICE_ID"].ToString()); //int LocationID = UDFLib.ConvertIntegerToNull(Request.QueryString["LocationID"].ToString()); int LocationNodeID = Convert.ToInt32(Request.QueryString["LocationNodeID"].ToString()); //objInsp.TEC_WL_INS_InspectionWorklist_Location(Convert.ToInt32(Request.QueryString["InspID"]), WorlistID, VESSEL_ID, OfficeID, LocationID, CREATED_BY); objInsp.TEC_WL_INS_InspectionWorklist_Location(Convert.ToInt32(Request.QueryString["InspID"]), WorlistID, VESSEL_ID, OfficeID, UDFLib.ConvertIntegerToNull(Request.QueryString["LocationID"].ToString()), LocationNodeID, CREATED_BY); // if (ddlType.SelectedItem.Text == "Defect") { //objInsp.INSP_Update_SubSystemRating(Convert.ToInt32(Request.QueryString["InspID"]), LocationID, "", "", CREATED_BY, DateTime.Now); objInsp.INSP_Update_SubSystemRating(Convert.ToInt32(Request.QueryString["InspID"]), UDFLib.ConvertIntegerToNull(Request.QueryString["LocationID"].ToString()), "", "", CREATED_BY, DateTime.Now); } Session["Attachment"] = null; } } Search_Worklist(); string js1 = "alert('Job added successfully.'); hideModal('dvJob');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert1", js1, true); string js2 = "parent.UpdatePage();"; ScriptManager.RegisterStartupScript(this, this.GetType(), "hidePopup", js2, true); ClearPage(); // BtnSave.Enabled = false; //BtnAttach.Enabled = false; //BtnClear.Enabled = true; Session["Mode"] = "ADD"; } else if (Session["Mode"].ToString() == "EDIT") { int res = objInsp.Update_Job(VESSEL_ID, UDFLib.ConvertToInteger(Session["WID"].ToString()), UDFLib.ConvertToInteger(Session["OID"].ToString()), DATE_ESTMTD_CMPLTN, DATE_COMPLETED, PRIORITY, ASSIGNOR, NCR_YN, DEPT_SHIP, DEPT_OFFICE, REQSN_MSG_REF, DEFER_TO_DD, CATEGORY_NATURE, CATEGORY_PRIMARY, CATEGORY_SECONDARY, CATEGORY_MINOR, UDFLib.ConvertStringToNull(PIC), CREATED_BY, TOSYNC, Inspector, InspectionDate, WL_TYPE, null); //DataTable dtAttach = (DataTable)Session["Attachment"]; //if (dtAttach.Rows.Count > 0) //{ // for (int i = 0; i < dtAttach.Rows.Count; i++) // { // int FileID = objInsp.Insert_Worklist_Attachment(VESSEL_ID, UDFLib.ConvertToInteger(Session["WID"].ToString()), UDFLib.ConvertToInteger(Session["OID"].ToString()), dtAttach.Rows[i]["FileName"].ToString(), dtAttach.Rows[i]["Flag_Attach"].ToString(), Convert.ToInt32(dtAttach.Rows[i]["FileSize"].ToString()), UDFLib.ConvertToInteger(Session["USERID"])); // } //} string js1 = "alert('Job updated successfully.'); "; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert1", js1, true); //string js2 = "parent.UpdatePage();"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "hidePopup", js2, true); Search_Worklist(); ClearPage(); //BtnSave.Enabled = false; //BtnAttach.Enabled = false; //BtnClear.Enabled = true; Session["Mode"] = "ADD"; } } catch (Exception ex) { string js = "alert('Error in saving data!! Error: " + ex.Message.Replace("'", "") + "');"; ScriptManager.RegisterStartupScript(this, this.GetType(), "alertUser", js, true); UDFLib.WriteExceptionLog(ex); } }