Ejemplo n.º 1
0
        public void UpdMu()
        {
            reader = connection.GetDBData("select * from mu where prof_id='" + prof_id.ToString() + "';");
            int i = 0;

            while (reader.Read())
            {
                string          comment    = reader["comment"].ToString();
                int             course_id  = Convert.ToInt32(reader["course_id"]);
                int             classes_id = Convert.ToInt32(reader["classes_id"]);
                string[]        stroke     = reader["date"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string          link       = reader["link"].ToString();
                DB_connect      cn         = new DB_connect(ip, db, user, pass);
                MySqlDataReader reader2    = cn.GetDBData("select * from course where id='" + course_id.ToString() + "';");
                reader2.Read();
                string name = reader2["name"].ToString();
                reader2.Close();
                reader2 = cn.GetDBData("select * from classes where id='" + classes_id + "';");
                reader2.Read();
                string   classes_type_name = reader2["classes_type_name"].ToString();
                string   num     = reader2["number"].ToString();
                string[] stroke2 = reader2["date"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                reader2.Close();
                reader2 = cn.GetDBData("select * from capacity where prof_id='" + prof_id + "' and course_id='" + course_id + "' and classes_id='" + classes_id + "';");
                string group_name = "";
                if (reader2.Read())
                {
                    group_name = reader2["groups_name"].ToString();
                }
                reader2.Close();
                dataGridView1.Rows.Add(name, group_name, classes_type_name, num, stroke2[0], comment, link, stroke[0]);
                dataGridView1.Rows[i].Height = 80;
                i++;
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int        k   = comboBox1.SelectedIndex;
            DB_connect con = new DB_connect(txt[k][1], txt[k][3], txt[k][4], txt[k][5]);

            if (con.CheckLogPass(textBox1.Text, textBox2.Text))
            {
                if (con.CheckRole(textBox1.Text) == "prof")
                {
                    this.Hide();
                    MainForm mf = new MainForm(textBox1.Text, txt[k][1], txt[k][3], txt[k][4], txt[k][5]);
                    mf.Show();
                }
                if (con.CheckRole(textBox1.Text) == "stud")
                {
                    this.Hide();
                    StudForm st = new StudForm(textBox1.Text, txt[k][1], txt[k][3], txt[k][4], txt[k][5]);
                    st.Show();
                }
            }
            else
            {
                MessageBox.Show("Неверные логин или пароль!");
            }
        }
Ejemplo n.º 3
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public StudForm(string login, string ip, string db, string user, string pass)
 {
     InitializeComponent();
     this.login = login;
     this.ip    = ip;
     this.db    = db;
     this.user  = user;
     this.pass  = pass;
     connection = new DB_connect(ip, db, user, pass);
 }
Ejemplo n.º 5
0
        private void Add_ad_Shown(object sender, EventArgs e)
        {
            DB_connect      con    = new DB_connect(ip, db, user, pass);
            MySqlDataReader reader = con.GetDBData("select * from capacity where prof_id='" + prof_id + "' group by groups_name;");

            while (reader.Read())
            {
                string group_name = reader["groups_name"].ToString();
                checkedListBox1.Items.Add(group_name);
            }
            reader.Close();
        }
Ejemplo n.º 6
0
 public MainForm(string login, string ip, string db, string user, string pass)
 {
     InitializeComponent();
     this.MaximizeBox     = false;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.login           = login;
     this.ip    = ip;
     this.db    = db;
     this.user  = user;
     this.pass  = pass;
     connection = new DB_connect(ip, db, user, pass);
     this.dataGridView1.CellClick += DataGridView1_CellClick;
 }
Ejemplo n.º 7
0
 public choose_pr(int prof_id, string ip, string db, string user, string pass)
 {
     InitializeComponent();
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.ip      = ip;
     this.db      = db;
     this.user    = user;
     this.pass    = pass;
     this.prof_id = prof_id;
     con          = new DB_connect(ip, db, user, pass);
 }
Ejemplo n.º 8
0
        public StudSched(string name, string group_name, string ip, string db, string user, string pass)
        {
            InitializeComponent();
            this.group_name = group_name;
            this.ip         = ip;
            this.db         = db;
            this.user       = user;
            this.pass       = pass;
            con             = new DB_connect(ip, db, user, pass);
            string today = DateTime.Today.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day;

            reader = con.GetDBData("select * from week where date_start<='" + today + "' and date_finish>='" + today + "';");
            reader.Read();
            week = Convert.ToInt32(reader["week_no"]);
            reader.Close();
        }
Ejemplo n.º 9
0
 public Progress(string groups_name, int course_id, string ip, string db, string user, string pass)
 {
     InitializeComponent();
     this.MaximizeBox     = false;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.groups_name     = groups_name;
     this.course_id       = course_id;
     this.ip   = ip;
     this.db   = db;
     this.user = user;
     this.pass = pass;
     con       = new DB_connect(ip, db, user, pass);
     this.listBox1.MouseDoubleClick += listBox1_MouseDoubleClick;
     this.dataGridView2.CellEndEdit += dataGridView2_labs;
     this.dataGridView3.CellEndEdit += dataGridView3_rk;
     this.dataGridView4.CellEndEdit += dataGridView4_dz;
 }
Ejemplo n.º 10
0
        public Prepsched(string login, string ip, string db, string user, string pass)
        {
            InitializeComponent();
            this.MaximizeBox     = false;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ip    = ip;
            this.db    = db;
            this.user  = user;
            this.pass  = pass;
            this.login = login;
            con        = new DB_connect(ip, db, user, pass);
            string today = DateTime.Today.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day;

            reader = con.GetDBData("select * from week where date_start<='" + today + "' and date_finish>='" + today + "';");
            reader.Read();
            week = Convert.ToInt32(reader["week_no"]);
            reader.Close();
            this.dataGridView1.CellClick += DataGridView1_CellClick;
        }
Ejemplo n.º 11
0
 public Ads(int prof_id, string ip, string db, string user, string pass)
 {
     InitializeComponent();
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.prof_id         = prof_id;
     this.ip      = ip;
     this.db      = db;
     this.user    = user;
     this.pass    = pass;
     this.prof_id = prof_id;
     con          = new DB_connect(ip, db, user, pass);
     reader       = con.GetDBData("select name from professor where id='" + prof_id + "';");
     reader.Read();
     prof_name = reader["name"].ToString();
     reader.Close();
     label1.Text = prof_name;
 }
Ejemplo n.º 12
0
 private void choose_pr_Load(object sender, EventArgs e)
 {
     reader = con.GetDBData("select * from capacity where prof_id='" + prof_id + "' group by groups_name;");
     while (reader.Read())
     {
         comboBox1.Items.Add(reader["groups_name"]);
     }
     reader.Close();
     reader = con.GetDBData("select * from capacity where prof_id='" + prof_id + "' group by course_id;");
     while (reader.Read())
     {
         int             id      = Convert.ToInt32(reader["course_id"]);
         DB_connect      con2    = new DB_connect(ip, db, user, pass);
         MySqlDataReader reader2 = con2.GetDBData("select * from course where id='" + id + "'");
         reader2.Read();
         comboBox2.Items.Add(reader2["name"]);
         reader2.Close();
     }
     reader.Close();
 }
Ejemplo n.º 13
0
        private void updMu()
        {
            reader = connection.GetDBData("select * from mu;");
            while (reader.Read())
            {
                int      course_id         = Convert.ToInt32(reader["course_id"]);
                int      classes_id        = Convert.ToInt32(reader["classes_id"]);
                int      prof_id           = Convert.ToInt32(reader["prof_id"]);
                string   comment           = reader["comment"].ToString();
                string   link              = reader["link"].ToString();
                DateTime dt                = DateTime.Parse(reader["date"].ToString());
                DateTime dt_cl             = new DateTime();
                string   crs_name          = "";
                string   prf_name          = "";
                string   classes_type_name = "";

                DB_connect      con     = new DB_connect(ip, db, user, pass);
                MySqlDataReader reader2 = con.GetDBData("select * from course where id='" + course_id + "';");
                if (reader2.Read())
                {
                    crs_name = reader2["name"].ToString();
                }
                reader2.Close();
                reader2 = con.GetDBData("select * from professor where id='" + prof_id + "';");
                if (reader2.Read())
                {
                    prf_name = reader2["name"].ToString();
                }
                reader2.Close();
                reader2 = con.GetDBData("select * from classes where id='" + classes_id + "' and course_id='" + course_id + "';");
                if (reader2.Read())
                {
                    classes_type_name = reader2["classes_type_name"].ToString();
                    dt_cl             = DateTime.Parse(reader["date"].ToString());
                }
                reader2.Close();
                dataGridView1.Rows.Add(crs_name, prf_name, classes_type_name, "", String.Format("{0:dd.MM.yyyy}", dt_cl), comment, link, String.Format("{0:dd.MM.yyyy}", dt));
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Height = 75;
            }
        }
Ejemplo n.º 14
0
 private void dataGridView2_labs(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView2.Columns[e.ColumnIndex].Name == "mark")
     {
         DataGridViewRow row = dataGridView2.CurrentRow;
         //MessageBox.Show("Hello " + row.Cells[3].Value.ToString());
         DB_connect      cn       = new DB_connect(ip, db, user, pass);
         DateTime        dt       = DateTime.Parse(row.Cells[1].Value.ToString());
         MySqlDataReader reader2  = cn.GetDBData("select * from classes where date='" + String.Format("{0:yyyy-MM-dd}", dt) + "' and course_id='" + course_id + "';");
         int             class_id = -1;
         if (reader2.Read())
         {
             class_id = Convert.ToInt32(reader2["id"]);
             DB_connect      cn2 = new DB_connect(ip, db, user, pass);
             MySqlDataReader rc  = cn2.GetDBData("UPDATE classes_progress SET mark='" + row.Cells[3].Value.ToString() + "' WHERE st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + class_id + "';");
             rc.Read();
             MessageBox.Show("Значение обновлено!");
             rc.Close();
         }
         reader2.Close();
     }
 }
Ejemplo n.º 15
0
        private void Upd()
        {
            // Очистка всех таблиц --------------------------------------------------
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            dataGridView2.Rows.Clear();
            dataGridView3.Rows.Clear();
            dataGridView4.Rows.Clear();
            dataGridView5.Rows.Clear();


            //Заполняем таблицу на первой вкладке ------------------------------------
            //Создаем колонки
            reader = con.GetDBData("select * from classes where classes_type_name='Семинар' AND course_id='" + course_id + "';");
            int days = 0;

            dataGridView1.Columns.Add("student", "Студент");
            dataGridView1.Columns[0].SortMode  = DataGridViewColumnSortMode.NotSortable;
            dataGridView1.Columns[0].Resizable = DataGridViewTriState.False;
            dataGridView1.Columns[0].ReadOnly  = true;
            dataGridView1.Columns[0].Width     = 150;
            String[] stroke;
            int      i = 1;

            while (reader.Read())
            {
                stroke = reader["date"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                dataGridView1.Columns.Add(stroke[0], stroke[0].ToString());
                dataGridView1.Columns[i].Width     = 65;
                dataGridView1.Columns[i].SortMode  = DataGridViewColumnSortMode.NotSortable;
                dataGridView1.Columns[i].Resizable = DataGridViewTriState.False;
                string today = DateTime.Today.ToString(); //.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day;
                string date  = reader["date"].ToString();
                if (!(date == today))
                {
                    dataGridView1.Columns[i].ReadOnly = true;
                    dataGridView1.Columns[i].DefaultCellStyle.ForeColor = DefaultForeColor;
                }
                else
                {
                    dataGridView1.Columns[i].ReadOnly = false;
                    dataGridView1.Columns[i].DefaultCellStyle.BackColor = Color.LightGreen;
                }
                i++;
            }
            days = i - 1;
            reader.Close();
            dataGridView1.Columns.Add("late", "Опозданий");
            dataGridView1.Columns[i].Width     = 80;
            dataGridView1.Columns[i].SortMode  = DataGridViewColumnSortMode.NotSortable;
            dataGridView1.Columns[i].Resizable = DataGridViewTriState.False;
            dataGridView1.Columns[i].ReadOnly  = true;
            dataGridView1.Columns.Add("work", "Работа на семинарах");
            dataGridView1.Columns[i + 1].Width     = 90;
            dataGridView1.Columns[i + 1].SortMode  = DataGridViewColumnSortMode.NotSortable;
            dataGridView1.Columns[i + 1].Resizable = DataGridViewTriState.False;
            dataGridView1.Columns[i + 1].ReadOnly  = true;

            //Заполняем данными
            reader = con.GetDBData("select * from students where groups_name='" + groups_name + "';");
            i      = 0;
            while (reader.Read())
            {
                string name = reader["name"].ToString();
                string zk   = reader["zk"].ToString();
                dataGridView1.Rows.Add(name);
                try
                {
                    DB_connect      con2       = new DB_connect(ip, db, user, pass);
                    MySqlDataReader reader2    = con2.GetDBData("select * from attendance where st_zk_no='" + zk + "' and course_id='" + course_id + "';");
                    int             sum_late   = 0;
                    int             sum_answer = 0;
                    int             k          = 0;
                    for (int j = 1; j <= days; j++)
                    {
                        reader2.Read();
                        //MessageBox.Show(reader2["attend"].ToString());
                        dataGridView1.Rows[i].Cells[j].Value = "";

                        var    attend   = reader2["attend"].ToString();
                        var    lateness = reader2["lateness"].ToString();
                        var    answer   = reader2["answer"].ToString();
                        string str      = "";
                        if (attend == "True")
                        {
                            str += "+";
                        }
                        if (lateness == "True")
                        {
                            str      += "о";
                            sum_late += 1;
                        }
                        if (answer == "True")
                        {
                            str        += "д";
                            sum_answer += 1;
                        }
                        dataGridView1.Rows[i].Cells[j].Value = str;
                        k = j;
                    }
                    if (!(sum_late == 0))
                    {
                        dataGridView1.Rows[i].Cells[k + 1].Value = sum_late.ToString() + "/" + days;
                    }
                    if (!(sum_answer == 0))
                    {
                        dataGridView1.Rows[i].Cells[k + 2].Value = sum_answer.ToString() + "/" + days;
                    }

                    i++;
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.ToString());
                }
            }
            reader.Close();


            // Вторая вкладка ---------------------------------
            // listbox
            listBox1.Items.Clear();
            DB_connect      connect = new DB_connect(ip, db, user, pass);
            MySqlDataReader newread = connect.GetDBData("select * from students where groups_name='" + groups_name + "';");

            while (newread.Read())
            {
                listBox1.Items.Add(newread["name"].ToString());
            }
            newread.Close();
            connect.Close();
            // заполнение по щелчку dataGridView2, 3 и 4 (лб, рк, дз) отдельной функцией ниже
        }
Ejemplo n.º 16
0
        private void Lab_Upd(string name)
        {
            // Очистка датагридвью
            dataGridView2.Rows.Clear();
            dataGridView3.Rows.Clear();
            dataGridView4.Rows.Clear();

            //dataGridView2 --------------------------------------------
            DB_connect      connect = new DB_connect(ip, db, user, pass);
            MySqlDataReader newread = connect.GetDBData("select * from students where name='" + name + "';");

            if (newread.Read())
            {
                zk = newread["zk"].ToString();
            }
            newread.Close();
            newread = connect.GetDBData("select * from classes where course_id='" + course_id + "' and classes_type_name='Лабораторная работа';");
            int[] lab_no = null;
            int[] lab_id = null;
            int   i      = 0;

            while (newread.Read())
            {
                Array.Resize(ref lab_no, i + 1);
                lab_no[i] = Convert.ToInt32(newread["number"]);
                Array.Resize(ref lab_id, i + 1);
                lab_id[i] = Convert.ToInt32(newread["id"]);
                dataGridView2.Rows.Add(lab_no[i].ToString());
                string[] stroke = newread["date"].ToString().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                string   s      = stroke[0];
                dataGridView2.Rows[i].Cells[1].Value = stroke[0];
                DB_connect      connect2 = new DB_connect(ip, db, user, pass);
                MySqlDataReader newread2 = connect2.GetDBData("select * from attendance where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    bool attend = Convert.ToBoolean(newread2["attend"]);
                    if (attend)
                    {
                        dataGridView2.Rows[i].Cells[2].Value = "+";
                    }
                    DateTime late_date = DateTime.Parse(stroke[0]);
                    late_date = late_date.AddDays(7);
                    TimeSpan ts        = DateTime.Today - late_date;
                    int      days_left = ts.Days;
                    if (days_left > 7)
                    {
                        dataGridView2.Rows[i].Cells[4].Value = "+";
                    }
                }
                newread2.Close();
                newread2 = connect2.GetDBData("select * from classes_progress where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    int mark = Convert.ToInt32(newread2["mark"]);
                    dataGridView2.Rows[i].Cells[3].Value = mark;
                }
                newread2.Close();

                i++;
            }
            newread.Close();



            //dataGridView3 ------------------------------------------
            //string zk;
            newread = connect.GetDBData("select * from students where name='" + name + "';");
            if (newread.Read())
            {
                zk = newread["zk"].ToString();
            }
            newread.Close();
            newread = connect.GetDBData("select * from classes where course_id='" + course_id + "' and classes_type_name='Рубежный контроль';");
            lab_no  = null;
            lab_id  = null;
            i       = 0;
            while (newread.Read())
            {
                Array.Resize(ref lab_no, i + 1);
                lab_no[i] = Convert.ToInt32(newread["number"]);
                Array.Resize(ref lab_id, i + 1);
                lab_id[i] = Convert.ToInt32(newread["id"]);
                dataGridView3.Rows.Add(lab_no[i].ToString());
                string[] stroke = newread["date"].ToString().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                string   s      = stroke[0];
                dataGridView3.Rows[i].Cells[1].Value = stroke[0];
                DB_connect      connect2 = new DB_connect(ip, db, user, pass);
                MySqlDataReader newread2 = connect2.GetDBData("select * from attendance where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    bool attend = Convert.ToBoolean(newread2["attend"]);
                    if (attend)
                    {
                        dataGridView3.Rows[i].Cells[2].Value = "+";
                    }
                    DateTime late_date = DateTime.Parse(stroke[0]);
                    late_date = late_date.AddDays(7);
                    TimeSpan ts        = DateTime.Today - late_date;
                    int      days_left = ts.Days;
                    if (days_left > 7)
                    {
                        dataGridView3.Rows[i].Cells[4].Value = "+";
                    }
                }
                newread2.Close();
                newread2 = connect2.GetDBData("select * from classes_progress where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    int mark = Convert.ToInt32(newread2["mark"]);
                    dataGridView3.Rows[i].Cells[3].Value = mark;
                }
                newread2.Close();

                i++;
            }
            newread.Close();


            // dataGridView4 ---------------------------------------------------
            //string zk;
            newread = connect.GetDBData("select * from students where name='" + name + "';");
            if (newread.Read())
            {
                zk = newread["zk"].ToString();
            }
            newread.Close();
            newread = connect.GetDBData("select * from classes where course_id='" + course_id + "' and classes_type_name='Домашнее задание';");
            lab_no  = null;
            lab_id  = null;
            i       = 0;
            while (newread.Read())
            {
                Array.Resize(ref lab_no, i + 1);
                lab_no[i] = Convert.ToInt32(newread["number"]);
                Array.Resize(ref lab_id, i + 1);
                lab_id[i] = Convert.ToInt32(newread["id"]);
                dataGridView4.Rows.Add(lab_no[i].ToString());
                string[] stroke = newread["date"].ToString().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                string   s      = stroke[0];
                dataGridView4.Rows[i].Cells[1].Value = stroke[0];
                DB_connect      connect2 = new DB_connect(ip, db, user, pass);
                MySqlDataReader newread2 = connect2.GetDBData("select * from attendance where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    bool attend = Convert.ToBoolean(newread2["attend"]);
                    if (attend)
                    {
                        dataGridView4.Rows[i].Cells[2].Value = "+";
                    }
                    DateTime late_date = DateTime.Parse(stroke[0]);
                    late_date = late_date.AddDays(7);
                    TimeSpan ts        = DateTime.Today - late_date;
                    int      days_left = ts.Days;
                    if (days_left > 7)
                    {
                        dataGridView4.Rows[i].Cells[4].Value = "+";
                    }
                }
                newread2.Close();
                newread2 = connect2.GetDBData("select * from classes_progress where st_zk_no='" + zk + "' and course_id='" + course_id + "' and classes_id='" + lab_id[i] + "';");
                if (newread2.Read())
                {
                    int mark = Convert.ToInt32(newread2["mark"]);
                    dataGridView4.Rows[i].Cells[3].Value = mark;
                }
                newread2.Close();

                i++;
            }
            newread.Close();
        }
Ejemplo n.º 17
0
        // А тут обновляем последнюю вкладку с экзаменом.
        public void exam_tab_update()
        {
            //Очищаем, снова.
            dataGridView5.Rows.Clear();
            //dataGridView5.Columns.Clear();

            DB_connect con = new DB_connect(ip, db, user, pass);

            /*MySqlDataReader newread = con.GetDBData("select * from modules where course_id='" + course_id + "';");
             * int i = 2;
             * while (newread.Read())
             * {
             *  int mdl_id = Convert.ToInt32(newread["id"]);
             *  DataGridViewColumn module2 = new DataGridViewColumn();
             *  module2.Name = "in_time_" + i;
             *  module2.HeaderText = "В срок";
             *  dataGridView5.Columns.Insert(i, module2);
             *  DataGridViewColumn module1 = new DataGridViewColumn();
             *  module1.Name = "module" + i;
             *  module1.HeaderText = "Модуль " + i/2;
             *  dataGridView5.Columns.Insert(i, module1);
             *  i += 2;
             * }
             * newread.Close(); */

            MySqlDataReader newread = con.GetDBData("select * from students where groups_name='" + groups_name + "';");
            int             j       = 1;
            int             i       = 0;
            string          zk2     = "";

            while (newread.Read())
            {
                string st = newread["name"].ToString();
                dataGridView5.Rows.Add(st);
                zk2 = newread["zk"].ToString();
                DB_connect      con2       = new DB_connect(ip, db, user, pass);
                MySqlDataReader newreader2 = con2.GetDBData("select * from classes_progress where st_zk_no='" + zk2 + "' and course_id='" + course_id + "';");
                int             sum_mark   = 0;
                while (newreader2.Read())
                {
                    sum_mark += Convert.ToInt32(newreader2["mark"]);
                }
                dataGridView5.Rows[i].Cells[j + 5].Value = sum_mark;
                newreader2.Close();

                newreader2 = con2.GetDBData("select * from attendance where st_zk_no='" + zk2 + "' and course_id='" + course_id + "';");
                int sum_late = 0;
                int sum_act  = 0;
                int num      = 0;
                while (newreader2.Read())
                {
                    string late = newreader2["attend"].ToString();
                    string act  = newreader2["answer"].ToString();
                    if (late == "True")
                    {
                        sum_late++;
                    }
                    if (act == "True")
                    {
                        sum_act++;
                    }
                    num++;
                }
                dataGridView5.Rows[i].Cells[j + 2].Value = sum_late + "/" + num;
                dataGridView5.Rows[i].Cells[j + 3].Value = sum_late + "/" + num;
                newreader2.Close();

                newreader2 = con2.GetDBData("select * from classes where classes_type_name='Экзамен' and course_id='" + course_id + "';");
                int ekz_cl_id = 0;
                if (newreader2.Read())
                {
                    ekz_cl_id = Convert.ToInt32(newreader2["id"]);
                }
                newreader2.Close();

                newreader2 = con2.GetDBData("select * from classes_progress where st_zk_no='" + zk2 + "' and classes_id='" + ekz_cl_id + "' and course_id='" + course_id + "';");
                if (newreader2.Read())
                {
                    int mark = Convert.ToInt32(newreader2["mark"]);
                    dataGridView5.Rows[i].Cells[j + 4].Value = mark;
                }
                newreader2.Close();
                i++;
            }
            newread.Close();

            newread = con.GetDBData("select * from modules where course_id='" + course_id + "';");
            i       = 2;
            while (newread.Read())
            {
                int mod_id = Convert.ToInt32(newread["id"]);
                int mdl_id = Convert.ToInt32(newread["id"]);
                dataGridView5.Columns.Add("in_time" + (i / 2).ToString(), "В срок");
                dataGridView5.Columns["in_time" + (i / 2).ToString()].DisplayIndex = i;
                dataGridView5.Columns.Add("moudule" + (i / 2).ToString(), "Модуль " + (i / 2).ToString());
                dataGridView5.Columns["moudule" + (i / 2).ToString()].DisplayIndex = i;
                int col_id = dataGridView5.Columns["moudule" + (i / 2).ToString()].Index;

                for (int k = 0; k < dataGridView5.RowCount; k++)
                {
                    int             mod_mark   = 0;
                    DB_connect      con3       = new DB_connect(ip, db, user, pass);
                    string          st_n       = dataGridView5.Rows[k].Cells[0].Value.ToString();
                    MySqlDataReader newreader2 = con3.GetDBData("select * from students where name='" + st_n + "';");
                    string          zk         = "";
                    if (newreader2.Read())
                    {
                        zk = newreader2["zk"].ToString();
                    }
                    newreader2.Close();
                    newreader2 = con3.GetDBData("select * from module_progress where course_id='" + course_id + "' and st_zk_no='" + zk + "' and module_id='" + mod_id + "';");

                    if (newreader2.Read())
                    {
                        mod_mark = Convert.ToInt32(newreader2["summ_mark"]);
                    }
                    newreader2.Close();
                    if (!(mod_mark == 0))
                    {
                        dataGridView5.Rows[k].Cells[col_id].Value = mod_mark.ToString();
                    }
                    newreader2.Close();
                }
                i += 2;
            }
            newread.Close();
        }
Ejemplo n.º 18
0
        private void StudForm_Shown(object sender, EventArgs e)
        {
            //Смотрим, что за студент
            connection = new DB_connect(ip, db, user, pass);
            MySqlDataReader reader = connection.GetDBData("SELECT * FROM students WHERE login='******';");

            reader.Read();
            label1.Text = reader["name"].ToString();
            group_name  = reader["groups_name"].ToString();
            zk          = reader["zk"].ToString();
            reader.Close();

            //Достаем расписание
            string today = DateTime.Today.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day;

            reader = connection.GetDBData("select * from week where date_start<='" + today + "' and date_finish>='" + today + "';");
            string d_s;
            string d_f;
            int    week_no = -1;

            if (reader.Read())
            {
                d_s     = reader["date_start"].ToString();
                d_f     = reader["date_finish"].ToString();
                week_no = Convert.ToInt32(reader["week_no"]);
            }
            reader.Close();
            int nechet;

            if (!(week_no == -1) && (week_no % 2 == 0))
            {
                nechet = 0; //знаменатель
            }
            else
            {
                nechet = 1; //числитель
            }
            // А также день недели
            reader = connection.GetDBData("select * from day_of_week where name='" + DateTime.Today.DayOfWeek.ToString() + "';");
            int day_of_week = 0;

            if (reader.Read())
            {
                day_of_week = Convert.ToInt32(reader["no"]);
            }
            reader.Close();
            reader = connection.GetDBData("select * from pairs");
            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader["pair_no"] + ": " + reader["time_start"] + "-" + reader["time_finish"], "");
            }
            reader.Close();


            // Вытягиваем все занятия и заполняем DataGridView
            if (!(day_of_week == 0))
            {
                reader = connection.GetDBData("select * from schedule_on_week where parity='" + nechet + "' AND day_of_week='" + day_of_week + "' AND groups_name='" + group_name + "';");
                while (reader.Read())
                {
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (row.Index == Convert.ToInt32(reader["pair_no"]))
                        {
                            row.Cells[1].Value = "";
                            //Приходится еще раз подключаться в виду некоторых ограничений
                            DB_connect connection2 = new DB_connect(ip, db, user, pass);
                            // Дисциплина
                            MySqlDataReader reader2 = connection2.GetDBData("select * from course where id='" + reader["course_id"] + "';");
                            reader2.Read();
                            row.Cells[1].Value += reader2["name"] + "\r\n";
                            reader2.Close();
                            // Преподаватель
                            reader2 = connection2.GetDBData("select * from professor where id='" + reader["prof_id"] + "';");
                            reader2.Read();
                            row.Cells[1].Value += reader2["name"] + "\r\n";
                            reader2.Close();
                            // Тип
                            row.Cells[1].Value += reader2["name"] + "\r\n";
                            // Аудитория уже есть.
                            row.Cells[1].Value += reader["auditory_no"].ToString();
                            row.Height          = 65;
                        }
                    }
                }
            }
            reader.Close();
        }
