Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!(comboBox1.SelectedItem == null) && !(comboBox2.SelectedItem == null))
     {
         string group_name = comboBox1.SelectedItem.ToString();
         reader = con.GetDBData("select * from course where name='" + comboBox2.SelectedItem.ToString() + "';");
         reader.Read();
         int course_id = Convert.ToInt32(reader["id"]);
         reader.Close();
         ini_func ini = new ini_func();
         Progress pr  = new Progress(group_name, course_id, ip, db, user, pass);
         this.Close();
         if (ini.FormOpened(pr))
         {
             Application.OpenForms[pr.Name].Focus();
         }
         else
         {
             pr.Show();
         }
     }
     else
     {
         MessageBox.Show("Не выбрана группа или дисциплина!", "Ошибка");
     }
 }
        private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewCell cell = dataGridView1.CurrentCell;

            if (!(cell.Value == null) && !(cell.Value.ToString() == "") && (cell.ColumnIndex > 0))
            {
                //MessageBox.Show(cell.Value.ToString());
                String[] stroke = cell.Value.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                // stroke[0] = дисциплина, stroke[1] = группа
                string          group_name  = stroke[1];
                string          course_name = stroke[0];
                ini_func        ini         = new ini_func();
                DB_connect      connection  = new DB_connect(ip, db, user, pass);
                MySqlDataReader reader      = connection.GetDBData("select * from course where name='" + course_name + "';");
                int             course_id   = 0;
                if (reader.Read())
                {
                    course_id = Convert.ToInt32(reader["id"]);
                }
                reader.Close();
                if (!(group_name == "") && !(course_id == 0))
                {
                    Progress pr = new Progress(group_name, course_id, ip, db, user, pass);
                    if (ini.FormOpened(pr))
                    {
                        Application.OpenForms[pr.Name].Focus();
                    }
                    else
                    {
                        pr.Show();
                    }
                }
            }
        }