コード例 #1
0
ファイル: FlowController.cs プロジェクト: zjchenxk/SYLS
        public ActionResult NewPlanApproveStep()
        {
            string strErrText;

            //读取计划审批步骤数据
            FlowSystem flow = new FlowSystem();
            List<ApproveFlowStep> listStep = flow.LoadApproveFlowStepsByFlowType(InnoSoft.LS.Resources.Options.PlanApproveFlow, LoginAccountId, LoginStaffName, out strErrText);
            if (listStep == null)
            {
                throw new Exception(strErrText);
            }

            //生成新步骤序号
            int nStepNum = 1;
            if (listStep.Count > 0)
            {
                nStepNum = listStep[listStep.Count - 1].StepNum + 1;
            }

            //创建空的Model
            ApproveFlowStepViewModel model = new ApproveFlowStepViewModel();
            model.StepNum = nStepNum;

            model.Conditions = new List<ApproveFlowStepConditionViewModel>();
            model.Conditions.Add(new ApproveFlowStepConditionViewModel());

            //生成处理人下拉列表项
            StaffSystem staff = new StaffSystem();
            List<Staff> listStaff = staff.LoadStaffs(LoginAccountId, LoginStaffName, out strErrText);
            if (listStaff == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListStaff = new List<SelectListItem>();
            selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListStaff.AddRange(from s in listStaff
                                     select new SelectListItem
                                     {
                                         Text = s.FullName,
                                         Value = s.Id.ToString()
                                     });
            ViewData["Disposers"] = new SelectList(selectListStaff, "Value", "Text");

            return View(model);
        }
コード例 #2
0
ファイル: FlowController.cs プロジェクト: zjchenxk/SYLS
        public ActionResult NewPlanApproveStep(ApproveFlowStepViewModel model)
        {
            if (ModelState.IsValid)
            {
                //检查数据
                if (model.ConditionExpression == null || model.ConditionExpression == string.Empty)
                {
                    if (model.Conditions != null && model.Conditions.Count > 1)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.NotEnterConditionExpressionWhenMultiConditions);
                    }
                }
                else
                {
                    if (model.Conditions == null || model.Conditions.Count <= 1)
                    {
                        return Json(InnoSoft.LS.Resources.Strings.CanNotEnterConditionExpressionWhenNoOrOneCondition);
                    }
                }

                //创建数据
                ApproveFlowStep data = new ApproveFlowStep();
                data.StepName = model.StepName;
                data.StepNum = model.StepNum;
                data.FlowType = InnoSoft.LS.Resources.Options.PlanApproveFlow;
                data.DisposerId = model.DisposerId;
                data.ConditionExpression = model.ConditionExpression;

                List<ApproveFlowStepCondition> listConditions = new List<ApproveFlowStepCondition>();
                if (model.Conditions != null)
                {
                    foreach (ApproveFlowStepConditionViewModel m in model.Conditions)
                    {
                        ApproveFlowStepCondition c = new ApproveFlowStepCondition();
                        c.FlowType = InnoSoft.LS.Resources.Options.PlanApproveFlow;
                        c.ConditionNum = m.ConditionNum;
                        c.FieldName = m.FieldName;
                        c.CompareOperator = m.CompareOperator;
                        c.FieldValue = m.FieldValue;
                        listConditions.Add(c);
                    }
                }

                //保存数据
                string strErrText;
                FlowSystem flow = new FlowSystem();
                if (flow.InsertApproveFlowStep(data, listConditions, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }
コード例 #3
0
ファイル: FlowController.cs プロジェクト: zjchenxk/SYLS
        public ActionResult ModifyPlanApproveStep(string id)
        {
            string strErrText;

            //读取计划审批步骤数据
            FlowSystem flow = new FlowSystem();
            ApproveFlowStep data = flow.LoadApproveFlowStep(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            //创建Model
            ApproveFlowStepViewModel model = new ApproveFlowStepViewModel();
            model.StepNum = data.StepNum;
            model.StepName = data.StepName;
            model.DisposerId = data.DisposerId;
            model.ConditionExpression = data.ConditionExpression;

            model.Conditions = new List<ApproveFlowStepConditionViewModel>();
            model.Conditions.Add(new ApproveFlowStepConditionViewModel());

            //生成处理人下拉列表项
            StaffSystem staff = new StaffSystem();
            List<Staff> listStaff = staff.LoadStaffs(LoginAccountId, LoginStaffName, out strErrText);
            if (listStaff == null)
            {
                throw new Exception(strErrText);
            }
            List<SelectListItem> selectListStaff = new List<SelectListItem>();
            selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = string.Empty });
            selectListStaff.AddRange(from s in listStaff
                                     select new SelectListItem
                                     {
                                         Text = s.FullName,
                                         Value = s.Id.ToString()
                                     });
            ViewData["Disposers"] = new SelectList(selectListStaff, "Value", "Text", model.DisposerId);

            return View(model);
        }