Exemple #1
0
        private void SetDataSource(ReportDocument Report)
        {
            long iID = 0;

            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["soid"].ToString() != null)
                {
                    iID = Convert.ToInt64(Request.QueryString["soid"].ToString());
                }
                else
                {
                    iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["soid"].ToString(), Session.SessionID));
                }
                lblReferrer.ToolTip = iID.ToString();
            }
            catch { iID = long.Parse(lblReferrer.ToolTip); }

            ReportDataset rptds = new ReportDataset();

            SO clsSO = new SO();
            MySqlDataReader myreader = clsSO.List(iID, "SOID", SortOption.Ascending);

            while (myreader.Read())
            {
                DataRow drNew = rptds.SO.NewRow();

                foreach (DataColumn dc in rptds.SO.Columns)
                {
                    drNew[dc] = "" + myreader[dc.ColumnName];
                }

                rptds.SO.Rows.Add(drNew);
            }
            myreader.Close();

            SOItem clsSOItem = new SOItem(clsSO.Connection, clsSO.Transaction);

            System.Data.DataTable dt = clsSOItem.ListAsDataTable(iID);
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.SOItems.NewRow();

                foreach (DataColumn dc in rptds.SOItems.Columns)
                {
                    drNew[dc] = "" + dr[dc.ColumnName];
                }

                rptds.SOItems.Rows.Add(drNew);
            }
            clsSO.CommitAndDispose();

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Exemple #2
0
        private void LoadList()
        {
            SO        clsSO        = new SO();
            DataClass clsDataClass = new DataClass();
            Common    Common       = new Common();

            string SortField = "SOID";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            if (Request.QueryString["Search"] == null)
            {
                PageData.DataSource = clsDataClass.DataReaderToDataTable(clsSO.List(SOStatus.Posted, SortField, sortoption)).DefaultView;
            }
            else
            {
                string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID);
                PageData.DataSource = clsDataClass.DataReaderToDataTable(clsSO.Search(SOStatus.Posted, SearchKey, SortField, sortoption)).DefaultView;
            }

            clsSO.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }