コード例 #1
0
        private void label3_Click(object sender, EventArgs e)
        {
            Mu mu = new Mu(prof_id, ip, db, user, pass);

            if (ini.FormOpened(mu))
            {
                Application.OpenForms[mu.Name].Focus();
            }
            else
            {
                mu.Show();
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem == null)
            {
                MessageBox.Show("Вы не заполнили поле \"Дисциплина\"!");
                return;
            }
            string course_name = comboBox1.SelectedItem.ToString();

            if (comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Вы не заполнили поле \"Группа\"!");
                return;
            }
            string group_name = comboBox2.SelectedItem.ToString();

            if (comboBox3.SelectedItem == null)
            {
                MessageBox.Show("Вы не заполнили поле \"Тип занятия\"!");
                return;
            }
            string cl_type = comboBox3.SelectedItem.ToString();

            if (textBox1.Text == "")
            {
                MessageBox.Show("Вы не заполнили поле \"Номер занятия\"!");
                return;
            }
            int cl_id = Convert.ToInt32(textBox1.Text);

            string          comment   = textBox2.Text;
            string          link      = textBox3.Text;
            DB_connect      con2      = new DB_connect(ip, db, user, pass);
            MySqlDataReader reader2   = con2.GetDBData("select * from course where name='" + course_name + "';");
            int             course_id = 0;

            if (reader2.Read())
            {
                course_id = Convert.ToInt32(reader2["id"]);
            }
            reader2.Close();
            reader2 = con2.GetDBData("select * from classes where id='" + cl_id + "' and course_id='" + course_id + "';");
            if (reader2.Read())
            {
                DB_connect      con3 = new DB_connect(ip, db, user, pass);
                MySqlDataReader reader3;
                if (id == 0)
                {
                    reader3 = con3.GetDBData("insert into mu (classes_id, course_id, prof_id, comment, link, date) values ('" + cl_id + "', '" + course_id + "', '" + prof_id + "', '" + comment + "', '" + link + "', '" + String.Format("{0:yyyy-MM-dd}", DateTime.Today) + "');");
                    while (reader3.Read())
                    {
                    }
                    MessageBox.Show("МУ успешно добавлено!", "Успех!");
                }
                else
                {
                    reader3 = con3.GetDBData("update mu set comment='" + comment + "', link='" + link + "' where id='" + id + "';");
                    while (reader3.Read())
                    {
                    }
                    MessageBox.Show("МУ успешно обновлено!", "Успех!");
                }
                this.Close();
                Mu mu = Application.OpenForms["Mu"] as Mu;
                mu.UpdMu();
            }
            else
            {
                MessageBox.Show("Такого урока не существует!", "Ошибка.");
            }
        }