protected void btnAddPrerequisites_Click(object sender, EventArgs e)
        {
            SubjectCategory.BaseSubjectForm bsf = new SubjectCategory.BaseSubjectForm();
            bsf.MultiSelect = true;
            DialogResult dr = bsf.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (bsf.SelectedItems.SelectedItems == null || bsf.SelectedItems.SelectedItems.Count == 0)
                {
                    return;
                }
                if (this.prerequisites == null || this.prerequisites.Count() == 0)
                {
                    this.prerequisites = bsf.SelectedItems.SelectedItems;
                }
                else
                {
                    this.prerequisites.AddRange(from p in bsf.SelectedItems.SelectedItems
                                                where this.prerequisites.Where(pr =>
                                                                               pr.SubjectID == p.SubjectID).Count() == 0
                                                select p);
                }
                this.prerequisites = this.prerequisites.OrderBy(p => p.Title).ToList();
                this.boxPrerequisitesCombo.Items.Clear();
                this.boxPrerequisitesCombo.Items.AddRange(this.prerequisites.Select(p => p.ToString()).ToArray());
                this.boxPrerequisitesCombo.SelectedIndex = 0;
                this.btnDeletePrerequisites.Enabled      = true;
            }
        }
        protected void btnAddSubjects_Click(object sender, EventArgs e)
        {
            SubjectCategory.BaseSubjectForm bsf = new SubjectCategory.BaseSubjectForm();
            bsf.MultiSelect = true;
            DialogResult dr = bsf.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (bsf.SelectedItems.SelectedItems == null || bsf.SelectedItems.SelectedItems.Count == 0)
                {
                    return;
                }
                if (this.subjects == null || this.subjects.Count() == 0)
                {
                    this.subjects = bsf.SelectedItems.SelectedItems;
                }
                else
                {
                    this.subjects.AddRange(from s in bsf.SelectedItems.SelectedItems
                                           where this.subjects.Where(sub =>
                                                                     sub.SubjectID == s.SubjectID).Count() == 0
                                           select s);
                }
                this.subjects = this.subjects.OrderBy(s => s.Title).ToList();
                this.boxSubjectsCombo.Items.Clear();
                this.boxSubjectsCombo.Items.AddRange(this.subjects.Select(s => s.ToString()).ToArray());
                this.boxSubjectsCombo.SelectedIndex = 0;
                if (boxSubjectsCombo.Items.Count > 1)
                {
                    this.btnDeleteSubjects.Enabled = true;
                }
            }
        }
Exemple #3
0
        private void btnAddSubject_Click(object sender, EventArgs e)
        {
            if (this.groups == null || this.groups.Count == 0 || this.groupDataGridView.SelectedRows.Count != 1)
            {
                MessageBox.Show("لطفا یک گروه انتخاب کنید.");
                return;
            }
            GroupSubject subject = new GroupSubject();

            SubjectCategory.BaseSubjectForm bsf = new SubjectCategory.BaseSubjectForm();
            bsf.MultiSelect = true;
            bsf.SetDontShowControls();
            TaaliDataDataContext data = new TaaliDataDataContext();

            bsf.Subjects = data.MajorSubjects.Where(ms => ms.MajorID ==
                                                    this.groups[this.dataSource.Position].MajorID).Select(ms => ms.Subject).ToList();
            DialogResult dr = bsf.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (bsf.SelectedItems.SelectedItems == null || bsf.SelectedItems.SelectedItems.Count == 0)
                {
                    return;
                }
                if (this.groups[this.dataSource.Position].Subjects == null ||
                    this.groups[this.dataSource.Position].Subjects.Count == 0)
                {
                    this.groups[this.dataSource.Position].Subjects = bsf.SelectedItems.SelectedItems
                                                                     .OrderBy(sub => sub.SubjectID).ToList();
                }
                else
                {
                    List <Subject> subs = new List <Subject>();
                    subs.AddRange(this.groups[this.dataSource.Position].Subjects);
                    subs.AddRange(from s in bsf.SelectedItems.SelectedItems
                                  where this.groups[this.dataSource.Position]
                                  .Subjects.Where(su => su.SubjectID ==
                                                  s.SubjectID).Count() == 0
                                  select s);
                    this.groups[this.dataSource.Position].Subjects = subs.OrderBy(sub => sub.SubjectID).ToList();
                }
                this.groups = this.groups.OrderBy(g => g.Title).ToList();
                this.refreshGridView();
                this.subjectDataGridView.ClearSelection();
                foreach (var s in bsf.SelectedItems.SelectedItems)
                {
                    int i = this.groups[this.dataSource.Position].Subjects.IndexOf
                                (this.groups[this.dataSource.Position].Subjects.Where
                                    (sub => sub.SubjectID == s.SubjectID).Single());
                    this.subjectDataGridView.Rows[i].Selected = true;
                }
                if (this.subjectDataGridView.RowCount > 0)
                {
                    this.btnDeleteSubject.Enabled = true;
                }
                this.styleView();
            }
        }
Exemple #4
0
        private void btnAddSubject_Click(object sender, EventArgs e)
        {
            SubjectCategory.BaseSubjectForm bsf = new SubjectCategory.BaseSubjectForm();
            bsf.MultiSelect = false;
            bsf.SetDontShowControls();
            bsf.Subjects = taali.Subjects.ToList().Where(s => s.MajorSubjects.Where(ms => ms.MajorID
                                                                                    == this.TheGroup.MajorID).Count() > 0 && s.HoursPerWeak == this.Times.Count &&
                                                         (from gs in this.TheGroup.GroupSubjects
                                                          join tt in this.TimeTableCells
                                                          on gs.GroupSubjectID equals tt.GroupSubjectID
                                                          where gs.SubjectID == s.SubjectID
                                                          select gs.Subject).Count() == 0).ToList();
            DialogResult dr = bsf.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    this.TheSubject = taali.Subjects.Where(s => s.SubjectID == bsf.SelectedItems
                                                           .SelectedItems[0].SubjectID &&
                                                           (from gs in this.TheGroup.GroupSubjects
                                                            join tt in this.TimeTableCells
                                                            on gs.GroupSubjectID equals tt.GroupSubjectID
                                                            where gs.GroupID == this.TheGroup.GroupID &&
                                                            gs.SubjectID == bsf.SelectedItems.SelectedItems[0].SubjectID
                                                            select gs.Subject).Count() == 0).Single();
                    this.boxSubject.Text = this.TheSubject.Title;
                    if (this.TheSubject.HoursPerWeak != this.Times.Count)
                    {
                        throw new Exception(string.Format("{0}{1}{2}{3}",
                                                          "مدت زمانی که شما در نظر گرفتید برای ارایه این درس مناسب نمی باشد. ",
                                                          "برای ارایه این درس نیاز به ", this.TheSubject.HoursPerWeak,
                                                          " ساعت می باشد."));
                    }
                    this.btnAddSubject.Enabled    = false;
                    this.btnDeleteSubject.Enabled = true;
                    this.btnAddTeacher.Enabled    = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.TargetSite + "\n" + ex.Message);
                }
            }
        }