Exemplo n.º 1
0
        private void btn_edit_Click(object sender, EventArgs e)
        {
            try
            {
                string text = string.Empty;
                if (Access(out text, out TestModel selectedTest))
                {
                    NewTestForm testForm = new NewTestForm(UserID);
                    testForm.TestID            = selectedTest.TestID;
                    testForm.txt_testName.Text = selectedTest.TestName;
                    testForm.txt_timer.Text    = selectedTest.Timer.ToString();

                    var           allCategory = categoryService.GetAll();
                    CategoryModel topic       = allCategory.Where(x => x.CategoryId == selectedTest.CategoryID).Single();
                    CategoryModel subCategory = allCategory.Where(x => x.CategoryId == topic.ParentCategoryId).SingleOrDefault();

                    string categoryName = string.Empty;
                    if (subCategory != null)
                    {
                        CategoryModel category = allCategory.Where(x => x.CategoryId == subCategory.ParentCategoryId).SingleOrDefault();
                        categoryName = category != null ? category.CategoryName : string.Empty;
                    }

                    string[] categoryList = new string[] { categoryName, subCategory?.CategoryName, topic.CategoryName };
                    DisplayCategory(testForm, categoryList, selectedTest.isLiveCheck);

                    testForm.ShowDialog();
                    DisplayAllTest();
                }
                else
                {
                    MessageBox.Show(text, "Error");
                }
            }
Exemplo n.º 2
0
 private void txt_addNew_Click(object sender, EventArgs e)
 {
     try
     {
         NewTestForm newTest = new NewTestForm(UserID);
         newTest.ShowDialog();
         DisplayAllTest();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }