Ejemplo n.º 1
0
        private void tlBtnFind_Click(object sender, EventArgs e)
        {
            if (tlCmbBasicDataType.Text.Trim() == string.Empty)
            {
                MessageBox.Show("查询类别不能为空!", "错误提示!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tlCmbBasicDataType.Focus();
                return;
            }
            else
            {
                if (tlTxtFindBasicData.Text.Trim() == string.Empty)
                {
                    dgvBasicDataList.DataSource = baseinfo.GetAllBasicData("BasicData").Tables[0].DefaultView;
                    this.SetdgvBasicDataListHeadText();
                    return;
                }
            }
            DataSet ds = null;                   //创建DataSet对象

            if (tlCmbBasicDataType.Text == "ID") //按编号查询
            {
                BasicDatainfo.id = tlTxtFindBasicData.Text;
                ds = baseinfo.FindBasicDataByID(BasicDatainfo, "BasicData");
                dgvBasicDataList.DataSource = ds.Tables[0].DefaultView;
            }
            else if (tlCmbBasicDataType.Text == "性别")
            {
                                                      //按性别查询
                {
                    BasicDatainfo.sex = tlTxtFindBasicData.Text;
                    ds = baseinfo.FindBasicDataBySex(BasicDatainfo, "BasicData");
                    dgvBasicDataList.DataSource = ds.Tables[0].DefaultView;
                }
            }
            else if (tlCmbBasicDataType.Text == "年龄")
            {
                                                      //按年龄查询
                {
                    BasicDatainfo.age = tlTxtFindBasicData.Text;
                    ds = baseinfo.FindBasicDataByAge(BasicDatainfo, "BasicData");
                    dgvBasicDataList.DataSource = ds.Tables[0].DefaultView;
                }
            }
            else if (tlCmbBasicDataType.Text == "身高")
            {
                                                      //按身高查询
                {
                    BasicDatainfo.bodyhigh = tlTxtFindBasicData.Text;
                    ds = baseinfo.FindBasicDataByBodyHigh(BasicDatainfo, "BasicData");
                    dgvBasicDataList.DataSource = ds.Tables[0].DefaultView;
                }
            }
            else
            {
                BasicDatainfo.idcard = tlTxtFindBasicData.Text;
                ds = baseinfo.FindBasicDataByIDCard(BasicDatainfo, "BasicData");
                dgvBasicDataList.DataSource = ds.Tables[0].DefaultView;
            }
            this.SetdgvBasicDataListHeadText();
        }