Exemplo n.º 1
0
        private void CancelButton_Click(object sender, EventArgs e)
        {   //кнопка "отмена"
            Hide();
            FrProjects fp = new FrProjects();

            fp.ShowDialog();
            Close();
        }
Exemplo n.º 2
0
        private void ChangeProject_Click(object sender, EventArgs e)
        {   //изменение проекта
            Hide();
            FrProjects fP = new FrProjects();

            fP.ShowDialog();
            Close();
        }
Exemplo n.º 3
0
 private void SaveProject_Click(object sender, EventArgs e)
 {                               //сохранение проекта в бд
     if (ProjectName.Text != "") //введен ли проект?
     {
         bool inDBS = false;     //флаг, показывающий, есть ли в бд проект с таким же названием
         if (cont.DataBaseProjectSet.Count() != 0)
         {                       //обход проектов в бд
             foreach (DataBaseProject dbp in cont.DataBaseProjectSet)
             {
                 if (dbp.Name == ProjectName.Text)   //сравнение названий проектов
                 {
                     inDBS = true;
                 }
             }
         }
         if (!inDBS)                                   //в бд нет проектов с таким же названием
         {
             DataBaseProject dbp = new DataBaseProject //создание нового проекта
             {
                 Name        = ProjectName.Text,
                 Description = ProjectDscr.Text
             };
             cont.DataBaseProjectSet.Add(dbp); //добавление в базу данных
             cont.SaveChanges();               //сохранение изменений
             Hide();
             FrProjects fp = new FrProjects();
             fp.ShowDialog();
             Close();
         }
         else
         {
             MessageBox.Show("Такой проект уже есть в базе данных");
         }
     }
     else
     {
         MessageBox.Show("Не введено название проекта");
     }
 }
Exemplo n.º 4
0
        private void RemoveProject_Click(object sender, EventArgs e) //не завершено
        {                                                            //удаление проекта
            if (DBP.Entities.Count != 0)
            {
                for (int l = DBP.Entities.Count - 1; l >= 0; l--)    //обход сущностей
                {
                    Entity ent = DBP.Entities.ElementAt(l);
                    if (ent.Forms.Count != 0)
                    {
                        for (int j = ent.Forms.Count - 1; j >= 0; j--)  //обход форм
                        {
                            Forma forma = ent.Forms.ElementAt(j);
                            if (forma.ControlElements.Count != 0)
                            {
                                for (int i = forma.ControlElements.Count - 1; i >= 0; i--) //обход элементов управления
                                {                                                          //удаление элементов управления
                                    ControlElement cE = forma.ControlElements.ElementAt(i);
                                    cE.TypeControlElement.ControlElements.Remove(cE);
                                    cE.Attribute.ControlElements.Remove(cE);
                                    forma.ControlElements.Remove(cE);
                                    cont.ControlElementSet.Remove(cE);
                                }
                            }
                            forma.TypeEvent.Forms.Remove(forma); //удаление формы из типов события
                            ent.Forms.Remove(forma);             //удаление связи между формой и сущностью
                            cont.FormaSet.Remove(forma);         //удаление формы из бд
                        }
                        //cont.FormaSet.RemoveRange()
                    }
                    if (ent.Attributes.Count != 0)
                    {
                        for (int i = ent.Attributes.Count - 1; i >= 0; i--) //обход атрибутов
                        {
                            Attribute at = ent.Attributes.ElementAt(i);
                            if (at.Conditions.Count != 0)
                            {
                                for (int j = at.Conditions.Count - 1; j >= 0; j--) //обход условий, связанных с атрибутами
                                {                                                  //удаление условий
                                    Condition cond = at.Conditions.ElementAt(j);
                                    cond.Question.Conditions.Remove(cond);
                                    at.Conditions.Remove(cond);
                                    cont.ConditionSet.Remove(cond);
                                }
                            }
                            if (at.Questions.Count != 0)
                            {
                                for (int j = at.Questions.Count - 1; j >= 0; j--)   //обход запросов
                                {
                                    Question quest = at.Questions.ElementAt(j);
                                    if (quest.Reports.Count != 0)
                                    {
                                        for (int k = quest.Reports.Count - 1; k >= 0; k--) //обход отчетов
                                        {                                                  //удаление отчетов
                                            Report rp = quest.Reports.ElementAt(k);
                                            quest.Reports.Remove(rp);
                                            cont.ReportSet.Remove(rp);
                                        }
                                    }
                                    if (quest.Conditions.Count != 0)
                                    {
                                        for (int k = quest.Conditions.Count - 1; k >= 0; k--) //обход запросов
                                        {                                                     //удаление условий
                                            Condition cond = quest.Conditions.ElementAt(k);
                                            quest.Conditions.Remove(cond);
                                            cont.ConditionSet.Remove(cond);
                                        }
                                    }
                                    //удаление запросов
                                    quest.Attributes.Remove(at);
                                    at.Questions.Remove(quest);
                                    cont.QuestionSet.Remove(quest);
                                }
                            }
                            //точка, на которой остановился
                            if (at.RelFromSource.Count != 0)
                            {
                                for (int j = at.RelFromSource.Count - 1; j >= 0; j--)
                                {
                                    at.RelFromSource.Remove(at.RelFromSource.ElementAt(j));
                                }
                            }
                            if (DBP.Entities.ElementAt(l).Attributes.ElementAt(i).RelToTarget.Count != 0)
                            {
                                for (int j = DBP.Entities.ElementAt(l).Attributes.ElementAt(i).RelToTarget.Count - 1; j >= 0; j--)
                                {
                                    DBP.Entities.ElementAt(l).Attributes.ElementAt(i).RelToTarget.Remove(DBP.Entities.ElementAt(l).Attributes.ElementAt(i).RelToTarget.ElementAt(j));
                                }
                            }
                            DBP.Entities.ElementAt(l).Attributes.Remove(DBP.Entities.ElementAt(l).Attributes.ElementAt(i));
                        }
                    }
                }
            }
            cont.DataBaseProjectSet.Remove(DBP);    //удаление проекта
            cont.SaveChanges();
            Hide();
            FrProjects fP = new FrProjects();

            fP.ShowDialog();
            Close();
        }