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

            db.PM20553.Remove(student);
            db.SaveChanges();
            db.Dispose();
        }
        private void LoadAllStudents()
        {
            var source = Business.GetStudents();

            StudentView[] list = new StudentView[source.Length];
            for (int i = 0; i < list.Length; i++)
            {
                PM20553 obj = source[i];
                list[i] = new StudentView(obj.id, obj.Code, obj.Name, !obj.Gender ? "male" : "female", obj.Hometown);
            }
            this.grdStudent.DataSource = list;
        }
        public void UpdateStudent(int id, string code, string name, bool gender, string hometown)
        {
            var     db      = new OOPCSEntities();
            PM20553 student = db.PM20553.Find(id);

            student.Code            = code;
            student.Name            = name;
            student.Gender          = gender;
            student.Hometown        = hometown;
            db.Entry(student).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            db.Dispose();
        }
        public void CreateStudent(string name, string code, bool gender, string hometown)
        {
            var     db      = new OOPCSEntities();
            PM20553 student = new PM20553();

            student.Code     = code;
            student.Name     = name;
            student.Gender   = gender;
            student.Hometown = hometown;

            db.PM20553.Add(student);
            db.SaveChanges();
            db.Dispose();
        }
示例#5
0
        void UpdateStudentForm_Load(object sender, System.EventArgs e)
        {
            PM20553 obj = Business.GetStudent(id);

            this.txtCode.Text = obj.Code;
            this.txtName.Text = obj.Name;
            if (!obj.Gender)
            {
                this.rdbMale.Checked = true;
            }
            else
            {
                this.rdbFemale.Checked = true;
            }
            this.rdbFemale.Text = obj.Hometown;
        }