public void AddStudent(StuInfoTable stuTable)
        {
            StudentsInfoDBEntities StuDB = new StudentsInfoDBEntities();
               try
               {
               IDataAccess idata = new DataServerse();
               int getId = idata.Search((StuInfoTable stu) => stu.ID == stuTable.ID).Take(1).Count();
               if (getId != 1)
               {
                   StuDB.StuInfoTable.Add(stuTable);
                   StuDB.SaveChanges();
                   MessageBox.Show("成功添加1条信息!");
               }
               else
                   MessageBox.Show("学号已存在!");

               }
               catch (Exception e)
               {
               MessageBox.Show("添加数据发生异常:" + e.Message);
               }
               finally
               {
               StuDB.Dispose();
               }
        }
        private void AddStuMethod(object parameter)
        {
            IDataAccess iData = new DataServerse();
               StuInfoTable stuTable = new StuInfoTable()
               {
               ID = StudentModel.ID,
               Name = StudentModel.Name,
               Age = StudentModel.Age,
               Sex = StudentModel.Sex,
               Birthday = StudentModel.Birthday,
               PhoneNumber = StudentModel.PhoneNumber,
               Address = StudentModel.Address,
               Grades = StudentModel.Grades
               };

                iData.AddStudent(stuTable);
        }
        public int DeleteStudent(StuInfoTable stuTalbe)
        {
            StudentsInfoDBEntities stuDB = new StudentsInfoDBEntities();
            int result = 0;
            try
            {
                //List<StuInfoTable> stuEnu = stuDB.StuInfoTable.Where(item => item.ID == stuTalbe.ID).ToList<StuInfoTable>();
                //StuInfoTable stu = stuEnu[0];

                stuDB.StuInfoTable.Attach(stuTalbe);

                stuDB.StuInfoTable.Remove(stuTalbe);
                result= stuDB.SaveChanges();
            }
            catch (Exception e)
            {
                MessageBox.Show("删除出现错误:" + e.Message);
            }
            finally
            {
                stuDB.Dispose();
            }
            return result;
        }