Beispiel #1
0
        public Edit_Test(int testId, int questionId, Select_Question_To_Edit parent)
        {
            InitializeComponent();

            this.testId     = testId;
            this.questionId = questionId;
            this.parent     = parent;

            //наследуемый метод
            base.Top_Button(bunifuImageButton1_Min, bunifuImageButton1_Max, bunifuImageButton2_Norm);
            this.bunifuImageButton1_Close.Click += BunifuImageButton1_Close_Click;

            using (Tests_DBContainer tests = new Tests_DBContainer())
            {
                if (questionId == 0)
                {
                    var question = new TestQuestion()
                    {
                        Question = "Новый вопрос", TestId = this.testId, IsActual = 1,
                    };
                    tests.TestQuestion.Add(question);
                    tests.SaveChanges();
                    this.questionId = question.Id;
                    this.parent.renderQuestionList();
                }

                var rowQuestion = tests.TestQuestion.FirstOrDefault(t => t.Id == this.questionId);
                if (rowQuestion != null)
                {
                    textBox_AddQuestion.Text = rowQuestion.Question;
                }

                renderAnswerList();
            }
        }
 private void Button_EditTest_Click(object sender, EventArgs e)
 {
     if (currentTest > 0)
     {
         Select_Question_To_Edit selectQuestion = new Select_Question_To_Edit(currentTest, this);
         selectQuestion.ShowDialog();
     }
 }