Ejemplo n.º 1
0
    /// <summary>
    /// Purpose: To make search functionality available
    /// </summary>
    protected void Search_Worklist()
    {
        try
        {
            SaveItemsSelection();
            DataTable dtStatus = new DataTable();
            dtStatus.Columns.Add("All", typeof(int));
            dtStatus.Columns.Add("Pending", typeof(int));
            dtStatus.Columns.Add("Completed", typeof(int));
            dtStatus.Columns.Add("Reworked", typeof(int));
            dtStatus.Columns.Add("Verified", typeof(int));
            dtStatus.Columns.Add("Overdue", typeof(int));



            dtStatus.Rows.Add(rblJobStaus.Items[0].Selected == true ? 1 : 0,
                              rblJobStaus.Items[1].Selected == true ? 1 : 0,
                              0,

                              rblJobStaus.Items[2].Selected == true ? 1 : 0,
                              rblJobStaus.Items[3].Selected == true ? 1 : 0,
                              rblJobStaus.Items[4].Selected == true ? 1 : 0);

            DataTable dtFilter = new DataTable();
            dtFilter.Columns.Add("PRM_NAME", typeof(string));
            dtFilter.Columns.Add("PRM_VALUE", typeof(object));

            dtFilter.Rows.Add(new object[] { "@FLEET_ID", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@VESSEL_ID", UDFLib.ConvertIntegerToNull(hdnVesselID.Value) });
            dtFilter.Rows.Add(new object[] { "@ASSIGNOR", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DEPT_SHIP", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DEPT_OFFICE", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@PRIORITY", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@CATEGORY_NATURE", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@CATEGORY_PRIMARY", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@CATEGORY_SECONDARY", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@CATEGORY_MINOR", null, });
            dtFilter.Rows.Add(new object[] { "@JOB_DESCRIPTION", UDFLib.ConvertStringToNull(txtDescription.Text.Trim()) });
            dtFilter.Rows.Add(new object[] { "@JOB_STATUS", UDFLib.ConvertStringToNull(rblJobStaus.SelectedValue) });
            dtFilter.Rows.Add(new object[] { "@dtJOB_Status", dtStatus });
            dtFilter.Rows.Add(new object[] { "@JOB_TYPE", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@PIC", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@JOB_MODIFIED_IN", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DATE_RAISED_FROM", UDFLib.ConvertDateToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DATE_RAISED_TO", UDFLib.ConvertDateToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DATE_CMPLTN_FROM", UDFLib.ConvertDateToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DATE_CMPLTN_TO", UDFLib.ConvertDateToNull(null) });
            dtFilter.Rows.Add(new object[] { "@DEFER_TO_DD", (null) });
            dtFilter.Rows.Add(new object[] { "@SENT_TO_SHIP", (null) });
            dtFilter.Rows.Add(new object[] { "@HAVING_REQ_NO", (null) });
            dtFilter.Rows.Add(new object[] { "@FLAGGED_FOR_MEETING", (null) });
            dtFilter.Rows.Add(new object[] { "@INSPECTOR", UDFLib.ConvertIntegerToNull(null) });
            dtFilter.Rows.Add(new object[] { "@PAGE_INDEX", ucCustomPagerctp.CurrentPageIndex });
            dtFilter.Rows.Add(new object[] { "@PAGE_SIZE", ucCustomPagerctp.PageSize });

            int Record_Count = 0;

            DataTable taskTable = objInsp.INSP_GET_WORKLIST_JOB(dtFilter, ref Record_Count);

            grdJoblist.DataSource = taskTable;
            grdJoblist.DataBind();

            ucCustomPagerctp.CountTotalRec = Record_Count.ToString();
            ucCustomPagerctp.BuildPager();

            DataTable dtPKIDs = taskTable.DefaultView.ToTable(true, new string[] { "WORKLIST_ID", "VESSEL_ID", "OFFICE_ID" });
            dtPKIDs.PrimaryKey           = new DataColumn[] { dtPKIDs.Columns["WORKLIST_ID"], dtPKIDs.Columns["VESSEL_ID"], dtPKIDs.Columns["OFFICE_ID"] };
            Session["WORKLIST_PKID_NAV"] = dtPKIDs;

            lblRecordCount.Text = Record_Count.ToString();

            DataSet dsCheckListWorklist;

            dsCheckListWorklist = objBLLIndx.VET_Get_ObservationWorklistJobs(UDFLib.ConvertToInteger(Request.QueryString["Vessel_ID"]), UDFLib.ConvertToInteger(ViewState["Observation_ID"].ToString()));

            foreach (GridViewRow gr in grdJoblist.Rows)
            {
                string WORKLIST_ID = Convert.ToString(grdJoblist.DataKeys[gr.RowIndex]["WORKLIST_ID"]);
                string OFFICE_ID   = Convert.ToString(grdJoblist.DataKeys[gr.RowIndex]["OFFICE_ID"]);

                if (dsCheckListWorklist.Tables.Count > 0)
                {
                    DataRow[] drchk = dsCheckListWorklist.Tables[0].Select("WORKLIST_ID=" + WORKLIST_ID + " and OFFICE_ID=" + OFFICE_ID);

                    if (drchk.Length > 0)
                    {
                        if (drchk[0]["Observation_ID"].ToString() != ViewState["Observation_ID"].ToString())
                        {
                            (gr.FindControl("checkRow") as CheckBox).Checked = false;
                            (gr.FindControl("checkRow") as CheckBox).Enabled = false;
                        }
                        else
                        {
                            if (drchk[0]["Observation_ID"].ToString() != "0" && drchk[0]["Observation_ID"].ToString() != "")
                            {
                                (gr.FindControl("checkRow") as CheckBox).Checked = true;

                                if (Convert.ToInt32(drchk[0]["ISCURRENT"]) == 0)
                                {
                                    (gr.FindControl("checkRow") as CheckBox).Enabled = false;
                                }
                            }
                        }
                    }
                }
            }

            SaveItemsSelection();

            string js = "GridWorkFlow();";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "error1", js, true);
        }
        catch (Exception ex)
        {
            string js = "alert('Error in loading data!! Error: " + UDFLib.ReplaceSpecialCharacter(ex.Message) + "');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "error2", js, true);
        }
    }