Exemple #1
0
        public ActionResult PointEdit(int id = 0)
        {
            int pointId = RequestInt("pointId");

            Point_Records record = null;

            if (id > 0)
            {
                record = Bll.BllPoint_Records.First(o => o.Id == id);
                if (record == null)
                {
                    return(MessageBoxAndReturn("发生错误,记录不存在!"));
                }
                pointId = record.PointId.Value;
            }

            Point_List pointModel = null;

            if (pointId > 0)
            {
                pointModel = Bll.BllPoint_List.First(o => o.Id == pointId);
                if (pointModel == null)
                {
                    return(MessageBoxAndReturn("积分项不存在!"));
                }
            }
            ViewBag.pointId    = pointId;
            ViewBag.pointModel = pointModel;
            return(View(record));
        }
Exemple #2
0
        public ActionResult ChildPointSave()
        {
            int id = RequestInt("id");

            if (id == 0)
            {
                return(MessageBoxAndReturn("发生错误,记录不存在!"));
            }

            bool   isPass = RequestBool("ispass");
            string remark = RequestString("remark");

            Point_Records record = Bll.BllPoint_Records.First(o => o.Id == id);

            if (record == null)
            {
                return(MessageBoxAndReturn("发生错误,记录不存在!"));
            }
            if (record.IsApprove.Value)
            {
                return(MessageBoxAndReturn("该记录已审批过,禁止修改!"));
            }

            record.IsApprove   = true;
            record.Remark      = remark;
            record.IsPass      = isPass;
            record.ParUserId   = MyInfo.Id;
            record.ParUserName = MyInfo.RealName;
            record.ApproveTime = DateTime.Now;

            if (Bll.BllPoint_Records.Update(record, o => o.Id == id) > 0)
            {
                return(MessageBoxAndJump("审批成功!", "/point/point/childpointlist/" + record.UserId));
            }
            else
            {
                return(MessageBoxAndReturn("审批失败,请联系管理员!"));
            }
        }
Exemple #3
0
        public ActionResult PointSave()
        {
            int    id         = RequestInt("id");
            int    pointId    = RequestInt("pointId");
            int    pointscore = RequestInt("pointscore");
            string eventtime  = RequestString("eventtime");
            string content    = RequestString("content");
            string userIds    = RequestString("userid");

            if (string.IsNullOrEmpty(content))
            {
                return(MessageBoxAndReturn("请填写事件描述!"));
            }
            if (string.IsNullOrEmpty(eventtime))
            {
                return(MessageBoxAndReturn("请填写事发时间!"));
            }
            if (!Tools.Usual.Utils.IsDate(eventtime))
            {
                return(MessageBoxAndReturn("请填写正确时间格式!"));
            }
            if (pointscore == 0)
            {
                return(MessageBoxAndReturn("请选择添加分值,不能为空或0!"));
            }

            //多选用户Id
            var uids   = userIds.TrimEnd(',').Split(',');
            int userId = uids[0].ToInt32();

            Point_Records record = null;

            if (id > 0)
            {
                record = Bll.BllPoint_Records.First(o => o.Id == id);
                if (record == null)
                {
                    return(MessageBoxAndReturn("发生错误,记录不存在!"));
                }
                if (record.IsApprove.Value)
                {
                    return(MessageBoxAndReturn("该记录已审批过,禁止修改!"));
                }

                //自定义申请,目标员工
                DateTime time = eventtime.ToDateTime();
                record.UserId       = userId > 0 ? userId : MyInfo.Id;
                record.UserName     = userId > 0 ? Bll.BllMng_User.GetNameById(userId) : MyInfo.RealName;
                record.Score        = pointscore;
                record.EventTime    = time;
                record.Month        = time.Month;
                record.Year         = time.Year;
                record.Content      = content;
                record.PointId      = pointId;
                record.IsPass       = false;
                record.UpdateTime   = DateTime.Now;
                record.CreateUserId = MyInfo.Id;

                if (Bll.BllPoint_Records.Update(record, o => o.Id == id) > 0)
                {
                    return(MessageBoxAndJump("修改成功!", "/point/point/pointlist"));
                }
                else
                {
                    return(MessageBoxAndReturn("修改失败,请联系管理员!"));
                }
            }
            else
            {
                var      dateTimeNow = DateTime.Now;
                DateTime time        = eventtime.ToDateTime();

                if (uids == null || uids.Length == 0 || (uids.Length == 1 && userId == 0))
                {
                    //未选择,默认当前用户
                    record              = new Point_Records();
                    record.Score        = pointscore;
                    record.EventTime    = time;
                    record.Content      = content;
                    record.PointId      = pointId;
                    record.UserId       = MyInfo.Id;
                    record.UserName     = MyInfo.RealName;
                    record.IsApprove    = false;
                    record.IsPass       = false;
                    record.Month        = time.Month;
                    record.Year         = time.Year;
                    record.ParUserId    = 0;
                    record.ParUserName  = "";
                    record.CreateTime   = dateTimeNow;
                    record.CreateUserId = MyInfo.Id;
                    record.UpdateTime   = dateTimeNow;
                    id = Bll.BllPoint_Records.Insert(record);
                }
                else
                {
                    List <Point_Records> list = new List <Point_Records>();
                    //批量申请
                    foreach (var uid in uids)
                    {
                        if (int.TryParse(uid, out userId) && userId > 0)
                        {
                            record              = new Point_Records();
                            record.Score        = pointscore;
                            record.EventTime    = time;
                            record.Content      = content;
                            record.PointId      = pointId;
                            record.UserId       = userId;
                            record.UserName     = Bll.BllMng_User.GetNameById(userId);
                            record.IsApprove    = true;
                            record.ApproveTime  = dateTimeNow;
                            record.IsPass       = true;
                            record.Month        = time.Month;
                            record.Year         = time.Year;
                            record.ParUserId    = MyInfo.Id;
                            record.ParUserName  = MyInfo.RealName;
                            record.CreateTime   = dateTimeNow;
                            record.CreateUserId = MyInfo.Id;
                            record.UpdateTime   = dateTimeNow;
                            record.Remark       = "";
                            list.Add(record);
                        }
                    }
                    id = Bll.BllPoint_Records.Insert(list);
                }
                if (id > 0)
                {
                    return(MessageBoxAndJump("提交成功!", "/point/point/pointlist"));
                }
                else
                {
                    return(MessageBoxAndReturn("提交失败,请联系管理员!"));
                }
            }
        }