Ejemplo n.º 19
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("Такого урока не существует!", "Ошибка.");
            }
        }
Ejemplo n.º 20
0
        public void UpdMu(int id)
        {
            DB_connect      cn = new DB_connect(ip, db, user, pass);
            MySqlDataReader reader;

            if (id == 0)
            {
                reader = cn.GetDBData("select * from capacity where prof_id='" + prof_id + "';");
                while (reader.Read())
                {
                    int    course_id   = Convert.ToInt32(reader["course_id"]);
                    int    classes_id  = Convert.ToInt32(reader["classes_id"]);
                    string groups_name = reader["groups_name"].ToString();
                    string course_name;

                    DB_connect      con     = new DB_connect(ip, db, user, pass);
                    MySqlDataReader reader2 = con.GetDBData("select * from course where id='" + course_id + "';");
                    if (reader2.Read())
                    {
                        course_name = reader2["name"].ToString();
                        if (comboBox1.FindString(course_name) == -1)
                        {
                            comboBox1.Items.Add(course_name);
                        }
                    }
                    reader2.Close();
                    if (comboBox2.FindString(groups_name) == -1)
                    {
                        comboBox2.Items.Add(groups_name);
                    }
                    reader2 = con.GetDBData("select * from classes_type;");
                    while (reader2.Read())
                    {
                        string cl_name = reader2["name"].ToString();
                        if (comboBox3.FindString(cl_name) == -1)
                        {
                            comboBox3.Items.Add(cl_name);
                        }
                    }
                    reader2.Close();
                }
                reader.Close();
            }
            else
            {
                reader = cn.GetDBData("select * from mu where id='" + id + "';");
                reader.Read();
                int      course_id  = Convert.ToInt32(reader["course_id"]);
                int      classes_id = Convert.ToInt32(reader["classes_id"]);
                string   comment    = reader["comment"].ToString();
                string   link       = reader["link"].ToString();
                DateTime date       = DateTime.Parse(reader["date"].ToString());
                reader.Close();
                // ----
                reader = cn.GetDBData("select name from course where id='" + course_id + "';");
                reader.Read();
                string course_name = reader["name"].ToString();
                reader.Close();
                reader = cn.GetDBData("select * from classes where id='" + classes_id + "' and course_id='" + course_id + "';");
                reader.Read();
                string cl_t_n   = reader["classes_type_name"].ToString();
                int    c_number = Convert.ToInt32(reader["number"]);
                reader.Close();

                comboBox1.Items.Add(course_name);
                comboBox1.SelectedItem = course_name;
                comboBox2.Items.Add(group_name);
                comboBox2.SelectedItem = group_name;
                comboBox3.Items.Add(cl_t_n);
                comboBox3.SelectedItem = cl_t_n;
                textBox1.Text          = c_number.ToString();
                textBox2.Text          = comment;
                textBox3.Text          = link;
            }
        }
