コード例 #1
0
        // Add ExamCode
        private void MCbbAddExamCodeSubject_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mCbbAddExamCodeSubject.SelectedItem != null)
            {
                if (mTabExamCode.SelectedTab == mTabAddExamCode)
                {
                    MessageBox.Show("Danh sách câu hỏi đã có sẽ được xoá để cập nhật lại theo đúng môn học!", "Thay đổi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AddExamCodeQuestionIds.Clear();
                }

                var subject = mCbbAddExamCodeSubject.SelectedItem as Subject;
                mTxtAddExamCodeSubjectId.Text = subject.SubjectId.ToString();
                mTxtAddExamCodeGradeId.Text   = subject.GradeId.ToString();
            }
        }
コード例 #2
0
        private void MBtnAddExamCode_Click(object sender, EventArgs e)
        {
            if (mCbbAddExamCodeSubject.SelectedItem != null)
            {
                if (!rqAddNumberOfQuestions.IsValid || !rgAddNumberOfQuestions.IsValid)
                {
                    if (!rqAddNumberOfQuestions.IsValid)
                    {
                        rqAddNumberOfQuestions.ControlToValidate.Focus();
                    }
                    else
                    {
                        rgAddNumberOfQuestions.ControlToValidate.Focus();
                    }

                    return;
                }

                var examCode = new ExamCodeListViewModel
                {
                    NumberOfQuestions = int.Parse(mTxtAddExamCodeNumberOfQuestions.Text),
                    SubjectId         = mTxtAddExamCodeSubjectId.Text,
                    GradeId           = int.Parse(mTxtAddExamCodeGradeId.Text),
                    IsPracticeExam    = mToggleAddExamCodeIsPracticeExam.Checked
                };

                if (examCode.NumberOfQuestions == AddExamCodeQuestionIds.Count())
                {
                    AddExamCode?.Invoke(examCode, null);
                }
                else
                {
                    MessageBox.Show("Số lượng câu hỏi phải đúng với số câu hỏi đã quy định!");
                }
            }
            else
            {
                MessageBox.Show("Chưa đủ dữ liệu!");
            }
        }