protected void ImgExpExcel_Click(object sender, EventArgs e)
    {
        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());
        }

        ChkStatus();

        if (Session["sVesselCode"] == "0")
        {
            Session["sVesselCode"] = ddlVessel.SelectedValues;
        }
        if (Session["sAccountType"] == "0")
        {
            Session["sAccountType"] = ddlAccountType.SelectedValues;
        }
        if (Session["sAccClassification"] == "0")
        {
            Session["sAccClassification"] = ddlAccClassification.SelectedValues;
        }


        DataSet ds = BLL_POLOG_Register.POLOG_Get_Purchase_Report(UDFLib.ConvertStringToNull(ddlSupplier.SelectedValue),
                                                                  (DataTable)Session["sVesselCode"], (DataTable)Session["sAccountType"], (DataTable)Session["sAccClassification"], CurrStatus,
                                                                  txtFromDate.Text != "" ? Convert.ToDateTime(txtFromDate.Text) : Convert.ToDateTime("01/01/1900"), txtToDate.Text != "" ? Convert.ToDateTime(txtToDate.Text) : Convert.ToDateTime("01/01/1900"),
                                                                  UDFLib.ConvertIntegerToNull(GetSessionUserID()), sortbycoloumn, sortdirection
                                                                  , null, null, ref rowcount);


        string[] HeaderCaptions  = { "PO Status", "PO Date", "PO Code", "ship Ref Code", "Acct", "Amount", "Cur", "PO USD Value", "Invoice USD Amount", "Paid USD Amount", "Outstanding PO Amount", "Supplier Name" };
        string[] DataColumnsName = { "Line_Status", "Line_Date", "Office_Ref_Code", "ship_Ref_Code", "Account_Classification", "Line_Amount", "Line_Currency", "PO_USD_Value", "Invoice_USD_Amount", "Paid_USD_Amount", "OutStanding_USD_Amount", "Supplier_Name" };

        GridViewExportUtil.ShowExcel(ds.Tables[0], HeaderCaptions, DataColumnsName, "Purchasing_Report", "Purchasing Report", "");
    }
    public void BindGridView()
    {
        //try
        //{
        objChangeReqstMerge.AddMergedColumns(new int[] { 5, 6 }, "PO", "HeaderStyle-center");

        ChkStatus();
        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());
        }

        if (Session["sVesselCode"] == "0")
        {
            Session["sVesselCode"] = ddlVessel.SelectedValues;
        }
        if (Session["sAccountType"] == "0")
        {
            Session["sAccountType"] = ddlAccountType.SelectedValues;
        }
        if (Session["sAccClassification"] == "0")
        {
            Session["sAccClassification"] = ddlAccClassification.SelectedValues;
        }

        DataSet ds = BLL_POLOG_Register.POLOG_Get_Purchase_Report(UDFLib.ConvertStringToNull(ddlSupplier.SelectedValue),
                                                                  (DataTable)Session["sVesselCode"], (DataTable)Session["sAccountType"], (DataTable)Session["sAccClassification"], CurrStatus,
                                                                  txtFromDate.Text != "" ? Convert.ToDateTime(txtFromDate.Text) : Convert.ToDateTime("01/01/1900"), txtToDate.Text != "" ? Convert.ToDateTime(txtToDate.Text) : Convert.ToDateTime("01/01/1900"),
                                                                  UDFLib.ConvertIntegerToNull(GetSessionUserID()), sortbycoloumn, sortdirection
                                                                  , ucCustomPagerItems.CurrentPageIndex, ucCustomPagerItems.PageSize, ref rowcount);


        if (ucCustomPagerItems.isCountRecord == 1)
        {
            ucCustomPagerItems.CountTotalRec = rowcount.ToString();
            ucCustomPagerItems.BuildPager();
        }

        if (ds.Tables[0].Rows.Count > 0)
        {
            divPurchase.Visible   = true;
            gvPurchase.DataSource = ds.Tables[0];
            gvPurchase.DataBind();
            Label lblTotOutPOCurAmt1 = (Label)gvPurchase.FooterRow.FindControl("lblTotOutPOCurAmt1");
            Label lblTotPOUSDValue1  = (Label)gvPurchase.FooterRow.FindControl("lblTotPOUSDValue1");
            Label lblTotInvUSDAmt1   = (Label)gvPurchase.FooterRow.FindControl("lblTotInvUSDAmt1");
            Label lblTotPaidUSDAmt1  = (Label)gvPurchase.FooterRow.FindControl("lblTotPaidUSDAmt1");
            lblTotOutPOCurAmt1.Text = ds.Tables[1].Rows[0]["OutStanding_USD_Amount"].ToString();
            lblTotPOUSDValue1.Text  = ds.Tables[1].Rows[0]["PO_USD_Value"].ToString();
            lblTotInvUSDAmt1.Text   = ds.Tables[1].Rows[0]["Invoice_USD_Amount"].ToString();
            lblTotPaidUSDAmt1.Text  = ds.Tables[1].Rows[0]["Paid_USD_Amount"].ToString();
        }
        else
        {
            divPurchase.Visible   = false;
            gvPurchase.DataSource = ds.Tables[0];
            gvPurchase.DataBind();
            gvPurchase.EmptyDataText = "NO RECORDS FOUND";
        }
        // }
        //catch { }
        //{
        //}
    }