Пример #1
0
 private void addUser_Load(object sender, EventArgs e)
 {
     List<item> items = new List<item>();
      MySqlDataReader sdr;
      sdr = db.GetDataReader("SELECT district.`name`,district.`id` FROM district");
     while (sdr.Read())
     {
         item it = new item(sdr[0].ToString(), sdr[1].ToString());
         items.Add(it);
     }
     cb_district.DataSource = items;
      //   items.Clear();
     sdr.Close();
     sdr = db.GetDataReader("SELECT 	grid.`name`,grid.id FROM district INNER JOIN grid ON grid.district = district.id WHERE district.id = 1");
     while (sdr.Read())
     {
         item it = new item(sdr[0].ToString(), sdr[1].ToString());
         items.Add(it);
     }
     cb_grid.DataSource = items;
       //  items.Clear();
     sdr.Close();
     sdr = db.GetDataReader("SELECT 	block.`name`,block.id FROM grid INNER JOIN block ON block.grid = grid.id WHERE grid.id = 1");
     while (sdr.Read())
     {
         item it = new item(sdr[0].ToString(), sdr[1].ToString());
         items.Add(it);
     }
     cb_block.DataSource = items;
       //  items.Clear();
     sdr.Close();
 }
Пример #2
0
 private void cb_district_SelectionChangeCommitted(object sender, EventArgs e)
 {
     string index = null;
     List<item> items = new List<item>();
     MySqlDataReader sdr;
     item it = (item)cb_district.SelectedItem;
     index = it.Value;
     sdr = db.GetDataReader("SELECT 	grid.`name`,grid.id FROM district INNER JOIN grid ON grid.district = district.id WHERE district.id = " + index);
     while (sdr.Read())
     {
         item its = new item(sdr[0].ToString(), sdr[1].ToString());
         items.Add(its);
     }
     sdr.Close();
     cb_grid.DataSource = items;
        // cb_district.Text = sdr[0].ToString();
        // items.Clear();
 }