public int Delete( Student entity )
 {
     if ( CheckExist( entity.StudentID ) )
     {
         EnrollmentDSSStatic.GetEntities().Students.DeleteObject( entity );
         EnrollmentDSSStatic.GetEntities().SaveChanges();
         log.GhiNhanThongTinThaoTac("Deleted the student " + entity.StudentID, 1 );
         return 1;
     }
     else
     {
         return 0;
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Students EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStudents(Student student)
 {
     base.AddObject("Students", student);
 }
 /// <summary>
 /// Create a new Student object.
 /// </summary>
 /// <param name="studentID">Initial value of the StudentID property.</param>
 /// <param name="facultyID">Initial value of the FacultyID property.</param>
 /// <param name="identityNo">Initial value of the IdentityNo property.</param>
 /// <param name="validityDate">Initial value of the ValidityDate property.</param>
 /// <param name="province">Initial value of the Province property.</param>
 /// <param name="roomID">Initial value of the RoomID property.</param>
 public static Student CreateStudent(global::System.String studentID, global::System.String facultyID, global::System.String identityNo, global::System.DateTime validityDate, global::System.String province, global::System.String roomID)
 {
     Student student = new Student();
     student.StudentID = studentID;
     student.FacultyID = facultyID;
     student.IdentityNo = identityNo;
     student.ValidityDate = validityDate;
     student.Province = province;
     student.RoomID = roomID;
     return student;
 }
 public int DeleteStudent(Student student)
 {
     EnrollmentDSSStatic.GetEntities().DeleteObject( student );
     EnrollmentDSSStatic.GetEntities().SaveChanges();
     return 1;
 }
 public void UpdateStudent( Student student )
 {
     var kq = ( from m in EnrollmentDSSStatic.GetEntities().Students
                where m.StudentID.Equals( student.StudentID )
                select m ).FirstOrDefault();
     kq = student;
     EnrollmentDSSStatic.GetEntities().SaveChanges();
     log.GhiNhanThongTinThaoTac( "Updated the student " + student.StudentID, 1 );
 }
        public void Save( Student entity )
        {
            if ( entity != null )
            {
                Student temp = EnrollmentDSSStatic.GetEntities().Students.SingleOrDefault( x => x.StudentID == entity.StudentID );
                if ( temp == null )
                {
                    EnrollmentDSSStatic.GetEntities().AddToStudents( entity );
                }
                else
                {
                    UpdateStudent( entity );
                }
                EnrollmentDSSStatic.GetEntities().SaveChanges();

            }
        }
        public void QuickEditStudent( Student _student )
        {
            Student student = ( from m in EnrollmentDSSStatic.GetEntities().Students
                                where m.StudentID == _student.StudentID
                                select m ).FirstOrDefault();

            student.LastName = _student.LastName;
            student.FirstName = _student.FirstName;
            student.Sex = _student.Sex;
            student.BirthDay = _student.BirthDay;
            student.ClassID = _student.ClassID;
            student.RoomID = _student.RoomID;

            EnrollmentDSSStatic.GetEntities().SaveChanges();
        }
 public Enrollment_DSS.Data.Entities.Student makeNewItem()
 {
     Enrollment_DSS.Data.Entities.Student newStudent = new Enrollment_DSS.Data.Entities.Student();
     if ( this.CurrentStudent != null )
     {
         newStudent.Address = this.Address;
         newStudent.BirthDay = this.BirthDay;
         newStudent.FacultyID = this.FacultyItem.FacultyID;
         newStudent.IntoSchoolYear = this.YearItem;
         newStudent.FirstName = this.FirstName;
         newStudent.LastName = this.LastName;
         newStudent.StudentID = this.StudentID;
         newStudent.Sex = this.CboGender.IndexOf( this.GenderItem ).ToString();
         newStudent.Ethnic = this.Ethnicity;
         newStudent.BirthDay = this.BirthDay;
         newStudent.Address = this.Address;
         newStudent.Religion = this.Religion;
         newStudent.Phone = this.Phone;
         newStudent.ClassID = this.ClassID;
         newStudent.IdentityNo = this.IdentityID;
         newStudent.ValidityDate = this.ValidityDate;
         newStudent.Province = this.ProvinceItem;
         newStudent.RoomID = this.RoomItem.RoomID;
     }
     return newStudent;
 }
 public void AddStudentMethod()
 {
     if (checkField())
     {
         if ( StudentRepository.GetRepository().CheckExist( this.StudentID ) )
         {
             MessageBox.Show( "This account already exists, please edit the information." );
         }
         else
         {
             Enrollment_DSS.Data.Entities.Student newStudent = new Enrollment_DSS.Data.Entities.Student();
             newStudent = makeNewItem();
             MessageBox.Show( newStudent.ToString() );
             this.StudentList.addStudent( newStudent );
             this.CurrentStudent = this.StudentList.FirstOrDefault();
         }
     }
     else
     {
         MessageBox.Show( "You need to provide sufficient information" );
     }
 }