예제 #1
0
파일: FlowSystem.cs 프로젝트: zjchenxk/SYLS
 /// <summary>
 /// 读取指定审批流程步骤数据
 /// </summary>
 /// <param name="nId">步骤编码</param>
 /// <param name="nOpStaffId">操作员工编码</param>
 /// <param name="strOpStaffName">操作员工姓名</param>
 /// <param name="strErrText">出错信息</param>
 /// <returns></returns>
 public ApproveFlowStep LoadApproveFlowStep(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     ApproveFlowStep data;
     try
     {
         using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
         {
             using (FlowDAO dao = new FlowDAO())
             {
                 data = dao.LoadApproveFlowStep(nId, nOpStaffId, strOpStaffName, out strErrText);
                 if (data == null)
                 {
                     return null;
                 }
             }
             transScope.Complete();
         }
         return data;
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return null;
     }
 }
예제 #2
0
파일: FlowRule.cs 프로젝트: zjchenxk/SYLS
        /// <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;
            }
        }
예제 #3
0
파일: FlowRule.cs 프로젝트: zjchenxk/SYLS
        /// <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;
            }
        }
예제 #4
0
파일: FlowRule.cs 프로젝트: zjchenxk/SYLS
        /// <summary>
        /// 上移指定流程步骤数据
        /// </summary>
        /// <param name="nId">步骤编码</param>
        /// <param name="nOpStaffId">操作员工编码</param>
        /// <param name="strOpStaffName">操作员工姓名</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns></returns>
        public bool MoveUpApproveStep(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;
                        }

                        //调整当前步骤序号
                        int nStepNum = data.StepNum;
                        if (nStepNum > 1) 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;
            }
        }
예제 #5
0
파일: FlowRule.cs 프로젝트: zjchenxk/SYLS
        /// <summary>
        /// 根据流程类别读取指定审批流程的步骤数据
        /// </summary>
        /// <param name="strFlowType">流程类别</param>
        /// <param name="nOpStaffId">操作员工编码</param>
        /// <param name="strOpStaffName">操作员工姓名</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns></returns>
        public List<ApproveFlowStep> LoadApproveFlowStepsByFlowType(string strFlowType, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            List<ApproveFlowStep> listStep;
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (FlowDAO dao = new FlowDAO())
                    {
                        //读取流程步骤数据
                        listStep = dao.LoadApproveFlowStepsByFlowType(strFlowType, nOpStaffId, strOpStaffName, out strErrText);
                        if (listStep == null)
                        {
                            return null;
                        }

                        //读取流程所有步骤的条件数据
                        List<ApproveFlowStepCondition> listCondition = dao.LoadApproveFlowStepConditionsByFlowType(strFlowType, nOpStaffId, strOpStaffName, out strErrText);
                        if (listCondition == null)
                        {
                            return null;
                        }

                        //将条件存入流程步骤数据集中
                        foreach (ApproveFlowStep step in listStep)
                        {
                            long nStepId = step.Id;
                            string strConditionExpression = step.ConditionExpression;

                            //读取当前步骤条件数据
                            List<ApproveFlowStepCondition> list = listCondition.FindAll(delegate(ApproveFlowStepCondition c) { return c.StepId == nStepId; });
                            if (list.Count > 1)
                            {
                                string[] strConditions = new string[list.Count + 1];//为什么加1?因为条件序号是从1开始的
                                for (int i = 0; i < list.Count; i++)
                                {
                                    string strFieldName = list[i].FieldName;
                                    string strCompareOperator = list[i].CompareOperator;
                                    string strFieldValue = list[i].FieldValue;

                                    strConditions[i + 1] = strFieldName + strCompareOperator + strFieldValue;
                                }
                                step.Conditions = string.Format(strConditionExpression, strConditions);
                            }
                            else if (list.Count == 1)
                            {
                                string strFieldName = list[0].FieldName;
                                string strCompareOperator = list[0].CompareOperator;
                                string strFieldValue = list[0].FieldValue;

                                step.Conditions = strFieldName + strCompareOperator + strFieldValue;
                            }
                        }
                    }
                    transScope.Complete();
                }
                return listStep;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return null;
            }
        }
