Esempio n. 1
0
        //指标增加修改
        public ActionResult KpiAdd(int id = 0, int year = 0, int month = 0)
        {
            int pid = RequestInt("pid");

            CheckDate(ref year, ref month);

            var process = Bll.BllKpi_Process.First(o => o.Id == pid);

            if (process != null && (process.IsCreated ?? false))
            {
                return(MessageBoxAndReturn("该进程已生成,禁止继续添加指标!"));
            }

            Kpi_Records record = null;

            if (id > 0)
            {
                record = Bll.BllKpi_Records.First(o => o.Id == id);
                if (record != null && record.IsApprove.Value)
                {
                    return(MessageBoxAndReturn("该指标已被评分,不能修改!"));
                }
            }

            ViewBag.pid       = pid;
            ViewBag.year      = year;
            ViewBag.month     = month;
            ViewBag.startyear = StartYear;
            return(View(record));
        }
Esempio n. 2
0
        /// <summary>
        /// 更新进程状态
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public static bool UpdateProcessStatus(Kpi_Records record)
        {
            using (var trans = Db.Context.BeginTransaction())
            {
                int id = trans.Update(record, o => o.Id == record.Id);
                if (id == 0)
                {
                    trans.Rollback();
                    return(false);
                }
                //查询进程是否存在
                var process = trans.From <Kpi_Process>().Where(o => o.UserId == record.UserId && o.Year == record.Year && o.Month == record.Month).ToFirst();
                if (process == null)
                {
                    trans.Rollback();
                    return(false);
                }

                //查询进程下其他所有指标
                var recordlist = trans.From <Kpi_Records>().Where(o => o.Pid == process.Id).ToList();
                if (recordlist == null || recordlist.Count == 0)
                {
                    trans.Rollback();
                    return(false);
                }

                //更新状态和总分,指标
                process.IsApprove = recordlist.Count(o => o.IsApprove == false) == 0;
                process.Score     = recordlist.Where(o => o.IsApprove == true).Sum(o => o.FinishScore).Value;
                id = trans.Update(process, o => o.Id == process.Id);
                if (id == 0)
                {
                    trans.Rollback();
                    return(false);
                }
                trans.Commit();
                return(true);
            }
        }
Esempio n. 3
0
        public ActionResult KpiSave(int year = 0, int month = 0)
        {
            CheckDate(ref year, ref month);
            int    id             = RequestInt("id");
            int    pid            = RequestInt("pid");
            string name           = RequestString("name");
            string content        = RequestString("content");
            string target_highest = RequestString("target_highest");
            string target_normal  = RequestString("target_normal");
            string target_lowest  = RequestString("target_lowest");
            int    score          = RequestInt("score");
            string targetremark   = RequestString("targetremark");
            int    paruserid      = RequestInt("paruserid");

            var process = Bll.BllKpi_Process.First(o => o.Id == pid);

            if (process != null && (process.IsCreated ?? false))
            {
                return(MessageBoxAndReturn("该进程已生成,禁止继续添加指标!"));
            }

            Kpi_Records record = null;

            if (id > 0)
            {
                record = Bll.BllKpi_Records.First(o => o.Id == id);
                if (record != null && record.IsApprove.Value)
                {
                    return(MessageBoxAndReturn("该指标已被评分,不能修改!"));
                }

                year  = record.Year.Value;
                month = record.Month.Value;

                record.Name           = name;
                record.Content        = content;
                record.Target_Highest = target_highest;
                record.Target_Lowest  = target_lowest;
                record.Target_Normal  = target_normal;
                record.Score          = score;
                record.TargetRemark   = targetremark;
                record.ParUserId      = paruserid > 0 ? paruserid : MyInfo.ParUserId;
                record.ParUserName    = Bll.BllMng_User.GetNameById(record.ParUserId.Value);
                record.UserId         = MyInfo.Id;
                record.UserName       = MyInfo.RealName;
                id = Bll.BllKpi_Records.Update(record, o => o.Id == id);
            }
            else
            {
                record                = new Kpi_Records();
                record.Pid            = pid;
                record.Year           = year;
                record.Month          = month;
                record.Name           = name;
                record.Content        = content;
                record.Target_Highest = target_highest;
                record.Target_Lowest  = target_lowest;
                record.Target_Normal  = target_normal;
                record.Score          = score;
                record.FinishScore    = 0;
                record.ParScore       = 0;
                record.TargetRemark   = targetremark;
                record.ParUserId      = paruserid > 0 ? paruserid : MyInfo.ParUserId;
                record.ParUserName    = Bll.BllMng_User.GetNameById(record.ParUserId.Value);
                record.UserId         = MyInfo.Id;
                record.UserName       = MyInfo.RealName;
                record.CreateTime     = DateTime.Now;
                record.Remark         = "";
                record.IsApprove      = false;
                record.IsCreated      = false;
                id = Bll.BllKpi_Records.Insert(record);
            }
            if (id > 0)
            {
                return(Redirect($"/kpi/kpi/kpilist?year={year}&month={month}"));
            }
            else
            {
                return(MessageBoxAndReturn("提交失败,请联系管理员!"));
            }
        }