Ejemplo n.º 1
0
        /// <summary>
        /// 尾页按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_last_page_Click(object sender, EventArgs e)
        {
            pageIndex = pageCount;

            AccessDB  adb = new AccessDB();
            DataTable dt  = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum);

            dgv.DataSource          = dt;
            textBox_page_index.Text = pageIndex.ToString();
            label_current_page.Text = pageIndex.ToString() + "/" + pageCount.ToString();
            label_record_sum.Text   = recordSum.ToString();
        }
Ejemplo n.º 2
0
        private void comboBox_recordsPerPage_SelectedIndexChanged(object sender, EventArgs e)
        {
            pageIndex = 1;
            pageSize  = int.Parse(comboBox_recordsPerPage.SelectedItem.ToString());

            AccessDB adb = new AccessDB();
            //执行查询第一页,默认页面容量为选择页面容量
            DataTable dt = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum);

            dgv.DataSource          = dt;
            label_current_page.Text = "1/" + pageCount.ToString();
            label_record_sum.Text   = recordSum.ToString();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 跳转按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_goToPage_Click(object sender, EventArgs e)
        {
            pageIndex = int.Parse(textBox_page_index.Text);

            if (pageIndex > pageCount)
            {
                MessageBox.Show("页码大于总页数!", "错误");
                return;
            }

            AccessDB  adb = new AccessDB();
            DataTable dt  = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum);

            dgv.DataSource          = dt;
            textBox_page_index.Text = pageIndex.ToString();
            label_current_page.Text = pageIndex.ToString() + "/" + pageCount.ToString();
            label_record_sum.Text   = recordSum.ToString();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 刷新对应的dataGridView并展示第一页
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="sql"></param>
        public void refreshDataGirdViewBySQL(DataGridView dgv)
        {
            showString = "";

            for (int i = 0; i < dgv.Columns.Count; i++)
            {
                if (dgv.Columns[i] is DataGridViewTextBoxColumn)
                {
                    showString += dgv.Columns[i].DataPropertyName + ",";
                }
            }
            showString = showString.Substring(0, showString.Length - 1) + " ";


            AccessDB adb = new AccessDB();
            //执行查询第一页,默认页面容量为10
            DataTable dt = adb.ExecutePager(pageIndex, pageSize, keyString, showString, queryString, whereString, orderString, out pageCount, out recordSum);

            dgv.DataSource          = dt;
            label_current_page.Text = "1/" + pageCount.ToString();
            label_record_sum.Text   = recordSum.ToString();
        }