예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dt = SQLTools.getDT("select distinct(provinceName) from Data_Province");

            SQLTools.addBOX(comboBox1, dt, "provinceName");
            comboBox1.Text = dt.Rows[0][0].ToString();
        }
예제 #2
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox3.Items.Count != 0)
            {
                comboBox3.Items.Clear();
            }
            DataTable dtTemp = SQLTools.getDT("select CityCode,CityName from Data_City where CityName='" + comboBox2.SelectedItem + "'");
            DataTable dt     = SQLTools.getDT("select distinct(AreaName) from Data_Area where CityCode='" + dtTemp.Rows[0]["CityCode"] + "'");

            SQLTools.addBOX(comboBox3, dt, "AreaName");
            comboBox3.Text = dt.Rows[0][0].ToString();
        }
예제 #3
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //判断数据表是否为空,如果不为空则置为null
            if (dataGridView1.Rows.Count != 0)
            {
                dataGridView1.DataSource = null;
            }
            DataTable dtTemp = SQLTools.getDT("select provinceCode,provinceName from Data_Province where provinceName='" + comboBox1.SelectedItem + "'");
            DataTable dt     = SQLTools.getDT("select * from Data_City where ProvinceCode='" + dtTemp.Rows[0]["provinceCode"] + "'");

            dataGridView1.DataSource = dt;
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("先选择省份");
                return;
            }
            string    temp   = textBox1.Text;
            DataTable dtTemp = SQLTools.getDT("select provinceCode,provinceName from Data_Province where provinceName='" + comboBox1.SelectedItem + "'");
            DataTable dt     = SQLTools.getDT("select * from Data_City where ProvinceCode='" + dtTemp.Rows[0]["provinceCode"] + "' and CityName like '%" + temp + "%'");

            dataGridView1.DataSource = dt;
        }
예제 #5
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //判断选择框是否有内容,如果有则清除
            if (comboBox2.Items.Count != 0)
            {
                comboBox2.Items.Clear();
            }
            DataTable dtTemp = SQLTools.getDT("select provinceCode,provinceName from Data_Province where provinceName='" + comboBox1.SelectedItem + "'");
            //MessageBox.Show(dtTemp.Rows[0]["provinceCode"].ToString());
            DataTable dt = SQLTools.getDT("select distinct(CityName) from Data_City where ProvinceCode='" + dtTemp.Rows[0]["provinceCode"] + "'");

            SQLTools.addBOX(comboBox2, dt, "CityName");
            comboBox2.Text = dt.Rows[0][0].ToString();
        }
예제 #6
0
        private void Form2_Load(object sender, EventArgs e)
        {
            DataTable dt = SQLTools.getDT("select distinct(provinceName) from Data_Province");

            SQLTools.addBOX(comboBox1, dt, "provinceName");
        }