예제 #1
0
		private void SetDataSource(ReportDocument Report)
		{
            Int64 iID = 0;
            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["branchtransferid"].ToString() != null)
                { iID = Convert.ToInt64(Request.QueryString["branchtransferid"].ToString()); }
                else
                { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["branchtransferid"].ToString(), Session.SessionID)); }
            }
            catch { iID = Convert.ToInt64(Common.Decrypt(lblReferrer.Text.Substring(lblReferrer.Text.IndexOf("branchtransferid") + 13), Session.SessionID)); }

			ReportDataset rptds = new ReportDataset();

            BranchTransfer clsBranchTransfer = new BranchTransfer();
			System.Data.DataTable dt = clsBranchTransfer.ListAsDataTable(iID);
            BranchTransferItem clsBranchTransferItem = new BranchTransferItem(clsBranchTransfer.Connection, clsBranchTransfer.Transaction);
            System.Data.DataTable dtitems = clsBranchTransferItem.ListAsDataTable(iID);
            clsBranchTransfer.CommitAndDispose();

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

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

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

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

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

                rptds.BranchTransferItems.Rows.Add(drNew);
			}
            
			Report.SetDataSource(rptds); 
			SetParameters(Report);
		}
예제 #2
0
		private void LoadList()
		{	
			BranchTransfer clsBranchTransfer = new BranchTransfer();
			DataClass clsDataClass = new DataClass();
			Common Common = new Common();

			string SortField = "BranchTransferID";
			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 { }

            BranchTransferDetails searchKey = new BranchTransferDetails();
            searchKey.BranchTransferNo = txtSearch.Text;

            BranchTransferStatus status = (BranchTransferStatus)Enum.Parse(typeof(BranchTransferStatus), cboStatus.SelectedItem.Value);
            PageData.DataSource = clsBranchTransfer.ListAsDataTable(0, 0, searchKey, status, dteTransferStartDate, dteTransferEndDate, dtePostingStartDate, dtePostingEndDate, null, null, SortField, sortoption).DefaultView; 
            clsBranchTransfer.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;
		}