| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 723 人关注过本帖
标题:将数据保存到本地后如何分页?
只看楼主 加入收藏
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:2 
将数据保存到本地后如何分页?
图片附件: 游客没有浏览图片的权限,请 登录注册

程序代码:
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 编辑 ]
搜索更多相关主题的帖子: 数据 保存 
2010-11-24 08:27
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
收藏
得分:7 
能说的详细一点吗?!?
2010-11-24 09:03
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
收藏
得分:0 
就是当窗体第一次加载的时候获取远程数据保存到PKdata后,以后的分页数据都是在PKdata里面进行,如何实现
2010-11-24 09:07
快速回复:将数据保存到本地后如何分页?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059916 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved