Exemplo n.º 1
0
        private void SetDataSource(ReportDocument Report)
        {
            long iID = 0;
            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["retid"].ToString() != null)
                { iID = Convert.ToInt64(Request.QueryString["retid"].ToString()); }
                else
                { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["retid"].ToString(), Session.SessionID)); }
                lblReferrer.ToolTip = iID.ToString();
            }
            catch { iID = long.Parse(lblReferrer.ToolTip); }

            ReportDataset rptds = new ReportDataset();

            CreditMemos clsCreditMemos = new CreditMemos();
            MySqlDataReader myreader = clsCreditMemos.List(iID, "CreditMemoID", SortOption.Ascending);

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

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

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

            CreditMemoItems clsCreditMemoItems = new CreditMemoItems(clsCreditMemos.Connection, clsCreditMemos.Transaction);
            System.Data.DataTable dt = clsCreditMemoItems.ListAsDataTable(iID);
            foreach(System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.CreditMemoItem.NewRow();

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

                rptds.CreditMemoItem.Rows.Add(drNew);
            }
            clsCreditMemos.CommitAndDispose();

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }