Beispiel #1
0
        public PM06722 GetStudent(int id)
        {
            var db      = new OOPCSEntities();
            var student = db.PM06722.Find(id);

            return(student);
        }
Beispiel #2
0
        public PM06722[] GetStudents()
        {
            var db       = new OOPCSEntities();
            var Students = db.PM06722.ToArray();

            return(Students);
        }
Beispiel #3
0
        public void DeleteStudent(int id)
        {
            var db = new OOPCSEntities();
            var studentToDelete = db.PM06722.Find(id);

            db.PM06722.Remove(studentToDelete);
            db.SaveChanges();
        }
Beispiel #4
0
        private void viewAllStudents()
        {
            var db          = new OOPCSEntities();
            var students    = db.PM06722.ToArray();
            var studentView = new ViewStudent[students.Length];

            for (int i = 0; i < students.Length; i++)
            {
                studentView[i] = new ViewStudent(students[i]);
            }
            this.grdStudents.DataSource = studentView;
        }
Beispiel #5
0
        public void EditStudent(int id, string newCode, string newName, bool newGender, string newBirthPlace)
        {
            var db         = new OOPCSEntities();
            var oldStudent = db.PM06722.Find(id);

            oldStudent.Code     = newCode;
            oldStudent.Name     = newName;
            oldStudent.Gender   = newGender;
            oldStudent.Hometown = newBirthPlace;

            db.Entry(oldStudent).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Beispiel #6
0
        public void AddStudent(string code, string name, bool gender, string birthPlace)
        {
            var student = new PM06722();

            //student.id = id;
            student.Code     = code;
            student.Name     = name;
            student.Gender   = gender;
            student.Hometown = birthPlace;

            var db = new OOPCSEntities();

            db.PM06722.Add(student);
            db.SaveChanges();
        }