Esempio n. 1
0
        public void LoadCategoriesToDataGrid()
        {
            try
            {
                // Получить коллекцию ключей
                ICollection <string> keys = dict_listSubjects.Keys;

                foreach (var j in keys)
                {
                    if (j == (string)comboBox_name_of_subject_TabCatogory.SelectedItem)
                    {
                        current_id_subject = dict_listSubjects[j];
                        break;
                    }
                }
                //MessageBox.Show(current_id_subject.ToString(), "");

                using (ExamTicket_dbEntities db8 = new ExamTicket_dbEntities())
                {
                    var listCatogories = from s in db8.Categories.AsEnumerable()
                                         where current_id_subject == s.id_subject_cat
                                         select new { id_cat_for_dg = s.id_category, name_cat_for_dg = s.name_category };

                    dataGridCatogory.ItemsSource = listCatogories;
                }
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message, "LoadCategoriesToDataGrid", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
        public void Select_qq_of_tiket(int id_sub_INT)
        {
            try
            {
                using (ExamTicket_dbEntities db1 = new ExamTicket_dbEntities())
                {
                    var list1 = from a in db1.Subjects
                                where a.id_subject == id_sub_INT
                                select a;

                    foreach (var s in list1)
                    {
                        current_id_subject   = s.id_subject;
                        current_name_subject = s.name_subject;

                        if (s.id_subject == id_sub_INT)
                        {
                            comboBoxQuantityQuestions.SelectedIndex = (int)s.quantity_questions_of_tiket - 1;
                        }
                    }
                }
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message, "dataGrid_Subjects_form_teacher_MouseUp", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 3
0
        private void Window_Loaded_Form_Teacher(object sender, RoutedEventArgs e)
        {
            try
            {
                // Загрузка ФИО в textBoxFIO
                using (ExamTicket_dbEntities db6 = new ExamTicket_dbEntities())
                {
                    var var_FIO = from p in db6.Teachers
                                  where p.login_tch == TeacherLogin
                                  select p;
                    foreach (var s in var_FIO)
                    {
                        textBoxFIO.Content    = s.name_tch;
                        current_id_teacher_gl = s.id_teacher;
                    }
                }

                // Загрузка данных в dataGrid_Subjects_form_teacher
                Load_subjects();

                // Установка значений в comboBoxQuantityQuestions в диапазоне 1-4
                comboBoxQuantityQuestions.Items.Add(1);
                comboBoxQuantityQuestions.Items.Add(2);
                comboBoxQuantityQuestions.Items.Add(3);
                comboBoxQuantityQuestions.Items.Add(4);

                // Загрузка списка предметов в 2 комбобокса для вкладки "Категории" и "Вопросы"
                Load_subjects_to_comboBox();
            }
            catch (Exception e6)
            {
                MessageBox.Show(e6.Message, "Window_Loaded_Form_Teacher", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 4
0
        private void tabTeacher_Save_Category_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Categories cat = new Categories();
                using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                {
                    if (var_status_operation_catigory == "add")
                    {
                        cat.name_category  = textBox_name_catogory.Text;
                        cat.id_subject_cat = current_id_subject;
                        db.Categories.Add(cat);
                    }
                    else
                    {
                        var category = db.Categories
                                       .Where(c => c.id_category == current_id_category)
                                       .FirstOrDefault();

                        category.name_category = textBox_name_catogory.Text;
                    }
                    db.SaveChanges();
                }
                LoadCategoriesToDataGrid();
                MessageBox.Show("Записи успешно обновлены", "Информация");
                var_status_operation_catigory = "";
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message, "tabTeacher_Save_Category_Click", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 5
0
        private void TextBoxFindQuestions_TextChanged(object sender, TextChangedEventArgs e)
        {
            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                //Поиск
                if (textBoxFindQuestions.Text != "")
                {
                    //dataGridTeacher_list_questions.ItemsSource = db.Questions
                    //    .Where(t => t.text_quesation.Contains(textBoxFindQuestions.Text))
                    //    .ToList();
                    var searchText = from q in db.Questions.AsEnumerable()
                                     where q.id_subject_ques == current_id_subject
                                     //where q.id_category_ques == current_id_category
                                     where q.text_quesation.Contains(textBoxFindQuestions.Text)
                                     select new { text_question = q.text_quesation, pathToPicture = q.pathToPicture };

                    dataGridTeacher_list_questions.ItemsSource = searchText;
                }
                else
                {
                    Load_questions_to_dataGrid();
                }
                //dataGridTeacher_list_questions.ItemsSource = db.Questions.Local.ToBindingList();
                //Поиск
            }
        }
Esempio n. 6
0
        public void QuarySubject(int int_var)
        {
            try
            {
                listBox_subject_of_teacher.Items.Clear();
                using (ExamTicket_dbEntities db1 = new ExamTicket_dbEntities())
                {
                    var list = from a in db1.Subjects
                               from b in db1.Teachers
                               from c in db1.SubjectOfTeacher
                               where b.id_teacher == int_var
                               where b.id_teacher == c.id_teacher_sot
                               where c.id_subject_sot == a.id_subject
                               select a;

                    foreach (var s in list)
                    {
                        listBox_subject_of_teacher.Items.Add(s.name_subject);
                    }

                    // Ниже абсолютно рабочий код, он реализован просто через хранимую процедуру.

                    ////IEnumerable<output_subject_of_teacher_Result> query = db1.output_subject_of_teacher(int_var);
                    ////foreach (output_subject_of_teacher_Result p in query)
                    ////    listBox_subject_of_teacher.Items.Add(p.name_subject);
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Exception stored procedure", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 7
0
        ///*******************************************************************************************************
        private void Load_sub()
        {
            try
            {
                db.Subjects.Load();
                //dataGrid_Subjects.ItemsSource = db.Teachers.Local.ToBindingList();
                dataGrid_Subjects.ItemsSource = db.Subjects.Local.ToBindingList();

                // Очистка listBox_all_subjects и загрузка данными из базы
                listBox_all_subjects.Items.Clear();
                using (ExamTicket_dbEntities db2 = new ExamTicket_dbEntities())
                {
                    var listOfAllSubjects = from p in db2.Subjects
                                            select p;
                    foreach (var s in listOfAllSubjects)
                    {
                        listBox_all_subjects.Items.Add(s.name_subject);
                    }
                }
            }
            catch (Exception e5)
            {
                MessageBox.Show(e5.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 8
0
        private void Load_subjects_to_comboBox()
        {
            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                var var_name_of_subject = from p in db.Subjects
                                          from t in db.Teachers
                                          from r in db.SubjectOfTeacher
                                          where t.login_tch == TeacherLogin
                                          where r.id_teacher_sot == t.id_teacher
                                          where p.id_subject == r.id_subject_sot
                                          select p;

                foreach (var s in var_name_of_subject)
                {
                    comboBox_name_of_subject_TabCatogory.Items.Add(s.name_subject);
                    comboBox_name_of_subject_questions.Items.Add(s.name_subject);

                    current_id_subject = s.id_subject;

                    // Загрузка в словарь id и названия предметов авторизированого преподавателя
                    dict_listSubjects.Add(s.name_subject, s.id_subject);
                }
            }
            comboBox_name_of_subject_TabCatogory.SelectedIndex = 0;
            comboBox_name_of_subject_questions.SelectedIndex   = 0;
        }
Esempio n. 9
0
        // Метод, котрый записывает предметы из listBox_subject_of_teacher в базу данных
        public void RecordSubjectOfTeacher(List <int> list_id_teach, int id_teach)
        {
            try
            {
                list_id_teach.Sort();

                // Логическая переменная - "флажок" для удаления записей в БД 1 раз
                bool deleteRecord = false;

                using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                {
                    SubjectOfTeacher sot = new SubjectOfTeacher();

                    // Задача удалить все записи для преподавателя id_teach
                    if (list_id_teach.Count == 0)
                    {
                        db.SubjectOfTeacher.RemoveRange(db.SubjectOfTeacher.Where(x => x.id_teacher_sot == id_teach));
                        db.SaveChanges();
                    }

                    // Проверка на то, есть ли у преподавателя id_teach вообще записи в таблице SubjectOfTeacher
                    var id_teach_sot = from a in db.SubjectOfTeacher
                                       where a.id_teacher_sot == id_teach
                                       //orderby a.id_subject_sot ascending
                                       select a;

                    foreach (var s in id_teach_sot)
                    {
                        // Сначала удалим все существующие записи данного преподавателя,
                        // а потом создадим после следующем блоке операторов
                        if (deleteRecord == false)
                        {
                            db.SubjectOfTeacher.RemoveRange(db.SubjectOfTeacher.Where(x => x.id_teacher_sot == id_teach));
                            db.SaveChanges();
                            deleteRecord = true;
                        }
                    }

                    // 1. Создание записей, у тех преподавателей, у которых записей не было изначально.
                    // 2. Создание записей, у тех преподавателей, у которых они были изначально, но были удалены
                    // в предедущем блоке кода.

                    for (int i = 0; i < list_id_teach.Count; i++)
                    {
                        sot.id_teacher_sot = id_teach;
                        sot.id_subject_sot = list_id_teach[i];
                        sot.active         = true;
                        db.SubjectOfTeacher.Add(sot);
                        db.SaveChanges();
                    }
                    MessageBox.Show("Записи успешно обновлены", "Информация");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "Exception stored procedure", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 10
0
 private void tabTeacher_Delete_Category_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Вы действительно хотите удалить запись?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
         {
             db.Categories.RemoveRange(db.Categories.Where(x => x.id_category == current_id_category));
             db.SaveChanges();
         }
         LoadCategoriesToDataGrid();
     }
 }
Esempio n. 11
0
        private void Load_subjects()
        {
            using (ExamTicket_dbEntities db7 = new ExamTicket_dbEntities())
            {
                var subjectsOfTeacher = from s in db7.Subjects.AsEnumerable()
                                        from s_of_t in db7.SubjectOfTeacher
                                        where current_id_teacher_gl == s_of_t.id_teacher_sot
                                        where s_of_t.id_subject_sot == s.id_subject
                                        select new { Id = s.id_subject, Name = s.name_subject, Quantity = s.quantity_questions_of_tiket };

                dataGrid_Subjects_form_teacher.ItemsSource = subjectsOfTeacher;
            }
        }
Esempio n. 12
0
        private void buttonAddQuestion_Click(object sender, RoutedEventArgs e)
        {
            if (listBox_formWinAddEditQuestion.Text == "")
            {
                MessageBox.Show("Вы не написали вопрос.", "Предупреждение!");
            }
            else
            {
                try
                {
                    Questions ques = new Questions();
                    using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                    {
                        // Определение текущей категории вопроса
                        var name_of_category = from t in db.Categories
                                               where t.name_category == comboBox_name_of_category_formWinAddEditQuestion.SelectedItem
                                               select t;

                        foreach (var p in name_of_category)
                        {
                            Id_category = p.id_category;
                        }

                        // Удаляем запись с выбраным вопросом
                        db.Questions.RemoveRange(db.Questions.Where(x => x.text_quesation == old_textQuestion));
                        //db.SaveChanges();

                        // Присвоение полей для записи в БД
                        ques.id_subject_ques  = Id_subject;
                        ques.id_category_ques = Id_category;
                        ques.text_quesation   = listBox_formWinAddEditQuestion.Text;
                        ques.pathToPicture    = currentpathToPicture;

                        db.Questions.Add(ques);
                        db.SaveChanges();

                        // Обновление dataGridTeacher_list_questions на форме WinTeacher
                        //WinTeacher.Load_questions_to_dataGrid();
                    }

                    MessageBox.Show("Записи успешно обновлены", "Информация");

                    // Закрытие окна
                    this.Close();
                }
                catch (Exception e2)
                {
                    MessageBox.Show(e2.Message, "!!!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 13
0
        public MainWindow()
        {
            InitializeComponent();

            labelFIO.Visibility            = Visibility.Collapsed;
            labelGroup.Visibility          = Visibility.Collapsed;
            labelSubject.Visibility        = Visibility.Collapsed;
            comboBoxSubject.Visibility     = Visibility.Collapsed;
            labelLoginTeacher.Visibility   = Visibility.Collapsed;
            labelPasswordTech.Visibility   = Visibility.Collapsed;
            labelPasswordAdm.Visibility    = Visibility.Collapsed;
            textBoxFIO.Visibility          = Visibility.Collapsed;
            comboBoxGroup.Visibility       = Visibility.Collapsed;
            textBoxLoginTeacher.Visibility = Visibility.Collapsed;
            passwordBoxTeacher.Visibility  = Visibility.Collapsed;
            passwordBoxAdmin.Visibility    = Visibility.Collapsed;
            labelLoginAmd.Visibility       = Visibility.Collapsed;
            textBoxLoginAdmin.Visibility   = Visibility.Collapsed;

            defaultColor_buttonStudent = buttonStudent.Background;
            defaultColor_buttonTeacher = buttonTeacher.Background;
            defaultColor_buttonAdmin   = buttonAdmin.Background;

            LoginsForDebugging();
            buttonLogin.Visibility = Visibility.Collapsed;

            try
            {
                using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                {
                    // Загрузка списка групп в комбобокс
                    var users = db.Groups;
                    foreach (Groups u in users)
                    {
                        comboBoxGroup.Items.Add(u.name_group);
                    }

                    // Загрузка списка предметов в комбобокс
                    var sub = db.Subjects;
                    foreach (Subjects u in sub)
                    {
                        comboBoxSubject.Items.Add(u.name_subject);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 14
0
        public void Load_questions_to_dataGrid()
        {
            if (tempVar_comboBox_name_of_category == 1)
            {
                try
                {
                    // Получить коллекцию ключей
                    ICollection <string> keys = dict_listSubjects.Keys;

                    foreach (var j in keys)
                    {
                        if (j == comboBox_name_of_subject_questions.SelectedItem.ToString())
                        {
                            current_id_subject = dict_listSubjects[j];
                            break;
                        }
                    }
                    /////
                    //MessageBox.Show(comboBox_name_of_category.SelectedItem.ToString(), "");
                    //MessageBox.Show(current_id_subject.ToString(), "");

                    using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                    {
                        if (comboBox_name_of_category.SelectedItem.ToString() == "      Все категории")
                        {
                            var listQuestions = from q in db.Questions.AsEnumerable()
                                                where q.id_subject_ques == current_id_subject
                                                select new { text_question = q.text_quesation, pathToPicture = q.pathToPicture };

                            dataGridTeacher_list_questions.ItemsSource = listQuestions;
                        }
                        else
                        {
                            var listQuestions = from q in db.Questions.AsEnumerable()
                                                where q.id_subject_ques == current_id_subject
                                                where q.id_category_ques == current_id_category
                                                select new { text_question = q.text_quesation, pathToPicture = q.pathToPicture };

                            dataGridTeacher_list_questions.ItemsSource = listQuestions;
                        }
                    }
                }
                catch (Exception e5)
                {
                    MessageBox.Show(e5.Message, "Load_questions_to_dataGrid", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Esempio n. 15
0
        private int GetIdCurrentCategory(string nameCategory)
        {
            int temp = 0;

            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                var idCategory = from c in db.Categories
                                 where c.name_category == nameCategory
                                 select c;
                foreach (var aa in idCategory)
                {
                    temp = aa.id_category;
                }
            }
            return(temp);
        }
Esempio n. 16
0
 private void buttonDeleteQuestion_Click(object sender, RoutedEventArgs e)
 {
     if (current_textQuestion == "")
     {
         MessageBox.Show("Сначала выберите вопрос", "Предупреждение");
     }
     else
     {
         if (MessageBox.Show("Вы уверены, что хотите удалить вопрос: \n\n" + current_textQuestion, "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
             {
                 db.Questions.RemoveRange(db.Questions.Where(x => x.text_quesation == current_textQuestion));
                 db.SaveChanges();
             }
             Load_questions_to_dataGrid();
         }
     }
 }
Esempio n. 17
0
        private void ReLoad_categories_in_comboBox()
        {
            try
            {
                // Условие проверяет, есть ли вообще элементы в comboBox_name_of_category. Если есть, то их всех удаляет.
                if (comboBox_name_of_category.HasItems)
                {
                    tempVar_comboBox_name_of_category = 0;
                    //comboBox_name_of_category.ItemsSource = null;
                    //comboBox_name_of_category.SelectedIndex = -1;
                    comboBox_name_of_category.Items.Clear();
                    comboBox_name_of_category.Text = "";
                }

                comboBox_name_of_category.Items.Add("      Все категории");

                using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                {
                    var var_name_of_category = from t in db.Categories
                                               from w in db.Subjects
                                               where comboBox_name_of_subject_questions.SelectedItem == w.name_subject
                                               //where temp_str == w.name_subject
                                               where t.id_subject_cat == w.id_subject
                                               select t;

                    foreach (var p in var_name_of_category)
                    {
                        comboBox_name_of_category.Items.Add(p.name_category);
                        //MessageBox.Show(comboBox_name_of_subject_questions.SelectedItem.ToString(), "");
                    }
                }
                comboBox_name_of_category.SelectedIndex = 0;
                tempVar_comboBox_name_of_category       = 1;
                current_name_subject = comboBox_name_of_subject_questions.SelectedItem.ToString();
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message, "ReLoad_categories_in_comboBox", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 18
0
        private void Save_ToSubjectOfTeacher()
        {
            try
            {
                // Список для id предметов из listBox_subject_of_teacher
                List <int> list_id = new List <int>();
                int        temp2   = 0;

                using (ExamTicket_dbEntities db3 = new ExamTicket_dbEntities())
                {//
                    for (int i = 0; i < listBox_subject_of_teacher.Items.Count; i++)
                    {
                        string temp = listBox_subject_of_teacher.Items[i].ToString();

                        var list_id_subject = from a in db3.Subjects
                                              where a.name_subject == temp
                                              select a;

                        foreach (var s in list_id_subject)
                        {
                            int temp1 = Convert.ToInt32(s.id_subject.ToString());
                            list_id.Add(temp1);
                        }
                    }
                }//

                // Это Id преподавателя которому нужно добавить предметы из listBox_subject_of_teacher
                temp2 = Convert.ToInt32(dataGrid_teachers_subjects_Id.Text);

                // Вызов функции для работы з БД
                RecordSubjectOfTeacher(list_id, temp2);

                // Очистка списка
                list_id.Clear();
            }
            catch (Exception e5)
            {
                MessageBox.Show(e5.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 19
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Очистка всего списка вопросов с конкретного предмета
            listQuestionsFromDb.Clear();

            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                // Выяснить количество вопросов в билете
                var countQues = from s in db.Subjects
                                where s.name_subject == (string)labelSubject.Content
                                select s;
                foreach (var tt in countQues)
                {
                    countQuestion      = (int)tt.quantity_questions_of_tiket;
                    current_id_subject = tt.id_subject;
                }

                // Загрузка вопросов в класс и массив
                var questions = from q in db.Questions
                                where q.id_subject_ques == current_id_subject
                                select new { id = q.id_question, category = q.id_category_ques, text = q.text_quesation, picture = q.pathToPicture };
                foreach (var query in questions)
                {
                    QuestionsFromDb qFromDb = new QuestionsFromDb();
                    qFromDb.Id       = query.id;
                    qFromDb.Category = query.category;
                    qFromDb.Text     = query.text;
                    qFromDb.Picture  = query.picture;

                    listQuestionsFromDb.Add(qFromDb);
                }
            }

            // Вывод вопросов и рисунков
            Generating();
        }
Esempio n. 20
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Загрузка предметов в labels
            label_name_of_subject_formWinAddEditQuestion.Content = Name_subject;


            // Загрузка категорий
            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                var var_name_of_category = from t in db.Categories
                                           from w in db.Subjects
                                           where Name_subject == w.name_subject
                                           where t.id_subject_cat == w.id_subject
                                           select t;

                foreach (var p in var_name_of_category)
                {
                    comboBox_name_of_category_formWinAddEditQuestion.Items.Add(p.name_category);
                    //MessageBox.Show(comboBox_name_of_subject_questions.SelectedItem.ToString(), "");
                }
            }
            comboBox_name_of_category_formWinAddEditQuestion.SelectedIndex = 0;
            Name_category = comboBox_name_of_category_formWinAddEditQuestion.SelectedItem.ToString();
        }
Esempio n. 21
0
        // Метод для обновления количества вопросов билета для каждого предмета
        private void button_Save_New_Value_qq_of_tiket_Click(object sender, RoutedEventArgs e)
        {
            int new_value_comboBoxQuantityQuestions = Convert.ToInt32(comboBoxQuantityQuestions.SelectedValue.ToString());

            try
            {
                using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
                {
                    var var2 = db.Subjects
                               .Where(c => c.id_subject == current_id_subject)
                               .FirstOrDefault();

                    var2.quantity_questions_of_tiket = new_value_comboBoxQuantityQuestions;

                    db.SaveChanges();
                    Load_subjects();
                }
                MessageBox.Show("Записи успешно обновлены", "Информация");
            }
            catch (Exception e2)
            {
                MessageBox.Show(e2.Message, "!!!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 22
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     db = new ExamTicket_dbEntities();
     Load_tch();
     Load_sub();
 }
Esempio n. 23
0
        private void buttonLogin_Click(object sender, RoutedEventArgs e)
        {
            // Проверка на введеные значений в поля каждой из ролей
            switch (selUser)
            {
            case selectionOfUser.Student:
                if (textBoxFIO.Text == "" || comboBoxGroup.SelectedIndex == -1 || comboBoxSubject.SelectedIndex == -1)
                {
                    MessageBox.Show("Вы не заполнили и (или) не выбрали все поля", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    WinStudent NewWinStudent = new WinStudent();
                    NewWinStudent.labelOutput_FIO.Content   = this.textBoxFIO.Text;
                    NewWinStudent.labelOutput_Group.Content = (string)this.comboBoxGroup.SelectedValue;
                    NewWinStudent.labelSubject.Content      = (string)this.comboBoxSubject.SelectedValue;
                    NewWinStudent.ShowDialog();
                }
                break;

            case selectionOfUser.Teacher:
                // Выборка из базы списка логинов и паролей преподавателей
                //
                using (ExamTicket_dbEntities db7 = new ExamTicket_dbEntities())
                {
                    bool loginOk = false;

                    var loginPassword = from a in db7.Teachers
                                        where a.login_tch == textBoxLoginTeacher.Text
                                        where a.password_tch == passwordBoxTeacher.Password
                                        select a;

                    foreach (var s in loginPassword)
                    {
                        if ((String.Compare(s.login_tch, textBoxLoginTeacher.Text) == 0) && (String.Compare(s.password_tch, passwordBoxTeacher.Password) == 0))
                        {
                            WinTeacher NewWinTeacher = new WinTeacher();

                            // Эта логин преподавателя, который будет предаватся в окно "Преподаватель" для его идентификации
                            NewWinTeacher.TeacherLogin = textBoxLoginTeacher.Text;

                            NewWinTeacher.ShowDialog();
                            loginOk = true;
                        }
                        else
                        {
                            loginOk = false;
                        }
                    }
                    if (loginOk == false)
                    {
                        MessageBox.Show("Не верный логин или пароль!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                break;

            case selectionOfUser.Admin:
                if (textBoxLoginAdmin.Text == "admin" && passwordBoxAdmin.Password == "admin")
                {
                    WinAdmin NewWinAdmin = new WinAdmin();
                    NewWinAdmin.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Не верный логин или пароль!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                break;

            default:
                MessageBox.Show("Вы не выбрали роль!", "Ошибка!");
                break;
            }
        }
Esempio n. 24
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //MessageBox.Show(Сurrent_picture, "");

            // Запоминаем первоначальный текст вопроса (это нужно для удаления записи)
            old_textQuestion = Сurrent_textQuestion;

            // Загрузка предметов в labels
            label_name_of_subject_formWinAddEditQuestion.Content = Name_subject;

            // Загрузка текста вопроса
            listBox_formWinAddEditQuestion.Text = this.Сurrent_textQuestion;


            // Загрузка категорий
            int index         = 0;
            int selectedIndex = 0;

            using (ExamTicket_dbEntities db = new ExamTicket_dbEntities())
            {
                // Поиск имени и id категории по выбраному вопросу
                var cat = from c in db.Categories
                          from q in db.Questions
                          where q.text_quesation == Сurrent_textQuestion
                          where q.id_category_ques == c.id_category
                          select c;

                foreach (var p in cat)
                {
                    Name_category = p.name_category;
                    Id_category   = p.id_category;
                }

                // Загрузка имен категорий в комбобокс
                var var_name_of_category = from t in db.Categories
                                           from w in db.Subjects
                                           where Name_subject == w.name_subject
                                           where t.id_subject_cat == w.id_subject
                                           select t;

                foreach (var p in var_name_of_category)
                {
                    comboBox_name_of_category_formWinAddEditQuestion.Items.Add(p.name_category);
                    if (Name_category == p.name_category)
                    {
                        selectedIndex = index;
                    }

                    index++;
                    //MessageBox.Show(comboBox_name_of_subject_questions.SelectedItem.ToString(), "");
                }
            }
            comboBox_name_of_category_formWinAddEditQuestion.SelectedIndex = selectedIndex;
            Name_category = comboBox_name_of_category_formWinAddEditQuestion.SelectedItem.ToString();

            // Загрузка текущего рисунка, если он есть
            if (Сurrent_picture != "")
            {
                pictureOfQuestion.Source = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\images\\" + Сurrent_picture, UriKind.Absolute));
            }
        }