Ejemplo n.º 21
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            //MessageBox.Show("Hello!");
            MySqlDataReader reader = connection.GetDBData("SELECT * FROM professor WHERE login='******';");

            //label1.Text = "";
            reader.Read();
            label1.Text = reader["name"].ToString();
            prof_id     = Convert.ToInt32(reader["id"]);
            reader.Close();

            //Высчитать, какие сегодня пары
            //Для этого мы должны узнать, какая четность недели
            string today = DateTime.Today.Year + "-" + DateTime.Today.Month + "-" + DateTime.Today.Day;

            reader = connection.GetDBData("select * from week where date_start<='" + today + "' and date_finish>='" + today + "';");
            string d_s;
            string d_f;
            int    week_no = -1;

            if (reader.Read())
            {
                d_s     = reader["date_start"].ToString();
                d_f     = reader["date_finish"].ToString();
                week_no = Convert.ToInt32(reader["week_no"]);
            }
            reader.Close();
            int nechet;

            if (!(week_no == -1) && (week_no % 2 == 0))
            {
                nechet = 1; //числитель
            }
            else
            {
                nechet = 2; //знаменатель
            }
            // А также день недели
            reader = connection.GetDBData("select * from day_of_week where name='" + DateTime.Today.DayOfWeek.ToString() + "';");
            int day_of_week = 0;

            if (reader.Read())
            {
                day_of_week = Convert.ToInt32(reader["no"]);
            }
            reader.Close();
            // И ID преподавателя
            reader = connection.GetDBData("select * from professor where login='******';");
            if (reader.Read())
            {
                prof_id = Convert.ToInt32(reader["id"]);
            }
            reader.Close();
            // Вытягиваем время занятий
            reader = connection.GetDBData("select * from pairs");
            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader["pair_no"] + ": " + reader["time_start"] + "-" + reader["time_finish"], "");
            }
            reader.Close();

            // Вытягиваем все занятия и заполняем DataGridView
            if (!(day_of_week == 0))
            {
                reader = connection.GetDBData("select * from schedule_on_week where (parity='" + nechet + "' or parity='0') AND day_of_week='" + day_of_week + "' AND prof_id='" + prof_id + "';");
                while (reader.Read())
                {
                    foreach (DataGridViewRow row in dataGridView1.Rows)
                    {
                        if (row.Index == Convert.ToInt32(reader["pair_no"]))
                        {
                            row.Cells[1].Value = "";
                            //Приходится еще раз подключаться в виду некоторых ограничений
                            DB_connect connection2 = new DB_connect(ip, db, user, pass);
                            // Дисциплина
                            MySqlDataReader reader2 = connection2.GetDBData("select * from course where id='" + reader["course_id"] + "';");
                            reader2.Read();
                            row.Cells[1].Value += reader2["name"] + "\r\n";
                            reader2.Close();
                            // Группа
                            reader2 = connection2.GetDBData("select * from groups where name='" + reader["groups_name"] + "';");
                            reader2.Read();
                            row.Cells[1].Value += reader2["name"] + "\r\n";
                            reader2.Close();
                            // Тип
                            row.Cells[1].Value += reader["classes_type_name"].ToString() + "\r\n";
                            // Аудитория уже есть.
                            row.Cells[1].Value += reader["auditory_no"].ToString();
                            row.Height          = 65;
                        }
                    }
                }
            }
            reader.Close();
        }
Ejemplo n.º 22
0
        private void Upd(int week_no)
        {
            // Очистка таблицы
            dataGridView1.Rows.Clear();

            //Заполнение
            reader = con.GetDBData("SELECT * FROM professor WHERE login='******';");
            reader.Read();
            label1.Text = reader["name"].ToString();
            int prof_id = Convert.ToInt32(reader["id"]);

            reader.Close();

            // Выбранная неделя
            reader = con.GetDBData("select * from week where week_no='" + week_no + "';");
            reader.Read();
            string[] d_s = reader["date_start"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string[] d_f = reader["date_finish"].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            textBox1.Text = d_s[0];
            textBox2.Text = d_f[0];
            reader.Close();
            int nechet;

            if (week_no % 2 == 0)
            {
                nechet = 2;
            }
            else
            {
                nechet = 1;
            }
            reader = con.GetDBData("select * from pairs");
            while (reader.Read())
            {
                dataGridView1.Rows.Add(reader["pair_no"] + ": " + reader["time_start"] + "-" + reader["time_finish"]);
            }
            string group_name = "";

            for (int i = 1; i < 7; i++)
            {
                DB_connect      con2    = new DB_connect(ip, db, user, pass);
                MySqlDataReader reader2 = con2.GetDBData("select * from schedule_on_week where (parity='" + nechet + "' or parity='0') and day_of_week='" + i + "' and prof_id='" + prof_id + "';");
                while (reader2.Read())
                {
                    int pair_no = Convert.ToInt32(reader2["pair_no"]);
                    group_name = reader2["groups_name"].ToString();
                    string          classes_type_name = reader2["classes_type_name"].ToString();
                    int             course_id         = Convert.ToInt32(reader2["course_id"]);
                    int             auditory          = Convert.ToInt32(reader2["auditory_no"]);
                    DB_connect      con3    = new DB_connect(ip, db, user, pass);
                    MySqlDataReader reader3 = con3.GetDBData("select * from course where id='" + course_id + "';");
                    reader3.Read();
                    string course_name = reader3["name"].ToString();
                    reader3.Close();
                    string str = course_name + "\r\n" + group_name + "\r\n" + classes_type_name + "\r\n" + auditory;
                    dataGridView1.Rows[pair_no - 1].Cells[i].Value = str;
                    dataGridView1.Rows[pair_no - 1].Height         = 65;
                }
            }
            reader.Close();
        }