public void DeleteStudent(int id)
        {
            var db      = new OOPServerEntities3();
            var student = db.Students.Find(id);

            db.Students.Remove(student);
            db.SaveChanges();
        }
        private void GrdFaculty_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var     db          = new OOPServerEntities3();
            string  Facultyname = this.grdFaculty.CurrentRow.Cells[0].Value.ToString();
            Faculty faculty     = db.Faculties.Single(x => x.Faculty_Name.Equals(Facultyname));

            this.txtFacultyName.Text = faculty.Faculty_Name;
        }
        private void GrdClass_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var    db        = new OOPServerEntities3();
            string classname = this.grdClass.CurrentRow.Cells[0].Value.ToString();
            Class  @class    = db.Classes.Single(x => x.Name.Equals(classname));

            this.txtClassName.Text = @class.Name;
        }
        public void DeleteFacuty(int id)
        {
            var db       = new OOPServerEntities3();
            var @Faculty = db.Faculties.Find(id);

            db.Faculties.Remove(@Faculty);
            db.SaveChanges();
        }
        public void DeleteClass(int id)
        {
            var db     = new OOPServerEntities3();
            var @class = db.Classes.Find(id);

            db.Classes.Remove(@class);
            db.SaveChanges();
        }
        private void LoadAllFaculty()
        {
            var db = new OOPServerEntities3();

            this.grdFaculty.DataSource = db.Faculties.Select(x => new
            {
                FacultyName = x.Faculty_Name
            }).ToList();
            this.grdFaculty.Columns[0].HeaderText = "Faculty name";
        }
 private void BtnUpdateClass_Click(object sender, EventArgs e)
 {
     try
     {
         var    db        = new OOPServerEntities3();
         string classname = this.grdClass.CurrentRow.Cells[0].Value.ToString();
         Class  @class    = db.Classes.Single(x => x.Name.Equals(classname));
         @class.Name = this.txtClassName.Text;
         db.SaveChanges();
         this.LoadAllClass();
         MessageBox.Show("Update Class Successfully");
     }
     catch
     {
         MessageBox.Show("Update Class Failed");
     }
 }
        public void UpdateStudent(int id, string code, string name, DateTime birthday, int class_id, string email, string hometown, int faculty, double averageScore)
        {
            var db      = new OOPServerEntities3();
            var student = db.Students.Find(id);

            student.Code          = code;
            student.Name          = name;
            student.Birthday      = birthday;
            student.Class_id      = class_id;
            student.Email         = email;
            student.Home_Town     = hometown;
            student.Faculty_ID    = faculty;
            student.Average_Score = averageScore;

            db.Entry(student).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
 private void BtnUpdateFaculty_Click(object sender, EventArgs e)
 {
     try
     {
         var     db          = new OOPServerEntities3();
         string  facultyname = this.grdFaculty.CurrentRow.Cells[0].Value.ToString();
         Faculty faculty     = db.Faculties.Single(x => x.Faculty_Name.Equals(facultyname));
         faculty.Faculty_Name = this.txtFacultyName.Text;
         db.SaveChanges();
         this.LoadAllFaculty();
         MessageBox.Show("Update Faculty Successfully");
     }
     catch
     {
         MessageBox.Show("Update Faculty Failed");
     }
 }
 private void BtnAddFaculty_Click(object sender, EventArgs e)
 {
     try
     {
         var     db      = new OOPServerEntities3();
         Faculty faculty = new Faculty();
         faculty.Faculty_Name = this.txtFacultyName.Text;
         db.Faculties.Add(faculty);
         db.SaveChanges();
         this.LoadAllFaculty();
         MessageBox.Show("Add Faculty Successfully");
     }
     catch
     {
         MessageBox.Show("Add Faculty Failed");
     }
 }
 private void BtnAddClass_Click(object sender, EventArgs e)
 {
     try
     {
         var   db     = new OOPServerEntities3();
         Class @class = new Class();
         @class.Name = this.txtClassName.Text;
         db.Classes.Add(@class);
         db.SaveChanges();
         this.LoadAllClass();
         MessageBox.Show("Add Class Successfully");
     }
     catch
     {
         MessageBox.Show("Add Class Failed");
     }
 }
Esempio n. 12
0
        public void CreateStudent(string code, string name, DateTime birthday, int class_id, string email, string hometown, int faculty, double averageScore)
        {
            var student = new Student();

            student.Code          = code;
            student.Name          = name;
            student.Birthday      = birthday;
            student.Class_id      = class_id;
            student.Email         = email;
            student.Home_Town     = hometown;
            student.Faculty_ID    = faculty;
            student.Average_Score = averageScore;

            var db = new OOPServerEntities3();

            db.Students.Add(student);
            db.SaveChanges();
        }
        private void LoadAllClass()
        {
            var db = new OOPServerEntities3();

            this.grdClass.DataSource = db.Classes.Select(x => new
            {
                Name = x.Name
            }).ToList();
            this.grdClass.Columns[0].HeaderText = "Class name";

            //var classes = this.Business.GetClasses();
            //var classViews = new ClassView[classes.Length];
            //for (int i = 0; i < classViews.Length; i++)
            //{
            //    classViews[i] = new ClassView(classes[i]);
            //}
            //this.grdClass.DataSource = classViews;
        }
        private void BtnDeleteFaculty_Click(object sender, EventArgs e)
        {
            var          db          = new OOPServerEntities3();
            string       facultyname = this.grdFaculty.CurrentRow.Cells[0].Value.ToString();
            DialogResult dr          = MessageBox.Show("Are you sure to delete this", "Confirm", MessageBoxButtons.YesNo);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                try
                {
                    Faculty faculty = db.Faculties.Single(x => x.Faculty_Name.Equals(facultyname));
                    db.Faculties.Remove(faculty);
                    db.SaveChanges();
                    this.LoadAllFaculty();
                    MessageBox.Show("Delete successfully");
                }
                catch
                {
                    MessageBox.Show("Delete failed");
                }
            }
        }
Esempio n. 15
0
        public Class[] GetClasses()
        {
            var db = new OOPServerEntities3();

            return(db.Classes.ToArray());
        }
Esempio n. 16
0
        public Faculty GetFaculty(int id)
        {
            var db = new OOPServerEntities3();

            return(db.Faculties.Find(id));
        }
Esempio n. 17
0
        public Student[] getSort()
        {
            var db = new OOPServerEntities3();

            return(db.Students.ToArray());
        }
Esempio n. 18
0
        public Student GetStudent(int id)
        {
            var db = new OOPServerEntities3();

            return(db.Students.Find(id));
        }
Esempio n. 19
0
        public Faculty[] getFacultyes()
        {
            var db = new OOPServerEntities3();

            return(db.Faculties.ToArray());
        }
Esempio n. 20
0
        public Class GetClass(int id)
        {
            var db = new OOPServerEntities3();

            return(db.Classes.Find(id));
        }