Example #1
0
        private bool IsNameAlreadyExists()
        {
            bool isExists = false;

            if (this.gridEditCategory.IsVisible == true)
            {
                isExists = GridLineCategory.IsNameAlreadyExists(this.textBoxCategoryName.Text);
            }
            else if (this.gridEditTest.IsVisible == true)
            {
                isExists = GridLineTest.IsNameAlreadyExists(
                    this.textBoxTestName.Text, this.entityParentId);
            }
            else if (this.gridEditQuestion.IsVisible == true)
            {
                isExists = GridLineQuestion.IsNameAlreadyExists(
                    this.textBoxQuestionName.Text, this.entityParentId);
            }
            else if (this.gridEditAnswer.IsVisible == true)
            {
                isExists = GridLineAnswer.IsNameAlreadyExists(
                    this.textBoxAnswerText.Text, this.entityParentId);
            }

            return(isExists);
        }
Example #2
0
        private void ShowAllCategories()
        {
            this.ShowHeaderCategory();

            this.ClearTheList();

            using (TestingSystemEntities db = new TestingSystemEntities())
            {
                this.level = Level.AllCategories;

                List <Category> listOfAllCategories = null;

                if (this.isTeacher)
                {
                    listOfAllCategories
                        = (
                              from category in db.Category.Include("Test")
                              select category
                              )
                          .ToList();
                }
                else
                {
                    listOfAllCategories
                        = (
                              from category in db.Category.Include("Test")
                              where category.Active == true
                              select category
                              )
                          .ToList();
                }


                GridLineCategory gridLineCategory = null;

                for (int i = 0; i < listOfAllCategories.Count(); i++)
                {
                    gridLineCategory
                        = new GridLineCategory(
                              i,
                              listOfAllCategories[i],
                              this.isTeacher
                              );


                    // Установить стиль кнопки внутри grid
                    (gridLineCategory.Children[0] as Button).Style = (Style)(this.Resources["styleButtonForList"]);

                    (gridLineCategory.Children[0] as Button).Click += ButtonCategoryLine_Click;

                    if (this.isTeacher)
                    {
                        this.CreateEditingButtons(gridLineCategory, listOfAllCategories[i].Id);
                    }

                    this.stackPanelSelection.Children.Add(gridLineCategory);
                }

                // Если Учитель, то добавим кнопку "Добавить" категорию.
                if (this.isTeacher)
                {
                    if (gridLineCategory == null)
                    {
                        gridLineCategory = new GridLineCategory();
                    }

                    this.CreateAddButton(gridLineCategory);
                }
            }
        }