//单表数据分页 public void LoadOneTablePageData() { if (this.PicShow != null) { DataTable dtData; //显示gif图片 this.Dgv.Rows.Clear(); this.PicShow.Show(); this.Thread = new Thread(() => { try { //模态 Thread.Sleep(1500); dtData = this.Func(); this.TotalRecords = this.FuncNums(); this.Dgv.BeginInvoke(new SetDgv(dtinfo => DataGridViewHelper.InsertDataToDgv(dtData, this.Dgv, this.IndexColumn)), dtData); //展示分页信息 this.Txb_pageIndex.Text = this.PageIndex.ToString(); this.PageCount = (this.TotalRecords % this.PageSize) > 0 ? ((this.TotalRecords / this.PageSize) + 1) : (this.TotalRecords / this.PageSize); this.Lbl_infos1.Text = "每页" + this.PageSize + "个"; this.Lbl_infos2.Text = this.PageIndex + "/" + this.PageCount + " " + "共" + this.TotalRecords + "个记录"; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } finally { this.Action(); this.HidePic(); if (this.Thread != null) { if (this.Thread.IsAlive) { //this.Thread.Abort(); } } } }); this.Thread.Start(); this.Thread.IsBackground = true; } else { DataTable dtData = this.Func(); //tbll.GetAllTSources(filedOutPut, filedWhere, filedOrder, order, ((_pageIndex - 1) * _pageSize) + "," + _pageSize); //dtData = _func(); //插入到dgv中 DataGridViewHelper.InsertDataToDgv(dtData, this.Dgv, this.IndexColumn); //展示分页信息 this.Txb_pageIndex.Text = this.PageIndex.ToString(); this.TotalRecords = this.FuncNums(); this.PageCount = (this.TotalRecords % this.PageSize) > 0 ? ((this.TotalRecords / this.PageSize) + 1) : (this.TotalRecords / this.PageSize); this.Lbl_infos1.Text = "每页" + this.PageSize + "个"; this.Lbl_infos2.Text = this.PageIndex + "/" + this.PageCount + " " + "共" + this.TotalRecords + "个记录"; } }
//loadData private void LoadData() { try { List <RegularProductInfo> productInfos = this.jymService.GetAllProductInfo().Result; //100000010 100000020 DataTable dtDgv = new DataTable(); dtDgv.Columns.Add(new DataColumn("productCatorgary", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("ProductId", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("FinancingSumAmount", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("paidAmount", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("UnitPrise", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("yield", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("period", Type.GetType("System.String"))); dtDgv.Columns.Add(new DataColumn("leftCount", Type.GetType("System.String"))); foreach (RegularProductInfo t in productInfos) { DataRow dr = dtDgv.NewRow(); dr[0] = t.ProductCategory == 100000010 ? "商票" : "银票"; dr[1] = t.ProductId.ToString().Replace("-", "").ToUpper(); dr[2] = t.FinancingSumAmount.ToString(); dr[3] = t.PaidAmount; dr[4] = t.UnitPrice; dr[5] = (t.Yield * 1.0 / 100).ToString(CultureInfo.InvariantCulture); dr[6] = t.Period.ToString(); dr[7] = (t.FinancingSumAmount - t.PaidAmount) / t.UnitPrice; //int index = this.dgv_Data.Rows.Add() //DataGridViewRow dr = this.dgv_Data.Rows[index]; dtDgv.Rows.Add(dr); } DataGridViewHelper.InsertDataToDgv(dtDgv, this.dgv_Data, new List <int> { 2, 3, 4, 5 }); } catch (Exception e) { MessageBox.Show("没有可以投资的标的,请让夏敏上一下"); } }