Exemplo n.º 1
0
    private void BindLists(DataSet ds)
    {
        DataSetHelper         dsHelper = new DataSetHelper(ref ds);
        ClsDivisionProcessing dp       = new ClsDivisionProcessing();

        dsHelper.SelectDistinct("Terms", ds.Tables[0], "Term");
        dsHelper.SelectDistinct("Course", ds.Tables[0], "CourseNumber");
        dsHelper.SelectDistinct("SubmittedBy", ds.Tables[0], "SubmittedBy");

        ddlTermFilter.DataSource = ds.Tables["Terms"];
        ddlTermFilter.DataBind();
        ddlTermFilter.Items.Insert(0, new ListItem("All", "All"));

        ddlCourse.DataSource = ds.Tables["Course"];
        ddlCourse.DataBind();
        ddlCourse.Items.Insert(0, new ListItem("All", "All"));

        ddlSubmittedByFilter.DataSource = ds.Tables["SubmittedBy"];
        ddlSubmittedByFilter.DataBind();
        ddlSubmittedByFilter.Items.Insert(0, new ListItem("All", "All"));

        ddlDivision.DataSource = dp.GetDivisions();
        ddlDivision.DataBind();
        ddlDivision.Items.Insert(0, new ListItem("All", "All"));
    }
Exemplo n.º 2
0
    private void CreateFilteredReport()
    {
        try
        {
            ClsDivisionProcessing dp         = new ClsDivisionProcessing();
            List <string>         rowFilters = new List <string>();
            if (ddlTermFilter.SelectedValue != "All")
            {
                rowFilters.Add("Term = '" + ddlTermFilter.SelectedValue + "' ");
            }
            if (ddlCourse.SelectedValue != "All")
            {
                rowFilters.Add("CourseNumber LIKE '" + ddlCourse.SelectedValue.Trim() + "%' ");
            }
            if (ddlSubmittedByFilter.SelectedValue != "All")
            {
                rowFilters.Add("SubmittedBy = '" + ddlSubmittedByFilter.SelectedValue.Trim() + "' ");
            }
            if (!string.IsNullOrEmpty(txtFrom.Text))
            {
                DateTime from = DateTime.Parse(txtFrom.Text);
                rowFilters.Add("DateSubmitted >=#" + from.ToShortDateString() + "#");
            }
            if (!string.IsNullOrEmpty(txtTo.Text))
            {
                DateTime to = DateTime.Parse(txtTo.Text);
                to = to.AddDays(1);
                rowFilters.Add("DateSubmitted <= #" + to.ToShortDateString() + "#");
            }
            if (ddlDivision.SelectedValue != "All")
            {
                rowFilters.Add(dp.GetDepartments(ddlDivision.SelectedValue));
            }

            StringBuilder sb = new StringBuilder();
            string        a  = "";
            foreach (string filter in rowFilters)
            {
                sb.Append(a);
                sb.Append(filter);
                a = " AND ";
            }
            rowFilter = sb.ToString();

            DataSet   ds = _log.FillDs();
            DataTable dt = new DataTable();
            dt = ds.Tables[0].Clone();

            DataView view = ds.Tables[0].DefaultView;
            view.RowFilter = rowFilter;

            DataTable cacheTable = view.ToTable();
            int       counter    = ((currentPageNumber - 1) * PAGE_SIZE);
            for (int i = counter; i < (PAGE_SIZE + counter); i++)
            {
                dt.ImportRow(cacheTable.Rows[i]);

                if (i == (view.Count - 1))
                {
                    break;
                }
            }

            double totalRows = view.Count;

            lblTotalPages.Text  = CalculateTotalPages(totalRows).ToString();
            lblCurrentPage.Text = currentPageNumber.ToString();

            if (currentPageNumber == 1)
            {
                Btn_Previous.Enabled = false;

                if (Int32.Parse(lblTotalPages.Text) > 1)
                {
                    Btn_Next.Enabled = true;
                }
                else
                {
                    Btn_Next.Enabled = false;
                }
            }
            else
            {
                Btn_Previous.Enabled = true;

                if (currentPageNumber == Int32.Parse(lblTotalPages.Text))
                {
                    Btn_Next.Enabled = false;
                }
                else
                {
                    Btn_Next.Enabled = true;
                }
            }

            lblRecordCount.Text        = view.Count.ToString();
            gvNeedsApproval.DataSource = dt;
            gvNeedsApproval.DataBind();
        }
        catch (Exception ex)
        {
            gvNeedsApproval.DataSource = null;
            gvNeedsApproval.DataBind();
        }
    }