Esempio n. 1
0
        public ActionResult SubmitChangeForm(string keyValue, PlanApplyEntity entity)
        {
            string workflow = entity.ApplyType == "部门工作计划" ? "06" : "07";
            //保存历史记录
            var oldEntity = planApplyBll.GetEntity(keyValue);

            if (oldEntity != null)
            {
                var newApplyId = Request["NewId"];
                oldEntity.ID     = newApplyId;
                oldEntity.BaseId = entity.ID;
                planApplyBll.SaveForm("", oldEntity);

                var planDetailsBll = new PlanDetailsBLL();
                var list           = planDetailsBll.GetList(string.Format(" and baseid in(select id from hrs_plandetails d where d.applyid='{0}') and not exists(select 1 from hrs_planapply a where a.id=hrs_plandetails.applyid)", keyValue)).ToList();
                foreach (var epd in list)
                {//纠正因未提交丢失的历史数据。
                    epd.ApplyId = newApplyId;
                    planDetailsBll.SaveForm(epd.ID, epd);
                }
            }
            //删除旧流程创建新流程
            htworkflowbll.DeleteWorkFlowObj(keyValue);
            CommonSaveForm(keyValue, workflow, entity);
            //创建完流程实例后
            if (string.IsNullOrEmpty(keyValue))
            {
                keyValue = entity.ID;
            }
            string errorMsg = "";

            if (workflow == "06")
            {//部门工作计划
                errorMsg = DepartFlow(keyValue, entity);
            }
            else
            {//个人工作计划
                errorMsg = PersonFlow(keyValue, entity);
            }

            if (!string.IsNullOrWhiteSpace(errorMsg))
            {
                return(Error("请联系系统管理员,确认" + errorMsg + "!"));
            }

            return(Success("操作成功。"));
        }