예제 #1
0
 void fill_grades()
 {
     cbLevel.Items.Clear();
     for (int i = 1; i <= 12; i++)
     {
         cbitem k = new cbitem();
         k.Value = i;
         k.Text  = i.ToString();
         cbLevel.Items.Add(k);
     }
     cbLevel.SelectedIndex = 0;
 }
예제 #2
0
 void fill_scheds()
 {
     cbSchedule.Items.Clear();
     if (Program.dataSource == Program.DataSources.Access)
     {
         try
         {
             dbcmd.CommandText = "select scheduleid, quickdescription from schedules order by scheduleid";
             dbr = dbcmd.ExecuteReader();
             while (dbr.Read())
             {
                 cbitem k;
                 k       = new cbitem();
                 k.Value = getLong("scheduleid");
                 k.Text  = getString("quickdescription");
                 cbSchedule.Items.Add(k);
             }
             cbSchedule.SelectedIndex = 0;
             dbr.Close();
         }
         catch (Exception ie)
         {
             MessageBox.Show(ie.Message + ie.StackTrace);
             this.Close();
         }
     }
     else
     {
         try
         {
             Odbcmd.CommandText = "select scheduleid, quickdescription from schedules order by scheduleid";
             Odbr = Odbcmd.ExecuteReader();
             while (Odbr.Read())
             {
                 cbitem k;
                 k       = new cbitem();
                 k.Value = getLong("scheduleid");
                 k.Text  = getString("quickdescription");
                 cbSchedule.Items.Add(k);
             }
             cbSchedule.SelectedIndex = 0;
             Odbr.Close();
         }
         catch (Exception ie)
         {
             MessageBox.Show(ie.Message + ie.StackTrace);
             this.Close();
         }
     }
 }
예제 #3
0
 void fill_cb(ref ComboBox cb, string table, string columnindex, string columnname)
 {
     cb.Items.Clear();
     if (Program.dataSource == Program.DataSources.Access)
     {
         try
         {
             dbcmd.CommandText = "select * from " + table + " order by " + columnname;
             dbr = dbcmd.ExecuteReader();
             while (dbr.Read())
             {
                 cbitem c = new cbitem();
                 c.Text  = getString(columnname);
                 c.Value = (int)getLong(columnindex);
                 cb.Items.Add(c);
             }
             cb.SelectedIndex = 0;
             dbr.Close();
         }
         catch (Exception ie)
         {
             MessageBox.Show(ie.Message);
             this.Close();
         }
     }
     else
     {
         try
         {
             Odbcmd.CommandText = "select * from " + table + " order by " + columnname;
             Odbr = Odbcmd.ExecuteReader();
             while (Odbr.Read())
             {
                 cbitem c = new cbitem();
                 c.Text  = getString(columnname);
                 c.Value = (int)getLong(columnindex);
                 cb.Items.Add(c);
             }
             cb.SelectedIndex = 0;
             Odbr.Close();
         }
         catch (Exception ie)
         {
             MessageBox.Show(ie.Message);
             this.Close();
         }
     }
 }