private void btnQuery_Click(object sender, EventArgs e) { if (this.btnQuery.Text == "重置条件") { this.groupBox1.Enabled = true; this.btnQuery.Text = "查询"; txtIdNum.Text = ""; tbAddr.Text = ""; dtpSt.Text = ""; dtpEd.Text = ""; dtpCreatedDateSt.Text = ""; dtpCreatedDateEd.Text = ""; } else if (this.ckBirthday.Checked && (this.dtpSt.Value.Date > this.dtpEd.Value.Date)) { MessageBox.Show(" 出生日期:开始日期大于结束日期!", "日期错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (this.ckxCreatedDate.Checked && (this.dtpCreatedDateSt.Value.Date > this.dtpCreatedDateEd.Value.Date)) { MessageBox.Show(" 建档日期:开始日期大于结束日期!", "日期错误", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { string where = this.GetWhere(); RecordsBaseInfoBLL archive_baseinfo = new RecordsBaseInfoBLL(); DataSet ds = archive_baseinfo.GetListDT(where, ""); DataTable dtF = new DataTable(); if (ds.Tables.Count > 0) { this.TransDs(ds); dtF = ds.Tables[0]; dtTmp = SetDate(dtF); //this.bds.DataSource = dtTmp; //this.dgvData.DataSource = this.bds; } this.totalCount = dtTmp.Rows.Count; this.totalPages = (this.totalCount <= this.pageCount) ? 1 : ((this.totalCount / this.pageCount) + (((this.totalCount % this.pageCount) > 0) ? 1 : 0)); this.currentPage = 0; this.lbTotalCount.Text = string.Format("共计{0}条", this.totalCount.ToString()); this.lbPages.Text = string.Format("{0}/{1}页", this.currentPage + 1, this.totalPages); if (ds.Tables.Count > 0) { DataTable dtTemp = dtTmp.Clone(); int nextV = (this.currentPage + 1) * this.pageCount; if (nextV > this.totalCount) { nextV = this.totalCount; } for (int i = (this.currentPage) * this.pageCount; i < nextV; i++) { dtTemp.ImportRow(dtTmp.Rows[i]); } this.bds.DataSource = dtTemp; this.dgvData.DataSource = this.bds; } this.groupBox1.Enabled = false; this.btnQuery.Text = "重置条件"; } }
/// <summary> /// 检核栏位输入 /// </summary> private void ChackDate() { string where = this.GetWhere(); if (string.IsNullOrEmpty(where)) { MessageBox.Show("请选择查询条件!", "查询条件", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { this.btnQuery.Enabled = false; RecordsBaseInfoBLL archive_baseinfo = new RecordsBaseInfoBLL(); DataSet ds = archive_baseinfo.GetListDT(where, ""); if (ds.Tables.Count > 0) { dtTmp = this.TransDs(ds); } this.totalCount = dtTmp.Rows.Count; this.totalPages = (this.totalCount <= this.pageCount) ? 1 : ((this.totalCount / this.pageCount) + (((this.totalCount % this.pageCount) > 0) ? 1 : 0)); if (this.currentPage > totalPages - 1) { this.currentPage--; } this.lbTotalCount.Text = string.Format("共计{0}条", this.totalCount.ToString()); this.lbPages.Text = string.Format("{0}/{1}页", this.currentPage + 1, this.totalPages); if (ds.Tables.Count > 0) { DataTable dtTemp = dtTmp.Clone(); int nextV = (this.currentPage + 1) * this.pageCount; if (nextV > this.totalCount) { nextV = this.totalCount; } for (int i = (this.currentPage) * this.pageCount; i < nextV; i++) { dtTemp.ImportRow(dtTmp.Rows[i]); } this.bds.DataSource = dtTemp; this.dgvData.DataSource = this.bds; } this.groupBox1.Enabled = false; this.btnQuery.Enabled = true; this.btnQuery.Text = "重置条件"; } }