Example #1
0
    private void BindData()
    {
        EnterpriseService comBSO = new EnterpriseService();
        DataTable         dt     = new DataTable();
        int    AreaId            = 0;
        int    SubAreaId         = 0;
        int    OrgId             = 0;
        int    Year          = 0;
        string strclientview = string.Empty;
        string strKey        = string.Empty;

        if (txtKeyword.Text != "" && txtKeyword.Text.Trim() != "")
        {
            strKey = txtKeyword.Text.Trim();
        }
        if (ddlArea.SelectedIndex > 0)
        {
            AreaId = Convert.ToInt32(ddlArea.SelectedValue);
        }
        if (ddlSubArea.SelectedIndex > 0)
        {
            SubAreaId = Convert.ToInt32(ddlSubArea.SelectedValue);
        }
        if (ddlOrg.SelectedIndex > 0)
        {
            OrgId = Convert.ToInt32(ddlOrg.SelectedValue);
        }
        if (ddlYear.SelectedIndex > 0)
        {
            Year = Convert.ToInt32(ddlYear.SelectedValue);
        }
        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        dt = comBSO.GetDataTable(Year, AreaId, SubAreaId, OrgId, 0, 0, null, strKey, paging);
        if (dt != null && dt.Rows.Count > 0)
        {
            paging.RowsCount   = Convert.ToInt32(dt.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.CurrentPage = CurrentPage;
            Paging.TotalRecord = Convert.ToInt32(dt.Rows[0]["Total"]);
            Paging.DataLoad();
            if (paging.PagesCount <= 1)
            {
                strclientview  = "Tổng số có " + paging.RowsCount + " doanh nghiệp";
                Paging.Visible = false;
            }
            else
            {
                int  st  = (CurrentPage - 1) * PageSize + 1;
                long end = CurrentPage * PageSize;
                if (end > paging.RowsCount)
                {
                    end = paging.RowsCount;
                }
                strclientview  = "Đang xem trang " + CurrentPage + ". Hiển thị từ " + st + " - " + end + " trên tổng số " + paging.RowsCount + " doanh nghiệp";
                Paging.Visible = true;
            }
        }
        else
        {
            strclientview  = "";
            Paging.Visible = false;
        }
        grvNewsGroup.DataSource = dt;
        grvNewsGroup.DataBind();
        clientview.Text = strclientview;
    }