Exemplo n.º 1
0
        public void DeleteStudent(int id)
        {
            var db       = new OOPCSEntities();
            var @student = db.PM20530.Find(id);

            db.PM20530.Remove(@student);
            db.SaveChanges();
        }
Exemplo n.º 2
0
        public void UpdateStudent(int id, string code, string name, string hometown, string gender)
        {
            var db         = new OOPCSEntities();
            var oldStudent = db.PM20530.Find(id);

            oldStudent.Code     = code;
            oldStudent.Name     = name;
            oldStudent.Hometown = hometown;
            bool isFemale = true;

            if (gender == "Female")
            {
                isFemale = false;
            }
            else
            {
                isFemale = true;
            }
            oldStudent.Gender          = isFemale;
            db.Entry(oldStudent).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 3
0
        public void CreateStudent(string code, string name, string hometown, string gender)
        {
            var newstudent = new PM20530();

            newstudent.Code     = code;
            newstudent.Name     = name;
            newstudent.Hometown = hometown;
            bool isFemale = true;

            if (gender == "Female")
            {
                isFemale = false;
            }
            else
            {
                isFemale = true;
            }
            var db = new OOPCSEntities();

            newstudent.Gender = isFemale;
            db.PM20530.Add(newstudent);
            db.SaveChanges();
        }
Exemplo n.º 4
0
        public PM20530 GetStudent(int id)
        {
            var db = new OOPCSEntities();

            return(db.PM20530.Find(id));
        }
Exemplo n.º 5
0
        public PM20530[] GetStudent()
        {
            var db = new OOPCSEntities();

            return(db.PM20530.ToArray());
        }