Пример #1
0
        public void parse(DataGridView data_grid, table source_table)
        {
            string table_name = source_table.get_name();

            switch (table_name)
            {
            case "Студент": student(data_grid, source_table); break;

            case "Преподаватель": teacher(data_grid, source_table); break;

            case "Предмет": subject(data_grid, source_table); break;

            case "Успеваемость": academic_progress(data_grid, source_table); break;

            case "Группа": group(data_grid, source_table); break;

            case "Деканат": deanery(data_grid, source_table); break;

            case "Специальность": specialty(data_grid, source_table); break;

            case "Факультет": faculty(data_grid, source_table); break;

            case "Запрос успеваемости": request_rating(data_grid, source_table); break;

            default: break;
            }
        }
Пример #2
0
        void student(DataGridView data_grid, table source_table)
        {
            source_table.clear();

            for (int i = 0, n_raw = data_grid.RowCount - 1; i < n_raw; ++i)
            {
                bool     error = false;
                string[] arg   = new string[data_grid.ColumnCount];

                for (int j = 0, n_columns = data_grid.ColumnCount; j < n_columns; ++j)
                {
                    if (j == 4)
                    {
                        string key = table_group.instanse().find(Convert.ToString(data_grid[j, i].Value), 1, 0);
                        if (key != "%undef%")
                        {
                            arg[j] = key;
                        }
                        else
                        {
                            error = true;
                        }
                    }
                    else
                    {
                        arg[j] = Convert.ToString(data_grid[j, i].Value);
                    }
                }

                if (!error)
                {
                    source_table.add_record(arg);
                }
            }
        }
Пример #3
0
 public key_table_field(string new_name, table new_table, int new_index)
 {
     name          = new_name;
     related_table = new_table;
     index         = new_index;
     type          = "str";
 }
Пример #4
0
 private void callback_group(string group)
 {
     this.Enabled = true;
     if (group != "%error%")
     {
         table result = main_mngr.find_by_value(group, request_contr.by_value.group);
         display(result);
     }
 }
Пример #5
0
 private void callback_specialty(string specialty)
 {
     this.Enabled = true;
     if (specialty != "%error%")
     {
         table result = main_mngr.find_by_value(specialty, request_contr.by_value.specialty);
         display(result);
     }
 }
Пример #6
0
        protected void find(table search_table, int index, string value)
        {
            search_table.Reset();
            int n = search_table.get_columns().Count;

            foreach (table_record record in search_table)
            {
                if (record[index].get_value() == value)
                {
                    string[] arg = record.get_values();
                    result.add_record(arg);
                }
            }
        }
Пример #7
0
        void faculty(DataGridView data_grid, table source_table)
        {
            source_table.clear();
            for (int i = 0, n_raw = data_grid.RowCount - 1; i < n_raw; ++i)
            {
                string[] arg = new string[data_grid.ColumnCount];

                for (int j = 0, n_columns = data_grid.ColumnCount; j < n_columns; ++j)
                {
                    arg[j] = Convert.ToString(data_grid[j, i].Value);
                }

                source_table.add_record(arg);
            }
        }
