Ejemplo n.º 1
0
    /// <summary>
    /// Bind all records of observation index
    /// </summary>
    public void Bind_ObservationIndex()
    {
        try
        {
            BLL_VET_Index objBLLIndx    = new BLL_VET_Index();
            DataSet       ds            = new DataSet();
            int           rowcount      = ucCustomPagerItemsObs.isCountRecord;
            string        sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
            int?          sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
            {
                sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
            }

            DataTable dtInspector = new DataTable();
            dtInspector.Columns.Add("ID");
            DataTable dtEXInspector = new DataTable();
            dtEXInspector.Columns.Add("ID");

            foreach (DataRow dr in DDLInspectorObs.SelectedValues.Rows)
            {
                if (dr[0].ToString().Split('_')[1] == "In")
                {
                    dtInspector.Rows.Add(dr[0].ToString().Split('_')[0]);
                }
                if (dr[0].ToString().Split('_')[1] == "Ex")
                {
                    dtEXInspector.Rows.Add(dr[0].ToString().Split('_')[0]);
                }
            }

            DateTime?LObsFromDate, LObsToDate;
            LObsFromDate = txtLObsFromDate.Text.Trim() == "" ? null : UDFLib.ConvertDateToNull(UDFLib.ConvertToDate(txtLObsFromDate.Text));
            LObsToDate   = txtLObsToDate.Text.Trim() == "" ? null : UDFLib.ConvertDateToNull(UDFLib.ConvertToDate(txtLObsToDate.Text));
            ds           = objBLLIndx.VET_Get_ObservationIndex(DDLQuestionnaire.SelectedValues, DDLSection.SelectedValues, DDLQuestion.SelectedValues, UDFLib.ConvertToInteger(rbtnType.SelectedValue), ViewState["Status"].ToString(), UDFLib.ConvertToInteger(DDLFleet.SelectedValue), DDLVesselObs.SelectedValues, DDLOilMajorObs.SelectedValues, dtInspector, dtEXInspector, DDLCategories.SelectedValues, DDLRiskLevel.SelectedValues, txtObservationVessel.Text != "" ? txtObservationVessel.Text.Trim() : null, LObsFromDate, LObsToDate, sortbycoloumn, sortdirection, ucCustomPagerItemsObs.CurrentPageIndex, ucCustomPagerItemsObs.PageSize, ref rowcount);

            if (ds.Tables.Count > 0)
            {
                ViewState["dtObsResponse"]    = ds.Tables[1];
                ViewState["dtObsJobsCount"]   = ds.Tables[2];
                ViewState["dtObsvationCount"] = ds.Tables[3];
            }

            if (ucCustomPagerItemsObs.isCountRecord == 1)
            {
                ucCustomPagerItemsObs.CountTotalRec = rowcount.ToString();
                ucCustomPagerItemsObs.BuildPager();
            }
            gvObservationIndex.DataSource = ds.Tables[0];
            gvObservationIndex.DataBind();
            if (ds.Tables[0].Rows.Count > 0)
            {
                btnObsExport.Enabled = true;
            }
            else
            {
                btnObsExport.Enabled = false;
            }

            UpdPnlGridObs.Update();
            UpdPnlFilterObs.Update();
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
            string js = "alert('" + UDFLib.GetException("SystemError/ GeneralMessage") + "');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "error", js, true);
        }
    }