Exemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Exemplo n.º 2
0
        //List<StCr> stdCrs;

        //List<InsCr> insCrs;



        private void CoursesForm_Load(object sender, EventArgs e)
        {
            this.FormClosed += (sender, e) =>
            {
                ctxAllCourses.Dispose();
                ctx.Dispose();
            };


            ctxAllCourses.Courses.Load();
            gridAllCourses.DataSource = ctxAllCourses.Courses.Local.ToBindingList();

            gridAllCourses.Columns["Exams"].Visible     = false;
            gridAllCourses.Columns["InsCrs"].Visible    = false;
            gridAllCourses.Columns["Questions"].Visible = false;
            gridAllCourses.Columns["CrsId"].Visible     = false;


            using (ExamContext ctx = new ExamContext())
            {
                ctx.Courses.Load();
                ctx.Students.Load();
                ctx.Instructors.Load();
                //ctx.StCrs.Load();
                //ctx.InsCrs.Load();

                students    = ctx.Students.Local.ToList();
                instructors = ctx.Instructors.Local.ToList();
                courses     = ctx.Courses.Local.ToList();
                //stdCrs = ctx.StCrs.Local.ToList();
                //insCrs = ctx.InsCrs.Local.ToList();
            }



            //cmbStd.DataSource = ctx.Students.Local.ToList();
            cmbStd.DataSource    = students;
            cmbStd.DisplayMember = "StName";
            cmbStd.ValueMember   = "StId";
            cmbStd.SelectedIndex = 0;


            cmbCourse.DataSource    = courses;
            cmbCourse.ValueMember   = "CrsId";
            cmbCourse.DisplayMember = "CrsName";
            cmbCourse.SelectedIndex = 0;


            cmbInstructor.DataSource    = instructors;
            cmbInstructor.DisplayMember = "InsName";
            cmbInstructor.ValueMember   = "InsId";
            cmbInstructor.SelectedIndex = 0;

            cmbInsCourses.DataSource    = courses;
            cmbInsCourses.ValueMember   = "CrsId";
            cmbInsCourses.DisplayMember = "CrsName";
            cmbInsCourses.SelectedIndex = 0;
        }
Exemplo n.º 3
0
        private void InstructorsForm_Load(object sender, EventArgs e)
        {
            this.FormClosed += (sender, e) =>
            {
                ctx.Dispose();
            };



            ctx.Instructors.Load();
            ctx.Departments.Load();
            stdList  = ctx.Instructors.Local.ToBindingList();
            deptList = ctx.Departments.Local.ToBindingList();

            stdBinding  = new BindingSource(stdList, "");
            deptBinding = new BindingSource(deptList, "");



            //public int InsId { get; set; }
            //public string InsName { get; set; }
            //public string InsEmail { get; set; }
            //public string InsHashedPwd { get; set; }
            //public int DeptId { get; set; }

            //public virtual Department Dept { get; set; }
            //public virtual ICollection<Department> Departments { get; set; }
            //public virtual ICollection<InsCr> InsCrs { get; set; }


            // we should add first datasource on grid
            grid.DataSource = stdBinding;


            grid.Columns["InsId"].Visible        = false;
            grid.Columns["InsHashedPwd"].Visible = false;
            grid.Columns["Dept"].Visible         = false;
            //grid.Columns["Departments"].Visible = false;
            grid.Columns["InsCrs"].Visible = false;


            grid.Columns.AddRange(DC);
            DC.DataSource       = deptBinding;
            DC.HeaderText       = "Departments";
            DC.DisplayMember    = "DeptName";
            DC.ValueMember      = "DeptId";
            DC.DataPropertyName = "DeptId";

            stdBinding.AddingNew += (sender, e) =>
            {
                e.NewObject = new Instructor()
                {
                    DeptId = deptList.FirstOrDefault().DeptId,
                };
            };
        }
Exemplo n.º 4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             _context.Dispose();
         }
     }
     this.disposed = true;
 }
Exemplo n.º 5
0
        private void DepartmentsForm_Load(object sender, EventArgs e)
        {
            this.FormClosed += (sender, e) =>
            {
                ctx.Dispose();
            };



            ctx.Departments.Load();
            ctx.Instructors.Load();
            deptList    = ctx.Departments.Local.ToBindingList();
            stdList     = ctx.Instructors.Local.ToBindingList();
            deptBinding = new BindingSource(deptList, "");
            stdBinding  = new BindingSource(stdList, "");

            // we should add first datasource on grid
            grid.DataSource = deptBinding;


            //grid.Columns["DeptId"].Visible = false;
            grid.Columns["Mgr"].Visible         = false;
            grid.Columns["MgrId"].Visible       = false;
            grid.Columns["DeptId"].Visible      = false;
            grid.Columns["Instructors"].Visible = false;
            //grid.Columns["Departments"].Visible = false;
            grid.Columns["Students"].Visible = false;


            //    public int DeptId { get; set; }
            //public string DeptName { get; set; }
            //public int? MgrId { get; set; }

            //public virtual Instructor Mgr { get; set; }
            //public virtual ICollection<Instructor> Instructors { get; set; }
            //public virtual ICollection<Student> Students { get; set; }


            grid.Columns.AddRange(DC);
            DC.DataSource       = stdBinding;
            DC.HeaderText       = "Manager";
            DC.DisplayMember    = "InsName";
            DC.ValueMember      = "InsId";
            DC.DataPropertyName = "MgrId";

            stdBinding.AddingNew += (sender, e) =>
            {
                e.NewObject = new Department()
                {
                };
            };
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     _context.Dispose();
 }
Exemplo n.º 7
0
        private void StudentsForm_Load(object sender, EventArgs e)
        {
            this.FormClosed += (sender, e) =>
            {
                ctx.Dispose();
            };



            ctx.Students.Load();
            ctx.Departments.Load();
            stdList  = ctx.Students.Local.ToBindingList();
            deptList = ctx.Departments.Local.ToBindingList();

            stdBinding  = new BindingSource(stdList, "");
            deptBinding = new BindingSource(deptList, "");


            grid.DataSource = stdBinding;



            //public int StId { get; set; }
            //public int Ssn { get; set; }
            //public string StName { get; set; }
            //public DateTime BirthDate { get; set; }
            //public string StEmail { get; set; }
            //public string StHashedPwd { get; set; }
            //public int DeptId { get; set; }

            //public virtual Department Dept { get; set; }
            //public virtual ICollection<Exam> Exams { get; set; }
            //public virtual ICollection<StCr> StCrs { get; set; }



            grid.Columns["StId"].Visible        = false;
            grid.Columns["StHashedPwd"].Visible = false;
            grid.Columns["Exams"].Visible       = false;
            grid.Columns["StCrs"].Visible       = false;
            grid.Columns["Dept"].Visible        = false;



            //    public int DeptId { get; set; }
            //public string DeptName { get; set; }

            DC.HeaderText = "Departments";

            // must be moved from here not to add again when reload
            grid.Columns.AddRange(DC);

            //DC.DataSource = pubList;
            DC.DataSource = deptBinding;


            DC.DisplayMember    = "DeptName";
            DC.ValueMember      = "DeptId";
            DC.DataPropertyName = "DeptId";



            stdBinding.AddingNew += (sender, e) =>
            {
                e.NewObject = new Student()
                {
                    DeptId = deptList.FirstOrDefault()?.DeptId ?? 0,
                };
            };
        }
Exemplo n.º 8
0
 public void Dispose()
 {
     dataContext.Dispose();
 }