public List <StudentDetail> Display() // Display Method is a common method to bind the Student details in datagridview after save,update and delete operation perform. { using (StudentInformationEntities _entity = new StudentInformationEntities()) { return(_entity.StudentDetails.ToList()); } }
public bool SaveStudentDetails(StudentDetail Stu) // calling SaveStudentMethod for insert a new record { bool result = false; using (StudentInformationEntities _entity = new StudentInformationEntities()) { _entity.StudentDetails.Add(Stu); _entity.SaveChanges(); result = true; } return(result); }
public bool DeleteStudentDetails(StudentDetail Stu) // DeleteStudentDetails method to delete record from table { bool result = false; using (StudentInformationEntities _entity = new StudentInformationEntities()) { StudentDetail _student = _entity.StudentDetails.Where(x => x.Id == Stu.Id).Select(x => x).FirstOrDefault(); _entity.StudentDetails.Remove(_student); _entity.SaveChanges(); result = true; } return(result); }
public bool UpdateStudentDetails(StudentDetail Stu) // UpdateStudentDetails method for update a existing Record { bool result = false; using (StudentInformationEntities _entity = new StudentInformationEntities()) { StudentDetail _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); }