コード例 #1
0
        public bool Update(TraineeCourseEntity traineeCourse)
        {
            try
            {
                tblTraineeCourse newTraineeCourse = new tblTraineeCourse();

                newTraineeCourse.ID               = traineeCourse.ID;
                newTraineeCourse.TraineeID        = traineeCourse.TraineeEntity.ID;
                newTraineeCourse.CourseID         = traineeCourse.CourseEntity.ID;
                newTraineeCourse.RegistrationDate = traineeCourse.RegistrationDate;
                newTraineeCourse.Duration         = traineeCourse.Duration;
                newTraineeCourse.Cost             = traineeCourse.Cost;
                newTraineeCourse.CreatedBy        = traineeCourse.CreatedBy;
                newTraineeCourse.CreatedDate      = traineeCourse.CreatedDate;
                newTraineeCourse.UpdatedBy        = traineeCourse.UpdatedBy;
                newTraineeCourse.UpdatedDate      = traineeCourse.UpdatedDate;

                TIMSDBEntities   entity           = new TIMSDBEntities();
                tblTraineeCourse oldTraineeCourse = entity.tblTraineeCourses.Where(x => x.ID == traineeCourse.ID).FirstOrDefault();
                entity.Entry(oldTraineeCourse).CurrentValues.SetValues(newTraineeCourse);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public int Save(TraineeCourseEntity traineeCourse)
        {
            try
            {
                tblTraineeCourse TraineeCourse = new tblTraineeCourse();

                TraineeCourse.ID               = traineeCourse.ID;
                TraineeCourse.TraineeID        = traineeCourse.TraineeEntity.ID;
                TraineeCourse.CourseID         = traineeCourse.CourseEntity.ID;
                TraineeCourse.RegistrationDate = traineeCourse.RegistrationDate;
                TraineeCourse.Duration         = traineeCourse.Duration;
                TraineeCourse.Cost             = traineeCourse.Cost;
                TraineeCourse.CreatedBy        = traineeCourse.CreatedBy;
                TraineeCourse.CreatedDate      = traineeCourse.CreatedDate;
                TraineeCourse.UpdatedBy        = traineeCourse.UpdatedBy;
                TraineeCourse.UpdatedDate      = traineeCourse.UpdatedDate;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblTraineeCourses.Add(TraineeCourse);
                entity.SaveChanges();

                return(TraineeCourse.ID); //return currently created record ID
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(TraineePaymentEntity traineePayment)
        {
            try
            {
                tblTraineePayment TraineePayment = new tblTraineePayment();

                TraineePayment.ID = traineePayment.ID;
                TraineePayment.TraineeCourseID = traineePayment.TraineeCourseEntity.ID;
                TraineePayment.PaymentDate     = traineePayment.PaymentDate;
                TraineePayment.PaymentAmount   = traineePayment.PaymentAmount;
                TraineePayment.CreatedBy       = traineePayment.CreatedBy;
                TraineePayment.CreatedDate     = traineePayment.CreatedDate;
                TraineePayment.UpdatedBy       = traineePayment.UpdatedBy;
                TraineePayment.UpdatedDate     = traineePayment.UpdatedDate;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblTraineePayments.Add(TraineePayment);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool Save(TraineeMessageEntity traineeMessage)
        {
            try
            {
                tblTraineeMessage TraineeMessage = new tblTraineeMessage();

                TraineeMessage.ID          = traineeMessage.ID;
                TraineeMessage.TraineeID   = traineeMessage.TraineeEntity.ID;
                TraineeMessage.PhoneNumber = traineeMessage.PhoneNumber;
                TraineeMessage.Message     = traineeMessage.Message;
                TraineeMessage.Status      = traineeMessage.Status;
                TraineeMessage.CreatedBy   = traineeMessage.CreatedBy;
                TraineeMessage.CreatedDate = traineeMessage.CreatedDate;
                TraineeMessage.UpdatedBy   = traineeMessage.UpdatedBy;
                TraineeMessage.UpdatedDate = traineeMessage.UpdatedDate;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblTraineeMessages.Add(TraineeMessage);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(TraineePaymentEntity traineePayment)
        {
            try
            {
                tblTraineePayment newTraineePayment = new tblTraineePayment();

                newTraineePayment.ID = traineePayment.ID;
                newTraineePayment.TraineeCourseID = traineePayment.TraineeCourseEntity.ID;
                newTraineePayment.PaymentDate     = traineePayment.PaymentDate;
                newTraineePayment.PaymentAmount   = traineePayment.PaymentAmount;
                newTraineePayment.CreatedBy       = traineePayment.CreatedBy;
                newTraineePayment.CreatedDate     = traineePayment.CreatedDate;
                newTraineePayment.UpdatedBy       = traineePayment.UpdatedBy;
                newTraineePayment.UpdatedDate     = traineePayment.UpdatedDate;

                TIMSDBEntities    entity            = new TIMSDBEntities();
                tblTraineePayment oldTraineePayment = entity.tblTraineePayments.Where(x => x.ID == traineePayment.ID).FirstOrDefault();
                entity.Entry(oldTraineePayment).CurrentValues.SetValues(newTraineePayment);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(TraineeMessageEntity traineeMessage)
        {
            try
            {
                tblTraineeMessage newTraineeMessage = new tblTraineeMessage();

                newTraineeMessage.ID          = traineeMessage.ID;
                newTraineeMessage.TraineeID   = traineeMessage.TraineeEntity.ID;
                newTraineeMessage.PhoneNumber = traineeMessage.PhoneNumber;
                newTraineeMessage.Message     = traineeMessage.Message;
                newTraineeMessage.Status      = traineeMessage.Status;
                newTraineeMessage.CreatedBy   = traineeMessage.CreatedBy;
                newTraineeMessage.CreatedDate = traineeMessage.CreatedDate;
                newTraineeMessage.UpdatedBy   = traineeMessage.UpdatedBy;
                newTraineeMessage.UpdatedDate = traineeMessage.UpdatedDate;

                TIMSDBEntities    entity            = new TIMSDBEntities();
                tblTraineeMessage oldTraineeMessage = entity.tblTraineeMessages.Where(x => x.ID == traineeMessage.ID).FirstOrDefault();
                entity.Entry(oldTraineeMessage).CurrentValues.SetValues(newTraineeMessage);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public int Save(TraineeEntity trainee)
        {
            try
            {
                tblTrainee Trainee = new tblTrainee();

                Trainee.ID              = trainee.ID;
                Trainee.Fullname        = trainee.Fullname;
                Trainee.BirthDate       = trainee.BirthDate;
                Trainee.GenderID        = trainee.GenderEntity.ID;
                Trainee.AcademicLevelID = trainee.AcademicLevelEntity.ID;
                Trainee.BranchID        = trainee.BranchEntity.ID;
                Trainee.Address         = trainee.Address;
                Trainee.PhoneNumber     = trainee.PhoneNumber;
                Trainee.Photo           = trainee.Photo;
                Trainee.CreatedBy       = trainee.CreatedBy;
                Trainee.CreatedDate     = trainee.CreatedDate;
                Trainee.UpdatedBy       = trainee.UpdatedBy;
                Trainee.UpdatedDate     = trainee.UpdatedDate;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblTrainees.Add(Trainee);
                entity.SaveChanges();
                return(Trainee.ID);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool Update(TraineeEntity trainee)
        {
            try
            {
                tblTrainee newTrainee = new tblTrainee();

                newTrainee.ID              = trainee.ID;
                newTrainee.Fullname        = trainee.Fullname;
                newTrainee.BirthDate       = trainee.BirthDate;
                newTrainee.GenderID        = trainee.GenderEntity.ID;
                newTrainee.AcademicLevelID = trainee.AcademicLevelEntity.ID;
                newTrainee.BranchID        = trainee.BranchEntity.ID;
                newTrainee.Address         = trainee.Address;
                newTrainee.PhoneNumber     = trainee.PhoneNumber;
                newTrainee.Photo           = trainee.Photo;
                newTrainee.CreatedBy       = trainee.CreatedBy;
                newTrainee.CreatedDate     = trainee.CreatedDate;
                newTrainee.UpdatedBy       = trainee.UpdatedBy;
                newTrainee.UpdatedDate     = trainee.UpdatedDate;

                TIMSDBEntities entity     = new TIMSDBEntities();
                tblTrainee     oldTrainee = entity.tblTrainees.Where(x => x.ID == trainee.ID).FirstOrDefault();
                entity.Entry(oldTrainee).CurrentValues.SetValues(newTrainee);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool Delete(AcademicLevelEntity academicLevel)
        {
            try
            {
                TIMSDBEntities   entity        = new TIMSDBEntities();
                tblAcademicLevel AcademicLevel = entity.tblAcademicLevels.Where(x => x.ID == academicLevel.ID).FirstOrDefault();

                entity.tblAcademicLevels.Remove(AcademicLevel);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Delete(BranchEntity Branch)
        {
            try
            {
                TIMSDBEntities entity    = new TIMSDBEntities();
                tblBranch      tblBranch = entity.tblBranches.Where(x => x.ID == Branch.ID).FirstOrDefault();

                entity.tblBranches.Remove(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Delete(RoleEntity role)
        {
            try
            {
                TIMSDBEntities entity = new TIMSDBEntities();
                tblRole        Role   = entity.tblRoles.Where(x => x.ID == role.ID).FirstOrDefault();

                entity.tblRoles.Remove(Role);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #12
0
        public bool Delete(TraineeCourseEntity traineeCourse)
        {
            try
            {
                TIMSDBEntities   entity        = new TIMSDBEntities();
                tblTraineeCourse TraineeCourse = entity.tblTraineeCourses.Where(x => x.ID == traineeCourse.ID).FirstOrDefault();

                entity.tblTraineeCourses.Remove(TraineeCourse);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Delete(GenderEntity gender)
        {
            try
            {
                TIMSDBEntities entity = new TIMSDBEntities();
                tblGender      Gender = entity.tblGenders.Where(x => x.ID == gender.ID).FirstOrDefault();

                entity.tblGenders.Remove(Gender);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(RoleEntity role)
        {
            try
            {
                tblRole Role = new tblRole();

                Role.ID   = role.ID;
                Role.Name = role.Name;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblRoles.Add(Role);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(BranchEntity Branch)
        {
            try
            {
                tblBranch tblBranch = new tblBranch();

                tblBranch.ID   = Branch.ID;
                tblBranch.Name = Branch.Name;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblBranches.Add(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(AcademicLevelEntity academicLevel)
        {
            try
            {
                tblAcademicLevel AcademicLevel = new tblAcademicLevel();

                AcademicLevel.ID    = academicLevel.ID;
                AcademicLevel.Title = academicLevel.Title;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblAcademicLevels.Add(AcademicLevel);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(GenderEntity gender)
        {
            try
            {
                tblGender Gender = new tblGender();

                Gender.ID    = gender.ID;
                Gender.Title = gender.Title;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblGenders.Add(Gender);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(BranchEntity Branch)
        {
            try
            {
                tblBranch newBranch = new tblBranch();

                newBranch.ID   = Branch.ID;
                newBranch.Name = Branch.Name;

                TIMSDBEntities entity    = new TIMSDBEntities();
                tblBranch      oldBranch = entity.tblBranches.Where(x => x.ID == Branch.ID).FirstOrDefault();
                entity.Entry(oldBranch).CurrentValues.SetValues(newBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(AcademicLevelEntity academicLevel)
        {
            try
            {
                tblAcademicLevel newAcademicLevel = new tblAcademicLevel();

                newAcademicLevel.ID    = academicLevel.ID;
                newAcademicLevel.Title = academicLevel.Title;

                TIMSDBEntities   entity           = new TIMSDBEntities();
                tblAcademicLevel oldAcademicLevel = entity.tblAcademicLevels.Where(x => x.ID == academicLevel.ID).FirstOrDefault();
                entity.Entry(oldAcademicLevel).CurrentValues.SetValues(newAcademicLevel);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(GenderEntity gender)
        {
            try
            {
                tblGender newGender = new tblGender();

                newGender.ID    = gender.ID;
                newGender.Title = gender.Title;

                TIMSDBEntities entity    = new TIMSDBEntities();
                tblGender      oldGender = entity.tblGenders.Where(x => x.ID == gender.ID).FirstOrDefault();
                entity.Entry(oldGender).CurrentValues.SetValues(newGender);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(RoleEntity role)
        {
            try
            {
                tblRole newRole = new tblRole();

                newRole.ID   = role.ID;
                newRole.Name = role.Name;

                TIMSDBEntities entity  = new TIMSDBEntities();
                tblRole        oldRole = entity.tblRoles.Where(x => x.ID == role.ID).FirstOrDefault();
                entity.Entry(oldRole).CurrentValues.SetValues(newRole);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(CourseEntity course)
        {
            try
            {
                tblCourse Course = new tblCourse();

                Course.ID          = course.ID;
                Course.Title       = course.Title;
                Course.Description = course.Description;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblCourses.Add(Course);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Save(UserEntity user)
        {
            try
            {
                tblUser User = new tblUser();

                User.ID       = user.ID;
                User.Username = user.Username;
                User.Password = user.Password;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblUsers.Add(User);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(CourseEntity course)
        {
            try
            {
                tblCourse newCourse = new tblCourse();

                newCourse.ID          = course.ID;
                newCourse.Title       = course.Title;
                newCourse.Description = course.Description;

                TIMSDBEntities entity    = new TIMSDBEntities();
                tblCourse      oldCourse = entity.tblCourses.Where(x => x.ID == course.ID).FirstOrDefault();
                entity.Entry(oldCourse).CurrentValues.SetValues(newCourse);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Update(UserEntity user)
        {
            try
            {
                tblUser newUser = new tblUser();

                newUser.ID       = user.ID;
                newUser.Username = user.Username;
                newUser.Password = user.Password;

                TIMSDBEntities entity  = new TIMSDBEntities();
                tblUser        oldUser = entity.tblUsers.Where(x => x.ID == user.ID).FirstOrDefault();
                entity.Entry(oldUser).CurrentValues.SetValues(newUser);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }