将数据保存到本地后如何分页?
程序代码:
using System; using System.Collections.Generic; using using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using CN56NET.PublicClass; using CN56NET.LPP.Members.DataModel; namespace CN56NET.LPP.Members.WindowsForm { public partial class PackageSpecificationsList : Form { public PackageSpecificationsList() { InitializeComponent(); } private void PackageSpecificationsList_Load(object sender, EventArgs e) { GetPackageSpecificationsList(int.Parse(Txt_PageNo.Text.Trim())); } CN56NET.LPP.Members.DataModel.PackageSpecificationsData pkData = new CN56NET.LPP.Members.DataModel.PackageSpecificationsData(); /// <summary> /// 当前页 /// </summary> /// <param name="PageNo"></param> private void GetPackageSpecificationsList(int PageNo) { int RecordCounts = 0; int PageCounts = 0; int PageSize = 5; //CN56NET.LPP.Members.DataModel.PackageSpecificationsData pkData = new CN56NET.LPP.Members.DataModel.PackageSpecificationsData(); ExecObj ordExecObj = CN56NET.LPP.Members.GetBusiness.InitClass.GetMembersPackageSpecificationsSystem(PubWinClass.MembersRemotingSite).GetPackageSpecificationsByPageList(ref pkData, PubWinClass.ConnObj, ref RecordCounts, ref PageCounts, PageNo, PageSize, Txt_KeyWork.Text.Trim()); for (int i = 0; i < ordData.Tables[0].Rows.Count; i++) { if (pkData.Tables[0].Rows[i]["PackageType"].ToString() == "1") { pkData.Tables[0].Rows[i]["PackageTypeChinese"] = "自有包装"; } else { pkData.Tables[0].Rows[i]["PackageTypeChinese"] = "协同包装"; } pkData.Tables[0].Rows[i]["PackageStateChinese"] = PubEnumName.GetMemberStateName(int.Parse(pkData.Tables[0].Rows[i]["PackageState"].ToString())); } //if (ordExecObj.ExecFlag) //{ bindingSource1.DataSource = pkData.Tables[0]; Dtv_PackageSpecificationsList.AutoGenerateColumns = false; Dtv_PackageSpecificationsList.DataSource = pkData.Tables[0]; Lbl_PageCounts.Text = PageCounts.ToString(); Lbl_RecordCounts.Text = RecordCounts.ToString(); //} } private void Btn_First_Click(object sender, EventArgs e) { GetPackageSpecificationsList(1); Dtv_PackageSpecificationsList.ClearSelection(); Txt_PageNo.Text = "1"; } private void Btn_Up_Click(object sender, EventArgs e) { if (int.Parse(Txt_PageNo.Text.Trim()) <= int.Parse(Lbl_PageCounts.Text) && Txt_PageNo.Text.Trim() != "1") { int pageno = int.Parse(Txt_PageNo.Text.Trim()) - 1; Txt_PageNo.Text = pageno.ToString(); GetPackageSpecificationsList(pageno); Dtv_PackageSpecificationsList.ClearSelection(); } } private void Btn_Next_Click(object sender, EventArgs e) { if (int.Parse(Txt_PageNo.Text.Trim()) < int.Parse(Lbl_PageCounts.Text)) { int pageno = int.Parse(Txt_PageNo.Text.Trim()) + 1; Txt_PageNo.Text = pageno.ToString(); GetPackageSpecificationsList(pageno); Dtv_PackageSpecificationsList.ClearSelection(); } } private void Btn_Last_Click(object sender, EventArgs e) { GetPackageSpecificationsList(int.Parse(Lbl_PageCounts.Text.Trim())); Dtv_PackageSpecificationsList.ClearSelection(); Txt_PageNo.Text = Lbl_PageCounts.Text.Trim(); } private void Btn_Search_Click(object sender, EventArgs e) { //string rowfilter = "PackageCode like '%" + Txt_KeyWork.Text.Trim() + "%' Or PackageName like '%" + Txt_KeyWork.Text.Trim() + "%'"; //pkData.Tables[0].DefaultView.RowFilter = rowfilter; //dataGridView1.DataSource = OrderDS.Tables[0].DefaultView; GetPackageSpecificationsList(1); Dtv_PackageSpecificationsList.ClearSelection(); Txt_PageNo.Text = "1"; } private void Btn_Add_Click(object sender, EventArgs e) { PackageSpecificationsAdd pckadd = new PackageSpecificationsAdd(); pckadd.ShowDialog(); } public static string PackCode = ""; private void Btn_Update_Click(object sender, EventArgs e) { if (Dtv_PackageSpecificationsList.SelectedRows.Count > 0) { PackCode = Dtv_PackageSpecificationsList.SelectedRows[0].Cells["Column2"].Value.ToString(); PackageSpecificationsEdit pckedit = new PackageSpecificationsEdit(); pckedit.ShowDialog(); } } private void Dtv_PackageSpecificationsList_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (Dtv_PackageSpecificationsList.SelectedRows.Count > 0) { PackCode = Dtv_PackageSpecificationsList.SelectedRows[0].Cells["Column2"].Value.ToString(); PackageSpecificationsInfo pckinfo = new PackageSpecificationsInfo(); pckinfo.ShowDialog(); } } private void PackageSpecificationsList_Activated(object sender, EventArgs e) { GetPackageSpecificationsList(int.Parse(Txt_PageNo.Text.Trim())); Dtv_PackageSpecificationsList.ClearSelection(); } } }将窗体第一次加载的时候保存过来的PKdata后,实现分页,也就是Pkdata里面的数据进行分页,而不是再次读远程服务器打交道分页,不知道分页里面的第一页,上一页,下一页 最后页的代码怎么写?
[ 本帖最后由 等待冰柠檬 于 2010-11-24 08:35 编辑 ]