protected void setAutoComplete()
        {
            TaaliClasses.DataList data = new TaaliClasses.DataList();
            var first = from s in data.TeacherList()
                        where s.FirstName != null
                        select s.FirstName;

            if (first != null && first.Count() > 0)
            {
                boxFirstName.AutoCompleteCustomSource.AddRange(first.ToArray());
            }
            var last = from s in data.TeacherList()
                       where s.LastName != null
                       select s.LastName;

            if (last != null && last.Count() > 0)
            {
                boxLastName.AutoCompleteCustomSource.AddRange(last.ToArray());
            }
        }
Esempio n. 2
0
        private void btnAddTeacher_Click(object sender, EventArgs e)
        {
            TeacherCategory.BaseTeacherForm btf  = new TeacherCategory.BaseTeacherForm();
            TaaliClasses.DataList           data = new TaaliClasses.DataList();
            btf.Teachers = data.TeacherList().Where(t => t.SubjectTeachers.Where(st =>
                                                                                 st.SubjectID == this.TheSubject.SubjectID && st.Active).Count() > 0 &&
                                                    (from tt in t.TimeTeachers
                                                     join uht in this.Times
                                                     on tt.TimeID equals uht.HoldingTimeID
                                                     where uht.Enabled && tt.Active
                                                     select tt.Teacher).Count() > 0 &&
                                                    (from ti in this.Times
                                                     join tt in this.TimeTableCells
                                                     on ti.HoldingTimeID equals tt.TimeTeacher.TimeID
                                                     where tt.TimeTeacher.TeacherID == t.TeacherID
                                                     select ti).Count() == 0).ToList();
            btf.SetDontShowControls();
            btf.MultiSelect = false;
            DialogResult dr = btf.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    this.TheTeacher = taali.Teachers.ToList().Where(t => t.TeacherID == btf.SelectedItems
                                                                    .SelectedItems[0].TeacherID && t.SubjectTeachers.Where(st => st.Active &&
                                                                                                                           st.SubjectID == this.TheSubject.SubjectID).Count() > 0 &&
                                                                    (from tt in t.TimeTeachers
                                                                     join ti in this.Times
                                                                     on tt.TimeID equals ti.HoldingTimeID
                                                                     where ti.Enabled
                                                                     select tt.Teacher).Count() > 0).Single();
                    this.boxTeacher.Text          = this.TheTeacher.ToString();
                    this.btnAddTeacher.Enabled    = false;
                    this.btnDeleteTeacher.Enabled = true;
                    this.btnAddClass.Enabled      = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "خطا",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.RtlReading);
                }
            }
        }