コード例 #1
0
        public bool SaveStudentDetails(StudentDetails Stu) // calling SaveStudentMethod for insert a new record
        {
            bool result = false;
            StudentInformationEntities _entity = new StudentInformationEntities();

            {
                _entity.StudentDetails.Add(Stu);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
コード例 #2
0
        public bool DeleteStudentDetails(StudentDetails Stu) // DeleteStudentDetails method to delete record from table
        {
            bool result = false;

            using (StudentInformationEntities _entity = new StudentInformationEntities())
            {
                StudentDetails _student = _entity.StudentDetails.Where(x => x.Id == Stu.Id).Select(x => x).FirstOrDefault();
                _entity.StudentDetails.Remove(_student);
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }
コード例 #3
0
 public void Display()   // Display Method is a common method to bind the Student details in datagridview after save,update and delete operation perform.
 {
     StudentInformationEntities _entity = new StudentInformationEntities();
     {
         List <StudentInformation> _studentList = new List <StudentInformation>();
         _studentList = _entity.StudentDetails.Select(x => new StudentInformation
         {
             Id     = x.Id,
             Name   = x.Name,
             Age    = x.Age,
             City   = x.City,
             Gender = x.Gender
         }).ToList();
         dataGridView1.DataSource = _studentList;
     }
 }
コード例 #4
0
        public bool UpdateStudentDetails(StudentDetails Stu) // UpdateStudentDetails method for update a existing Record
        {
            bool result = false;

            using (StudentInformationEntities _entity = new StudentInformationEntities())
            {
                StudentDetails _student = _entity.StudentDetails.Where(x => x.Id == Stu.Id).Select(x => x).FirstOrDefault();
                _student.Name   = Stu.Name;
                _student.Age    = Stu.Age;
                _student.City   = Stu.City;
                _student.Gender = Stu.Gender;
                _entity.SaveChanges();
                result = true;
            }
            return(result);
        }