コード例 #1
0
        private void LoadEducation(EducationInfo loc)
        {
            var label = new Label
            {
                Size     = new Size(95, 31),
                TabIndex = 1,
                Location = new Point(12, 35),
                Text     = "Выберите форму обучения",
            };

            label.Show();
            _com = new ComboBox
            {
                Size = new Size(121, 21),
                FormattingEnabled = true,
                Location          = new Point(107, 35),
                TabIndex          = 2,
                DropDownStyle     = ComboBoxStyle.DropDownList,
                SelectedIndex     = -1
            };
            _com.Items.AddRange(Model.GetAll.Education());
            if (loc != null)
            {
                _com.SelectedItem = loc;
            }

            Controls.Add(label);
            Controls.Add(_com);
            button1.Location = new Point(10, 69);
            Size             = new Size(245, 124);
        }
コード例 #2
0
            public static void Education(EducationInfo edu, string newValue)
            {
                var d = Db.Education.Single(a => a.ID_Education == edu.ID_Education);

                d.Name = newValue;
                Db.AcceptChanges();
            }
コード例 #3
0
        public static GroupInfo[] GetGroupFromEducation(EducationInfo edu)
        {
            var group = from g in Db.Group
                        where g.EducationRow.ID_Education == edu.ID_Education
                        select new GroupInfo(g);

            return(group.ToArray());
        }
コード例 #4
0
 public Add(string str, Type attr, EducationInfo loc)
 {
     InitializeComponent();
     if (attr == typeof(GroupInfo))
     {
         LoadEducation(loc);
     }
     addText.Text = str;
 }
コード例 #5
0
 public static void Education(EducationInfo edu)
 {
     foreach (var row in GetGroupFromEducation(edu))
     {
         Group(row);
     }
     Db.Education.RemoveEducationRow(Db.Education.Single(a => a.ID_Education == edu.ID_Education));
     Db.AcceptChanges();
 }
コード例 #6
0
            public static void Group(string str, FacultyInfo faculty, EducationInfo edu)
            {
                var temp = Db.Group.NewGroupRow();

                temp.Name         = str;
                temp.ID_Education = edu.ID_Education;
                temp.ID_Faculty   = faculty.ID_Faculty;
                Db.Group.AddGroupRow(temp);
                Db.AcceptChanges();
            }
コード例 #7
0
        private void Add_Click(object sender, EventArgs e)
        {
            string strAdd = null;

            if (_type == typeof(AuditoriumInfo))
            {
                var add = new AddAuditorium(null, 0, "", 0, "", false);
                if (add.ShowDialog() == DialogResult.OK)
                {
                    EditBase = true;
                    Model.Add.Auditorium(add.number,
                                         add.Capacity, add.NumbComp, add.QualityComp,
                                         add.AvailabilityProjector, (LocationInfo)_added);
                }
            }
            else
            {
                var           a   = new Add(null, _type, null);
                EducationInfo edu = null;
                if (a.ShowDialog() == DialogResult.OK)
                {
                    strAdd = a.strNew;
                    edu    = a.Edu;
                }
                if (strAdd != null)
                {
                    EditBase = true;
                    if (_type == typeof(FacultyInfo))
                    {
                        Model.Add.Faculty(strAdd);
                    }
                    else if (_type == typeof(TeacherInfo))
                    {
                        Model.Add.Teacher(strAdd);
                    }
                    else if (_type == typeof(LocationInfo))
                    {
                        Model.Add.Location(strAdd);
                    }
                    else if (_type == typeof(EducationInfo))
                    {
                        Model.Add.Education(strAdd);
                    }
                    else if (_type == typeof(GroupInfo))
                    {
                        Model.Add.Group(strAdd, (FacultyInfo)_added, edu);
                    }
                    else if (_type == typeof(DisciplineInfo))
                    {
                        Model.Add.Discipline(strAdd, (TeacherInfo)_added);
                    }
                }
            }
            LoadListBox();
        }
コード例 #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (addText.Text != "")
     {
         strNew = addText.Text;
         if (_com != null)
         {
             Edu = (EducationInfo)_com.SelectedItem;
         }
         DialogResult = DialogResult.OK;
         Close();
     }
 }
コード例 #9
0
            public static void Group(GroupInfo groupp, string newValue, EducationInfo eduNew)
            {
                var d = Db.Group.Single(a => a.ID_Group == groupp.ID_Group);

                if (d.Name != newValue)
                {
                    d.Name = newValue;
                }
                if (d.ID_Education != eduNew.ID_Education)
                {
                    d.ID_Education = eduNew.ID_Education;
                }
                Db.AcceptChanges();
            }
コード例 #10
0
        public static GroupInfo GetGroupFromString(string str, EducationInfo edu, string fac)
        {
            var temp = (from a in Db.Group
                        where a.Name == str
                        select a).SingleOrDefault();

            if (temp == null)
            {
                var group = Db.Group.NewGroupRow();
                group.Name         = str;
                group.ID_Education = edu.ID_Education;
                group.FacultyRow   = GetFacultyFromString(fac);
                Db.Group.AddGroupRow(group);
                Db.AcceptChanges();
                return(new GroupInfo(group));
            }
            return(new GroupInfo(temp));
        }
コード例 #11
0
 public int Compare(EducationInfo a, EducationInfo b)
 {
     return(a.Name.CompareTo(b.Name));
 }
コード例 #12
0
 private void Edit_Click(object sender, EventArgs e)
 {
     if (list.SelectedItem == null)
     {
         MessageBox.Show("Элемент не выбран");
     }
     else
     {
         if (_type == typeof(AuditoriumInfo))
         {
             var s  = (AuditoriumInfo)list.SelectedItem;
             var au = new AddAuditorium(s.Number, s.Capacity,
                                        s.AvailabilityProjector, s.NumbComp, s.QualityComp, true);
             if (au.ShowDialog() == DialogResult.OK)
             {
                 EditBase = true;
                 Model.Edit.Auditorium(s, au.number, au.Capacity, au.NumbComp, au.QualityComp,
                                       au.AvailabilityProjector);
             }
         }
         else
         {
             var           selected = list.SelectedItem;
             EducationInfo edu      = null;
             if (_type == typeof(GroupInfo))
             {
                 edu = Model.GetEducationFromGroup((GroupInfo)selected);
             }
             var    a      = new Add(selected.ToString(), _type, edu);
             string strAdd = null;
             if (a.ShowDialog() == DialogResult.OK)
             {
                 strAdd = a.strNew;
                 edu    = a.Edu;
             }
             if (strAdd != null)
             {
                 EditBase = true;
                 if (_type == typeof(FacultyInfo))
                 {
                     Model.Edit.Faculty(((FacultyInfo)selected), strAdd);
                 }
                 else if (_type == typeof(TeacherInfo))
                 {
                     Model.Edit.Teacher(((TeacherInfo)selected), strAdd);
                 }
                 else if (_type == typeof(DisciplineInfo))
                 {
                     Model.Edit.Discipline(((DisciplineInfo)selected), strAdd);
                 }
                 else if (_type == typeof(EducationInfo))
                 {
                     Model.Edit.Education(((EducationInfo)selected), strAdd);
                 }
                 else if (_type == typeof(GroupInfo))
                 {
                     Model.Edit.Group(((GroupInfo)selected), strAdd, edu);
                 }
                 else if (_type == typeof(LocationInfo))
                 {
                     Model.Edit.Location(((LocationInfo)selected), strAdd);
                 }
             }
         }
         LoadListBox();
     }
 }