예제 #6
0
        /// <summary>
        /// 提交打印送货单
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool SubmitPrintDeliverBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    #region 提交送货单

                    long nContractId = 0;
                    using (DeliverDAO dao = new DeliverDAO())
                    {
                        if (!dao.SubmitPrintDeliverBill(nId, out nContractId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return false;
                        }
                    }

                    #endregion

                    #region 提交打印特殊合同

                    if (nContractId > 0)
                    {
                        #region 修改合同打印状态

                        using (ContractDAO dao = new ContractDAO())
                        {
                            if (!dao.SubmitPrintContract(nContractId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return false;
                            }
                        }

                        #endregion

                        #region 读取合同价格最大超出比例和超出金额

                        decimal decOverPercentage = 0;
                        decimal decOverAmount = 0;

                        using (ContractDAO dao = new ContractDAO())
                        {
                            //读取合同价格超出比例
                            decOverPercentage = dao.LoadContractPriceOverPercentage(nContractId, nOpStaffId, strOpStaffName, out strErrText);

                            //读取合同价格超出金额
                            decOverAmount = dao.LoadContractPriceOverAmount(nContractId, nOpStaffId, strOpStaffName, out strErrText);
                        }

                        #endregion

                        #region 处理合同价格审批流程

                        int nApproveFlowStepNum = 0;
                        string strApproveFlowStepName = string.Empty;
                        long nApproverId = 0;
                        string strApproverName = string.Empty;

                        using (FlowDAO dao = new FlowDAO())
                        {
                            List<ApproveFlowStep> listStep = dao.LoadApproveFlowStepsByFlowType(InnoSoft.LS.Resources.Options.PriceApproveFlow, nOpStaffId, strOpStaffName, out strErrText);
                            if (listStep == null)
                            {
                                return false;
                            }
                            if (listStep.Count > 0)
                            {
                                int nStepIndex = 0;
                                for (nStepIndex = 0; nStepIndex < listStep.Count; nStepIndex++)
                                {
                                    //获取审批步骤数据
                                    long nStepId = listStep[nStepIndex].Id;
                                    string strStepName = listStep[nStepIndex].StepName;
                                    int nStepNum = listStep[nStepIndex].StepNum;
                                    long nDisposerId = listStep[nStepIndex].DisposerId;
                                    string strDisposerName = listStep[nStepIndex].DisposerName;
                                    string strConditionExpression = listStep[nStepIndex].ConditionExpression;

                                    //读取审批步骤条件数据
                                    List<ApproveFlowStepCondition> listCondition = dao.LoadApproveFlowStepConditionsByStepId(nStepId, nOpStaffId, strOpStaffName, out strErrText);
                                    if (listCondition == null)
                                    {
                                        return false;
                                    }

                                    //创建条件运算结果中间变量
                                    string[] arrayIntermediateResults = new string[listCondition.Count + 1];//为什么加1?因为条件序号是从1开始的

                                    //对每个条件进行运算,运算结果存入中间变量中
                                    int nConditionIndex = 0;
                                    for (nConditionIndex = 0; nConditionIndex < listCondition.Count; nConditionIndex++)
                                    {
                                        //获取条件数据
                                        string strFieldName = listCondition[nConditionIndex].FieldName;
                                        string strCompareOperator = listCondition[nConditionIndex].CompareOperator;
                                        string strFieldValue = listCondition[nConditionIndex].FieldValue;

                                        if (strFieldName == InnoSoft.LS.Resources.Options.OverPercentage)
                                        {
                                            decimal decFieldValue = decimal.Parse(strFieldValue);

                                            if (strCompareOperator == InnoSoft.LS.Resources.Options.Equal)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage == decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThanOrEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage >= decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThanOrEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage <= decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThan)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage > decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThan)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage < decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.NotEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverPercentage != decFieldValue)).ToString();
                                            }
                                            else
                                            {
                                                strErrText = string.Format(InnoSoft.LS.Resources.Strings.OverPercentageConditionNotSupportOperator, strCompareOperator);
                                                return false;
                                            }
                                        }
                                        else if (strFieldName == InnoSoft.LS.Resources.Options.OverAmount)
                                        {
                                            decimal decFieldValue = decimal.Parse(strFieldValue);

                                            if (strCompareOperator == InnoSoft.LS.Resources.Options.Equal)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount == decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThanOrEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount >= decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThanOrEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount <= decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.GreaterThan)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount > decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.LessThan)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount < decFieldValue)).ToString();
                                            }
                                            else if (strCompareOperator == InnoSoft.LS.Resources.Options.NotEqual)
                                            {
                                                arrayIntermediateResults[nConditionIndex + 1] = ((bool)(decOverAmount != decFieldValue)).ToString();
                                            }
                                            else
                                            {
                                                strErrText = string.Format(InnoSoft.LS.Resources.Strings.OverAmountConditionNotSupportOperator, strCompareOperator);
                                                return false;
                                            }
                                        }
                                        else
                                        {
                                            strErrText = string.Format(InnoSoft.LS.Resources.Strings.NotSupportApproveCondition, strFieldName);
                                            return false;
                                        }
                                    }

                                    //对所有条件运算的结果进行综合判断
                                    bool bFinalResult;
                                    if (listCondition.Count == 0)
                                    {
                                        bFinalResult = true;
                                    }
                                    else if (listCondition.Count == 1)
                                    {
                                        bFinalResult = bool.Parse(arrayIntermediateResults[1]);
                                    }
                                    else
                                    {
                                        //根据条件组合表达式计算最终结果
                                        string strFinalConditionExpression = string.Format(strConditionExpression, arrayIntermediateResults);
                                        bFinalResult = Utils.CalculateApproveFlowStepConditionExpression(strFinalConditionExpression);
                                    }

                                    //根据最终结果决定下一个步骤
                                    if (!bFinalResult)
                                    {
                                        //如果不执行当前步骤,则继续匹配下一步骤
                                        continue;
                                    }
                                    else
                                    {
                                        //设置当前审批人
                                        nApproveFlowStepNum = nStepNum;
                                        strApproveFlowStepName = strStepName;
                                        nApproverId = nDisposerId;
                                        strApproverName = strDisposerName;

                                        break;
                                    }
                                }
                            }
                        }

                        //修改合同审批人和审批状态
                        using (ContractDAO dao = new ContractDAO())
                        {
                            if (!dao.UpdateContractApprover(nContractId, nApproveFlowStepNum, strApproveFlowStepName, nApproverId, strApproverName, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return false;
                            }

                            //修改合同状态为“已审批”
                            if (nApproverId == 0)
                            {
                                if (!dao.UpdateContractApproveState(nContractId, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return false;
                                }
                            }
                        }

                        if (nApproverId > 0)
                        {
                            strErrText = string.Format(InnoSoft.LS.Resources.Strings.ContractNeedApprove, strApproverName);
                        }

                        #endregion
                    }

                    #endregion

                    transScope.Complete();
                }
                return true;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return false;
            }
        }
예제 #7
-1
파일: FlowRule.cs 프로젝트: zjchenxk/SYLS
        /// <summary>
        /// 删除指定流程步骤数据
        /// </summary>
        /// <param name="nId">步骤编码</param>
        /// <param name="nOpStaffId">操作员工编码</param>
        /// <param name="strOpStaffName">操作员工姓名</param>
        /// <param name="strErrText">出错信息</param>
        /// <returns></returns>
        public bool DeleteApproveFlowStep(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())
                    {
                        //删除步骤数据
                        if (!dao.DeleteApproveFlowStep(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return false;
                        }

                        //删除原条件数据
                        if (!dao.DeleteApproveFlowStepConditions(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return false;
                        }
                    }
                    transScope.Complete();
                }
                return true;
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return false;
            }
        }