private void BindGrid() { String sql = "SELECT * from MatchList where Ischecked<>'N' and Isapproved1=true and Isapproved2=true order by Matchdate "; OleDbCommand cmd = new OleDbCommand(sql); DataSet ds = SQLUtil.QueryDS(cmd); DataTable dtOrder = ds.Tables[0]; List <Match> li = GetList(ds); //先找出IEnumerable所有(該公司及分及司) 的送出訂單而且沒有建立收款單的 照duedate排序 //System.Collections.Generic.IEnumerable<DataRow> queryOrder = //from Order in dtOrder.AsEnumerable() //select Order; //IList lists = mgr.getMatchListForManager(); PagedDataSource pgitems = new PagedDataSource(); pgitems.DataSource = li; pgitems.AllowPaging = true; pgitems.PageSize = 10; pgitems.CurrentPageIndex = PageNumber; if (pgitems.PageCount > 1) { rptPages.Visible = true; ArrayList pages = new ArrayList(); for (int i = 0; i < pgitems.PageCount; i++) { pages.Add((i + 1).ToString()); } rptPages.DataSource = pages; rptPages.DataBind(); } else { rptPages.Visible = false; } //MatchGrid.DataSource = pgitems; MatchGrid.DataSource = dtOrder; MatchGrid.DataBind(); if (MatchGrid.Items.Count > 0) { Panel1.Visible = false; } else { Panel1.Visible = true; } pageNow.Text = (PageNumber + 1).ToString(); pageTotal.Text = pgitems.PageCount.ToString(); cntTotal.Text = ds.Tables[0].Rows.Count.ToString(); }
private void BindGrid() { //IList lists = mgr.getMatchListForUser2(User.Identity.Name); String sql = " select * from MatchList where Username2=@Username2 and Ischecked='Y' and Isconfirm2<>'N' order by Matchdate "; OleDbCommand cmd = new OleDbCommand(sql); cmd.Parameters.Add("@Username2", OleDbType.VarChar).Value = User.Identity.Name; cmd.CommandType = CommandType.Text; DataSet ds = SQLUtil.QueryDS(cmd); List <Match> lists = GetList(ds); PagedDataSource pgitems = new PagedDataSource(); pgitems.DataSource = lists; pgitems.AllowPaging = true; pgitems.PageSize = 10; pgitems.CurrentPageIndex = PageNumber; if (pgitems.PageCount > 1) { rptPages.Visible = true; ArrayList pages = new ArrayList(); for (int i = 0; i < pgitems.PageCount; i++) { pages.Add((i + 1).ToString()); } rptPages.DataSource = pages; rptPages.DataBind(); } else { rptPages.Visible = false; } if (lists != null) { MatchGrid.DataSource = pgitems; MatchGrid.DataBind(); } else { MatchGrid.DataSource = null; MatchGrid.DataBind(); } if (MatchGrid.Items.Count > 0) { Panel1.Visible = false; Panel2.Visible = true; } else { Panel1.Visible = true; Panel2.Visible = false; } pageNow.Text = (PageNumber + 1).ToString(); pageTotal.Text = pgitems.PageCount.ToString(); if (lists != null) { cntTotal.Text = lists.Count.ToString(); } else { cntTotal.Text = "0"; } }