Exemplo n.º 1
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.02.19
        /// 描述:创建用户班次信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static UserWorkTime CreateUserWorkTime(UserWorkTime model)
        {
            using (var edb = new EmeEntities())
            {
                edb.Entry(model).State = EntityState.Added;
                edb.SaveChanges();

                return model;
            }
        }
Exemplo n.º 2
0
        public ActionResult UserWorkTimeCreate(FormCollection fc)
        {
            var userId = Utility.CommonHelper.To<int>(fc["UserWorkTimeCreateUserId"]);
            var workTimeId = Utility.CommonHelper.To<int>(fc["WorkTimeCheckboxItem"]);
            var beginDate = Utility.CommonHelper.To<DateTime>(fc["UserWorkTimeCreateBeginTime"]);
            var endDate = Utility.CommonHelper.To<DateTime>(fc["UserWorkTimeCreateEndTime"]);

            var userworklistCreate = new List<UserWorkTime>();
            var userworklistUpdate = new List<UserWorkTime>();
            for (var i = 0; i <= (endDate - beginDate).Days; i++)
            {
                var workdate = beginDate.AddDays(i);
                var worktime = WebCommon.Cache.WorkTimeCache.GetWorkTimeCacheById(workTimeId);
                var userworktime = UserBLL.GetUserWorkTimeByUserId(userId, workdate);

                if (null != userworktime)
                {
                    userworktime.UserId = userId;
                    userworktime.WorkTimeId = workTimeId;
                    userworktime.WorkDate = workdate;
                    userworktime.MaxTaskNum = worktime.TaskNum;
                    userworktime.Status = Utility.CommonHelper.To<int>(StatusType.Active);
                    userworktime.UpdateBy = WebCommon.LoginUserManager.CurrLoginUser.UserId;
                    userworktime.UpdateTime = DateTime.Now;

                    userworklistUpdate.Add(userworktime);
                }
                else
                {
                    userworktime = new UserWorkTime()
                    {
                        UserId = userId,
                        WorkTimeId = workTimeId,
                        WorkDate = workdate,
                        CurrentTaskNum = 0,
                        MaxTaskNum = worktime.TaskNum,
                        Status = Utility.CommonHelper.To<int>(StatusType.Active),
                        CreateBy = WebCommon.LoginUserManager.CurrLoginUser.UserId,
                        CreatTime = DateTime.Now
                    };

                    userworklistCreate.Add(userworktime);
                }

            }
            UserBLL.UpdateUserWorkTimeList(userworklistCreate, userworklistUpdate, LoginUserManager.CurrLoginUser.UserId);

            return UserWorkTimePagedList(1);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.02.19
        /// 描述:更新用户班次信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool UpdateUserWorkTime(UserWorkTime model)
        {
            using (var edb = new EmeEntities())
            {
                var userWorkTime = edb.UserWorkTime.FirstOrDefault(p => p.Id == model.Id);
                if (null == userWorkTime)
                    return false;

                userWorkTime.V3TeacherScheduleId = model.V3TeacherScheduleId;
                userWorkTime.UserId = model.UserId;
                userWorkTime.WorkTimeId = model.WorkTimeId;
                userWorkTime.WorkDate = model.WorkDate;
                userWorkTime.CurrentTaskNum = model.CurrentTaskNum;
                userWorkTime.MaxTaskNum = model.MaxTaskNum;
                userWorkTime.Status = model.Status;
                userWorkTime.UpdateBy = model.UpdateBy;
                userWorkTime.UpdateTime = DateTime.Now;
                userWorkTime.Remark = model.Remark;

                edb.Entry(userWorkTime).State = EntityState.Modified;
                return edb.SaveChanges() > 0;
            }
        }