Пример #8
0
        private void read(string file_name, table new_table)
        {
            new_table.clear();

            FileStream   file   = new FileStream(file_name, FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(file);

            string str;

            while ((str = reader.ReadLine()) != null)
            {
                string[] elements = str.Split(';');
                if (elements.Count <string>() > 1)
                {
                    new_table.add_record(elements);
                }
            }
        }
Пример #9
0
        void academic_progress(DataGridView data_grid, table source_table)
        {
            source_table.clear();
            for (int i = 0, n_raw = data_grid.RowCount - 1; i < n_raw; ++i)
            {
                bool     error = false;
                string[] arg   = new string[data_grid.ColumnCount];

                for (int j = 0, n_columns = data_grid.ColumnCount; j < n_columns; ++j)
                {
                    //if (j == 0) {
                    //    string key = table_student.instanse().find(Convert.ToString(data_grid[j, i].Value), 1, 0);
                    //    if (key != "%undef%") arg[j] = key;
                    //    else error = true;
                    //}
                    if (j == 1)
                    {
                        string key = table_subject.instanse().find(Convert.ToString(data_grid[j, i].Value), 1, 0);
                        if (key != "%undef%")
                        {
                            arg[j] = key;
                        }
                        else
                        {
                            error = true;
                        }
                    }
                    //else if (j == 5) {
                    //    string key = table_teacher.instanse().find(Convert.ToString(data_grid[j, i].Value), 1, 0);
                    //    if (key != "%undef%") arg[j] = key;
                    //    else error = true;
                    //}
                    else
                    {
                        arg[j] = Convert.ToString(data_grid[j, i].Value);
                    }
                }

                if (!error)
                {
                    source_table.add_record(arg);
                }
            }
        }
Пример #10
0
        private void button4_Click(object sender, EventArgs e)
        {
            label_for_student.Text = "";
            if (data_grid.SelectedRows.Count > 0 && current_table != null)
            {
                if (current_table.get_name() == "Студент")
                {
                    int index = data_grid.SelectedRows[0].Index;

                    label_for_student.Text  = Convert.ToString(data_grid[1, index].Value) + " ";
                    label_for_student.Text += Convert.ToString(data_grid[2, index].Value) + " ";
                    label_for_student.Text += Convert.ToString(data_grid[3, index].Value) + " ";
                    label_for_student.Text += Convert.ToString(data_grid[4, index].Value);

                    string str           = Convert.ToString(data_grid[0, index].Value);
                    table  current_table = main_mngr.find_by_value(str, request_contr.by_value.rating);
                    display(current_table);
                }
            }
        }
Пример #11
0
        public override table execute(object value)
        {
            // the first step
            List <string> columns = table_group.instanse().get_columns();

            result = new table_custom(Convert.ToString(value), columns);

            int index;

            for (index = 0; index < columns.Count; ++index)
            {
                if (columns[index] == "Код факультета")
                {
                    break;
                }
            }

            find(table_group.instanse(), index, Convert.ToString(value));
            table group = result;

            // the second step
            columns = table_student.instanse().get_columns();
            result  = new table_custom(Convert.ToString(value), columns);

            for (index = 0; index < columns.Count; ++index)
            {
                if (columns[index] == "Код группы")
                {
                    break;
                }
            }


            foreach (table_record record in group)
            {
                find(table_student.instanse(), index, record[1].get_value());
            }

            return(result);
        }
Пример #12
0
        private void write(string file_name, table new_table)
        {
            FileStream   file   = new FileStream(file_name, FileMode.Create);
            StreamWriter writer = new StreamWriter(file);

            foreach (table_record record in new_table)
            {
                bool flag = false;
                foreach (table_field field in record)
                {
                    if (flag)
                    {
                        writer.Write(";");
                    }
                    flag = true;
                    writer.Write(field.get_absolute_value());
                }
                writer.Write("\n");
            }

            writer.Close();
        }
Пример #13
0
 public void parse(DataGridView data_grid, table source_table)
 {
     parser.parse(data_grid, source_table);
 }
Пример #14
0
        private void студентыПоГруппамToolStripMenuItem_Click(object sender, EventArgs e)
        {
            table result = main_mngr.report_by_group();

            display(result);
        }
Пример #15
0
        private void запросНаОтличниковToolStripMenuItem_Click(object sender, EventArgs e)
        {
            table result = main_mngr.find_by_rating(request_contr.by_rating._5);

            display(result);
        }
Пример #16
0
        private void запросНаСтудентовСЧетверкамиИПятеркамиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            table result = main_mngr.find_by_rating(request_contr.by_rating._4_and_5);

            display(result);
        }
Пример #17
0
        private void display(table table_for_display)
        {
            clear_data_grid();

            if (table_for_display.get_name() == "Студент")
            {
                rating_view.Enabled = true;
            }
            else
            {
                rating_view.Enabled = false;
            }

            if (table_for_display.get_name() != "Запрос успеваемости")
            {
                label_for_student.Text = "";
            }

            List <string> columns_name = table_for_display.get_columns();

            current_table = table_for_display;
            int column_width = (data_grid.Width - 70) / columns_name.Count();

            int index = 1;

            foreach (string name in columns_name)
            {
                var column = new DataGridViewColumn();
                column.HeaderText = name;
                if (index == columns_name.Count())
                {
                    column.Width = column_width + (data_grid.Width - column_width * index);
                }
                else
                {
                    column.Width = column_width;
                }
                //column.ReadOnly = true;
                column.Name         = name;
                column.Frozen       = true;
                column.CellTemplate = new DataGridViewTextBoxCell();
                column.SortMode     = DataGridViewColumnSortMode.Programmatic;
                data_grid.Columns.Add(column);
                ++index;
            }

            int index_raw = 0;

            table_for_display.Reset();
            foreach (table_record record in table_for_display)
            {
                data_grid.Rows.Add();
                int index_column = 0;

                foreach (table_field field in record)
                {
                    data_grid[index_column++, index_raw].Value = field.get_value();
                }

                ++index_raw;
            }
        }
Пример #18
0
        void request_rating(DataGridView data_grid, table source_table)
        {
            var student = table_student.instanse();

            int size = source_table.size();

            if (size < 1)
            {
                return;
            }
            string index = source_table[0][0].get_absolute_value();

            var rating = table_academic_progress.instanse();

            List <table_record> to_delete = new List <table_record>();


            rating.Reset();
            foreach (table_record record in rating)
            {
                string n_index = record[0].get_value();
                if (index == n_index)
                {
                    to_delete.Add(record);
                }
            }

            foreach (table_record record in to_delete)
            {
                rating.delete_record(record);
            }

            for (int i = 0, n_raw = data_grid.RowCount - 1; i < n_raw; ++i)
            {
                bool     error = false;
                string[] arg   = new string[data_grid.ColumnCount];

                for (int j = 0, n_columns = data_grid.ColumnCount; j < n_columns; ++j)
                {
                    if (j == 1)
                    {
                        string key = table_subject.instanse().find(Convert.ToString(data_grid[j, i].Value), 1, 0);
                        if (key != "%undef%")
                        {
                            arg[j] = key;
                        }
                        else
                        {
                            error = true;
                        }
                    }
                    else
                    {
                        arg[j] = Convert.ToString(data_grid[j, i].Value);
                    }
                }
                if (!error)
                {
                    rating.add_record(arg);
                }
            }
        }