Ejemplo n.º 1
0
    /// <summary>
    /// Bind all records of vetting
    /// </summary>
    public void Bind_VettingIndex()
    {
        try
        {
            BLL_VET_Index objBLLIndx    = new BLL_VET_Index();
            DataSet       ds            = new DataSet();
            int           rowcount      = ucCustomPagerItems.isCountRecord;
            string        sortbycoloumn = (ViewState["SORTBYCOLOUMN"] == null) ? null : (ViewState["SORTBYCOLOUMN"].ToString());
            int?          sortdirection = null; if (ViewState["SORTDIRECTION"] != null)
            {
                sortdirection = Int32.Parse(ViewState["SORTDIRECTION"].ToString());
            }
            int       IsValid       = 0;
            DataTable dtEXInspector = new DataTable();
            dtEXInspector.Columns.Add("ID");
            DataTable dtInspector = new DataTable();
            dtInspector.Columns.Add("ID");
            foreach (DataRow dr in DDLInspector.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?VetFromDate, VetToDate;
            VetFromDate = txtLVetFromDate.Text.Trim() == "" ? null : UDFLib.ConvertDateToNull(UDFLib.ConvertToDate(txtLVetFromDate.Text));
            VetToDate   = txtLVetToDate.Text.Trim() == "" ? null : UDFLib.ConvertDateToNull(UDFLib.ConvertToDate(txtLVetToDate.Text));

            if (rbtnValid.Checked == true)
            {
                IsValid = 1;
            }
            ds = objBLLIndx.VET_Get_VettingIndex(DDLVessel.SelectedValues, DDLVetType.SelectedValues, DDLStatus.SelectedValues, txtDueDays.Text == "0" ? UDFLib.ConvertToInteger(txtDueDays.Text.Trim()) : UDFLib.ConvertIntegerToNull(txtDueDays.Text.Trim()), IsValid, UDFLib.ConvertToInteger(rbtnObservation.SelectedValue), DDLOilMajor.SelectedValues, dtInspector, dtEXInspector, VetFromDate, VetToDate, DDLJobStatus.SelectedValues, txtVessel.Text != "" ? txtVessel.Text.Trim() : null, sortbycoloumn, sortdirection, ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, ref rowcount);

            if (ds.Tables.Count > 0)
            {
                ViewState["dtObservationCount"] = ds.Tables[1];
                ViewState["dtNotesCount"]       = ds.Tables[2];
                ViewState["dtResponse"]         = ds.Tables[3];
                ViewState["dtJobsCount"]        = ds.Tables[4];
            }

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

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