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

            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["WBranchTransferid"].ToString() != null)
                {
                    iID = Convert.ToInt64(Request.QueryString["WBranchTransferid"].ToString());
                }
                else
                {
                    iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["WBranchTransferid"].ToString(), Session.SessionID));
                }
            }
            catch { iID = Convert.ToInt64(Common.Decrypt(lblReferrer.Text.Substring(lblReferrer.Text.IndexOf("WBranchTransferid") + 13), Session.SessionID)); }

            ReportDataset rptds = new ReportDataset();

            WBranchTransfer clsWBranchTransfer = new WBranchTransfer();

            System.Data.DataTable dt = clsWBranchTransfer.ListAsDataTable(iID);
            WBranchTransferItem   clsWBranchTransferItem = new WBranchTransferItem(clsWBranchTransfer.Connection, clsWBranchTransfer.Transaction);

            System.Data.DataTable dtitems = clsWBranchTransferItem.ListAsDataTable(iID);
            clsWBranchTransfer.CommitAndDispose();

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.WBranchTransfer.NewRow();

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

                rptds.WBranchTransfer.Rows.Add(drNew);
            }
            foreach (System.Data.DataRow dr in dtitems.Rows)
            {
                DataRow drNew = rptds.WBranchTransferItems.NewRow();

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

                rptds.WBranchTransferItems.Rows.Add(drNew);
            }

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
예제 #2
0
        private void LoadList()
        {
            WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
            DataClass       clsDataClass       = new DataClass();
            Common          Common             = new Common();

            string SortField = "WBranchTransferID";

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

            DateTime dteTransferStartDate = DateTime.MinValue;

            try { if (txtTransferStartDate.Text != string.Empty)
                  {
                      dteTransferStartDate = Convert.ToDateTime(txtTransferStartDate.Text + " " + txtTransferStartTime.Text);
                  }
            }
            catch { }

            DateTime dteTransferEndDate = DateTime.MinValue;

            try { if (txtTransferEndDate.Text != string.Empty)
                  {
                      dteTransferEndDate = Convert.ToDateTime(txtTransferEndDate.Text + " " + txtTransferEndTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingStartDate = DateTime.MinValue;

            try { if (txtPostingStartDate.Text != string.Empty)
                  {
                      dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingEndDate = DateTime.MinValue;

            try { if (txtPostingEndDate.Text != string.Empty)
                  {
                      dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text);
                  }
            }
            catch { }

            WBranchTransferDetails searchKey = new WBranchTransferDetails();

            searchKey.WBranchTransferNo = txtSearch.Text;

            WBranchTransferStatus status = (WBranchTransferStatus)Enum.Parse(typeof(WBranchTransferStatus), cboStatus.SelectedItem.Value);

            PageData.DataSource = clsWBranchTransfer.ListAsDataTable(0, 0, searchKey, status, dteTransferStartDate, dteTransferEndDate, dtePostingStartDate, dtePostingEndDate, null, null, SortField, sortoption).DefaultView;
            clsWBranchTransfer.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;
        }