Exemplo n.º 1
0
        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.ckCheckDate.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();
                string FollowupDate = "";
                if (this.ckCheckDate.Checked)
                {
                    DateTime time1 = Convert.ToDateTime(this.dtpSt.Value.Date.ToString("yyyy-MM-dd"));
                    DateTime time2 = Convert.ToDateTime("2017-06-01");
                    if (DateTime.Compare(time1, time2) > 0)//选择日期大于2017-06-01
                    {
                        FollowupDate = string.Format("  between '{0}' and '{1}' ", "2017-10-01", this.dtpEd.Value.Date.ToString("yyyy-MM-dd"));
                    }
                    else
                    {
                        FollowupDate = string.Format("  between '{0}' and '{1}' ", this.dtpSt.Value.Date.ToString("yyyy-MM-dd"), this.dtpEd.Value.Date.ToString("yyyy-MM-dd"));
                    }
                }
                if (string.IsNullOrEmpty(where) && string.IsNullOrEmpty(FollowupDate))
                {
                    MessageBox.Show("请选择查询条件!", "查询条件", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    this.btnQuery.Enabled = false;
                    RecordsBaseInfoBLL archive_baseinfo = new RecordsBaseInfoBLL();
                    DataSet            ds = archive_baseinfo.GetTenVisitRecordCount(where, FollowupDate, "");

                    if (ds.Tables.Count > 0)
                    {
                        dtTmp = ds.Tables[0];
                    }
                    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(ds.Tables[0].Rows[i]);
                        }

                        this.bds.DataSource     = dtTemp;
                        this.dgvData.DataSource = this.bds;
                    }

                    lblOldManCount.Text = archive_baseinfo.GetTenOLDVisitCount(where, FollowupDate) + " 人";
                    lblHypCount.Text    = archive_baseinfo.GetTenHyperVisitCount(where, FollowupDate) + " 人";
                    lblDiaCount.Text    = archive_baseinfo.GetTenDiaVisitCount(where, FollowupDate) + " 人";
                    lblPsyCount.Text    = archive_baseinfo.GetTenMentalVisitCount(where, FollowupDate) + " 人";
                    lblTbCount.Text     = archive_baseinfo.GetTenLungerVisitCount(where, FollowupDate) + " 人";
                    lblNczCount.Text    = archive_baseinfo.GetTenStrokeVisitCount(where, FollowupDate) + " 人";
                    lblHeaCount.Text    = archive_baseinfo.GetTenChdVisitCount(where, FollowupDate) + " 人";

                    this.groupBox1.Enabled = false;
                    this.btnQuery.Enabled  = true;
                    this.btnQuery.Text     = "重置条件";
                }
            }
        }