예제 #1
0
        public Main()
        {
            InitializeComponent();

            var listTextBox = new List <TextBox>();

            listTextBox.Add(txtID);
            listTextBox.Add(txtName);
            listTextBox.Add(txtLastname);
            listTextBox.Add(txtEmail);

            var listLabel = new List <Label>();

            listLabel.Add(lblID);
            listLabel.Add(lblName);
            listLabel.Add(lblLastname);
            listLabel.Add(lblEmail);
            listLabel.Add(lblPagination);

            Object[] objects =
            {
                imgBox,
                Properties.Resources.logo,
                tableStudents,
                numControl
            };

            student = new LStudent(listTextBox, listLabel, objects);
        }
예제 #2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="age"></param>
        /// <param name="sex"></param>
        /// <returns></returns>
        public async Task <ActionResult <int> > Update(string name, string sex, int age, int id)
        {
            LStudent s = db.LStudent.Find(id);

            s.Name            = name;
            s.Sex             = sex;
            s.Age             = age;
            db.Entry(s).State = EntityState.Modified;
            return(await db.SaveChangesAsync());
        }
예제 #3
0
        public async Task <ActionResult <int> > Add(string name, string sex, int age)
        {
            LStudent s = new LStudent();

            s.Name = name;
            s.Sex  = sex;
            s.Age  = age;
            db.LStudent.Add(s);
            return(await db.SaveChangesAsync());
        }