private async void cbTest_SelectionChangeCommitted(object sender, EventArgs e)
        {
            int i = 1;
            ApplicationViewModel applicationViewModel = new ApplicationViewModel();
            var index = cbTest.SelectedIndex;

            test = handbookTests.ToList()[index];
            lblGradeName.Visible   = true;
            lblGradeName.Text      = test.GradeName;
            lblGradeNumber.Visible = true;
            lblGradeNumber.Text    = test.GradeNumber.ToString();
            lblSubjectName.Visible = true;
            lblSubjectName.Text    = test.SubjectName;
            await applicationViewModel.GetQuestions(user.Login, user.Password);

            var Questions = applicationViewModel.handbookQuestions.Where(q => q.TestId == test.Id).ToList();

            dataGridView.Rows.Clear();
            foreach (var question in Questions)
            {
                var rowNumber = dataGridView.Rows.Add();
                dataGridView.Rows[rowNumber].Cells["Id"].Value               = question.Id;
                dataGridView.Rows[rowNumber].Cells["No"].Value               = i++;
                dataGridView.Rows[rowNumber].Cells["TestId"].Value           = question.TestId;
                dataGridView.Rows[rowNumber].Cells["TestName"].Value         = question.TestName;
                dataGridView.Rows[rowNumber].Cells["TestQuantity"].Value     = question.TestQuantity;
                dataGridView.Rows[rowNumber].Cells["TestQuantityPass"].Value = question.TestQuantityPass;
                dataGridView.Rows[rowNumber].Cells["SubjectId"].Value        = question.SubjectId;
                dataGridView.Rows[rowNumber].Cells["SubjectName"].Value      = question.SubjectName;
                dataGridView.Rows[rowNumber].Cells["GradeId"].Value          = question.GradeId;
                dataGridView.Rows[rowNumber].Cells["GradeNumber"].Value      = question.GradeNumber;
                dataGridView.Rows[rowNumber].Cells["Content"].Value          = question.Content;
                dataGridView.Rows[rowNumber].Cells["Answer"].Value           = question.Answer;
            }
        }
 public AddQuestionForm(User user, HandbookTest test, QuestionForm questionForm, QuestionDB question)
 {
     InitializeComponent();
     this.user         = user;
     this.test         = test;
     this.questionForm = questionForm;
     txtId.Text        = question.Id.ToString();
     txtContent.Text   = question.Content;
     txtAnswer.Text    = question.Answer.ToString();
 }
 public AddQuestionForm(User user, HandbookTest test, QuestionForm questionForm)
 {
     if (!String.IsNullOrEmpty(Properties.Settings.Default.Language))
     {
         // ВАЖНО: Устанавливать язык нужно до создания элементов формы!
         // Это можно сделать глобально, в рамках приложения в классе Program (см. файл Program.cs).
         System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);
         System.Threading.Thread.CurrentThread.CurrentCulture   = System.Globalization.CultureInfo.GetCultureInfo(Properties.Settings.Default.Language);
     }
     InitializeComponent();
     this.user         = user;
     this.test         = test;
     this.questionForm = questionForm;
 }
        private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            HandbookTest handbookTest = new HandbookTest();

            handbookTest.GradeName    = dataGridView.Rows[e.RowIndex].Cells["GradeName"].FormattedValue.ToString();
            handbookTest.GradeId      = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["GradeId"].FormattedValue.ToString());
            handbookTest.GradeNumber  = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["GradeNumber"].FormattedValue.ToString());
            handbookTest.Name         = dataGridView.Rows[e.RowIndex].Cells["testName"].FormattedValue.ToString();
            handbookTest.SubjectName  = dataGridView.Rows[e.RowIndex].Cells["SubjectName"].FormattedValue.ToString() + " " + dataGridView.Rows[e.RowIndex].Cells["GradeName"].FormattedValue.ToString();
            handbookTest.SubjectId    = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["SubjectId"].FormattedValue.ToString());
            handbookTest.Quantity     = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["Quantity"].FormattedValue.ToString());
            handbookTest.QuantityPass = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["QuantityPass"].FormattedValue.ToString());
            handbookTest.Id           = Int32.Parse(dataGridView.Rows[e.RowIndex].Cells["Id"].FormattedValue.ToString());
            AddTestForm testForm = new AddTestForm(user, handbookTests, handbookSubjects, this, handbookTest);

            testForm.Show();
        }
        public AddTestForm(User user, IEnumerable <HandbookTest> handbookTests, IEnumerable <HandbookSubjects> handbookSubjects, TestForm testForm, HandbookTest handbookTest)
        {
            InitializeComponent();
            cbSubjectAndGrade.DropDownStyle = ComboBoxStyle.DropDownList;
            this.user                   = user;
            this.testForm               = testForm;
            this.txtId.Text             = handbookTest.Id.ToString();
            this.txtSubjectId.Text      = handbookTest.SubjectId.ToString();
            this.txtName.Text           = handbookTest.Name.ToString();
            this.cbSubjectAndGrade.Text = handbookTest.SubjectName.ToString() + " " + handbookTest.GradeName.ToString();
            this.txtQuantity.Text       = handbookTest.Quantity.ToString();
            this.txtQuantityPass.Text   = handbookTest.QuantityPass.ToString();
            subject = handbookSubjects.ToList().Where(s => s.Id == handbookTest.SubjectId).FirstOrDefault();

            var indexOfIntegerValue = handbookSubjects.ToList().IndexOf(subject);



            foreach (var subject in handbookSubjects)
            {
                cbSubjectAndGrade.Items.Add(subject.Name + " " + subject.GradeNumber + subject.GradeName);
            }

            cbSubjectAndGrade.SelectionChangeCommitted += delegate
            {
                var index = cbSubjectAndGrade.SelectedIndex;
                var list  = handbookSubjects.ToList();
                subject = list[index];
            };

            cbSubjectAndGrade.SelectedItem = cbSubjectAndGrade.Items[indexOfIntegerValue];
        }