public ActionResult ModifyPlanApproveStep(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.Id = model.Id; 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.StepId = model.Id; 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.UpdateApproveFlowStep(data, listConditions, LoginAccountId, LoginStaffName, out strErrText)) { return(Json(string.Empty)); } else { return(Json(strErrText)); } } return(View(model)); }
public ActionResult ModifyPriceApproveStep(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 PriceApproveFlowStepViewModel model = new PriceApproveFlowStepViewModel(); model.StepNum = data.StepNum; model.StepName = data.StepName; model.DisposerId = data.DisposerId; model.ConditionExpression = data.ConditionExpression; model.Conditions = new List <PriceApproveFlowStepConditionViewModel>(); model.Conditions.Add(new PriceApproveFlowStepConditionViewModel()); //生成处理人下拉列表项 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)); }
/// <summary> /// 下移指定流程步骤数据 /// </summary> /// <param name="nId">步骤编码</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns></returns> public bool MoveDownApproveStep(long nId, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (FlowDAO dao = new FlowDAO()) { //读取步骤数据 ApproveFlowStep data = dao.LoadApproveFlowStep(nId, nOpStaffId, strOpStaffName, out strErrText); if (data == null) { return(false); } //读取当前流程的所有步骤数据 List <ApproveFlowStep> listStep = dao.LoadApproveFlowStepsByFlowType(data.FlowType, nOpStaffId, strOpStaffName, out strErrText); if (listStep.Count == 0) { return(false); } //调整当前步骤序号 int nStepNum = data.StepNum; if (nStepNum < listStep.Count) { nStepNum++; } data.StepNum = nStepNum; //修改步骤数据 if (!dao.UpdateApproveFlowStep(data, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }
/// <summary> /// 修改审批流程步骤数据 /// </summary> /// <param name="data">流程步骤数据集</param> /// <param name="listConditions">步骤执行条件数据集</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns></returns> public bool UpdateApproveFlowStep(ApproveFlowStep data, List <ApproveFlowStepCondition> listConditions, long nOpStaffId, string strOpStaffName, out string strErrText) { try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (FlowDAO dao = new FlowDAO()) { //修改步骤数据 if (!dao.UpdateApproveFlowStep(data, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //删除原条件数据 if (!dao.DeleteApproveFlowStepConditions(data.Id, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } //保存新条件数据 foreach (ApproveFlowStepCondition condition in listConditions) { if (!dao.InsertApproveFlowStepCondition(condition, nOpStaffId, strOpStaffName, out strErrText)) { return(false); } } } transScope.Complete(); } return(true); } catch (Exception e) { strErrText = e.Message; return(false); } }
/// <summary> /// 新增审批流程步骤数据 /// </summary> /// <param name="data">流程步骤数据集</param> /// <param name="listConditions">步骤执行条件数据集</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns></returns> public long InsertApproveFlowStep(ApproveFlowStep data, List <ApproveFlowStepCondition> listConditions, long nOpStaffId, string strOpStaffName, out string strErrText) { long nId = 0; try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (FlowDAO dao = new FlowDAO()) { //保存步骤数据 nId = dao.InsertApproveFlowStep(data, nOpStaffId, strOpStaffName, out strErrText); if (nId <= 0) { return(0); } //保存条件数据 foreach (ApproveFlowStepCondition condition in listConditions) { condition.StepId = nId; if (!dao.InsertApproveFlowStepCondition(condition, nOpStaffId, strOpStaffName, out strErrText)) { return(0); } } } transScope.Complete(); } return(nId); } catch (Exception e) { strErrText = e.Message; return(-1); } }
/// <summary> /// 修改审批流程步骤数据 /// </summary> /// <param name="data">流程步骤数据集</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns></returns> public bool UpdateApproveFlowStep(ApproveFlowStep data, long nOpStaffId, string strOpStaffName, out string strErrText) { //创建参数数组 SqlParameter[] Params = { MakeParam(ID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.Id), MakeParam(STEPNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.StepName), MakeParam(STEPNUM_PARAM, SqlDbType.Int, 4, ParameterDirection.Input, (object)data.StepNum), MakeParam(FLOWTYPE_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)data.FlowType), MakeParam(DISPOSERID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)data.DisposerId), MakeParam(CONDITIONEXPRESSION_PARAM, SqlDbType.NVarChar, 100, ParameterDirection.Input, (object)data.ConditionExpression ?? System.DBNull.Value), MakeParam(OPSTAFFID_PARAM, SqlDbType.BigInt, 8, ParameterDirection.Input, (object)nOpStaffId), MakeParam(OPSTAFFNAME_PARAM, SqlDbType.NVarChar, 50, ParameterDirection.Input, (object)strOpStaffName) }; if (Execute("UpdateApproveFlowStep", Params, out strErrText) >= 0) { return(true); } else { return(false); } }
/// <summary> /// 修改审批流程步骤数据 /// </summary> /// <param name="data">流程步骤数据集</param> /// <param name="listCondition">步骤执行条件数据集</param> /// <param name="nOpStaffId">操作员工编码</param> /// <param name="strOpStaffName">操作员工姓名</param> /// <param name="strErrText">出错信息</param> /// <returns></returns> public bool UpdateApproveFlowStep(ApproveFlowStep data, List <ApproveFlowStepCondition> listCondition, long nOpStaffId, string strOpStaffName, out string strErrText) { FlowRule rule = new FlowRule(); return(rule.UpdateApproveFlowStep(data, listCondition, nOpStaffId, strOpStaffName, out strErrText)); }