Beispiel #1
0
        /// <summary>
        /// 批准一个Bill(事务由调用方负责)
        /// </summary>
        /// <param name="loggingSession">当前登录用户的Session信息</param>
        /// <param name="billId">Bill</param>
        /// <param name="remark">批注</param>
        /// <param name="strBillActionType">状态</param>
        /// <returns>操作的状态</returns>
        public BillOperateStateService ApproveBill(string billId, string remark, BillActionType strBillActionType)
        {
            if (strBillActionType.Equals(""))
            {
                strBillActionType = BillActionType.Approve;
            }
            BillModel bill = GetBillById(billId);

            if (bill == null)
            {
                return(BillOperateStateService.NotExist);
            }

            BillKindModel billKind = GetBillKindById(bill.KindId);

            if (billKind == null)
            {
                return(BillOperateStateService.NotExistKind);
            }
            BillStatusModel currentBillStatus = GetBillStatusByKindIdAndStatus(billKind.Id, bill.Status);

            if (currentBillStatus == null)
            {
                return(BillOperateStateService.NotExistStatus);
            }
            BillActionModel billApproveAction = GetBillAction(bill.KindId, strBillActionType);

            if (billApproveAction == null)
            {
                return(BillOperateStateService.NotSetApproveAction);
            }
            Hashtable           hashTable             = new Hashtable();
            BillActionRoleModel billApproveActionRole = new BillActionRoleModel();
            DataSet             ds = new DataSet();

            ds = billService.GetbillCreateActionRole(bill.KindId, billApproveAction.Id, GetBasicRoleId(this.loggingSessionInfo.CurrentUserRole.RoleId), currentBillStatus.Status);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                billApproveActionRole = DataTableToObject.ConvertToObject <BillActionRoleModel>(ds.Tables[0].Rows[0]);
            }

            if (billApproveActionRole == null)
            {
                return(BillOperateStateService.NotAllowApprove);
            }

            //if (billKind.MoneyFlag == 1)
            //{
            //    if ((bill.Money < billApproveActionRole.MinMoney) || (bill.Money > billApproveActionRole.MaxMoney))
            //    {
            //        return BillOperateStateService.OutOfMoneyScope;
            //    }
            //}

            bill.ModifyUserId = this.loggingSessionInfo.CurrentUser.User_Id;
            bill.ModifyDate   = GetCurrentDateTime();
            bill.Status       = billApproveActionRole.CurrentStatus;

            BillStatusModel nextBillStatus = GetBillStatusByKindIdAndStatus(billKind.Id, billApproveActionRole.CurrentStatus);

            if (nextBillStatus == null)
            {
                return(BillOperateStateService.NotExistStatus);
            }
            billService.UpdateBill(bill);
            //InsertBillActionLog(loggingSession, bill, billApproveAction, billApproveActionRole, remark);

            return(BillOperateStateService.ApproveSuccessful);
        }
Beispiel #2
0
        /// <summary>
        /// 批准一个Bill(事务由调用方负责) Jermyn2012-09-17
        /// </summary>
        /// <param name="loggingSession">当前登录用户的Session信息</param>
        /// <param name="billId">Bill</param>
        /// <param name="remark">批注</param>
        /// <param name="strBillActionType">状态</param>
        /// <param name="strError">输出错误参数</param>
        /// <returns>操作的状态</returns>
        public BillOperateStateService ApproveBill(string billId, string remark, BillActionType strBillActionType, out string strError)
        {
            if (strBillActionType.Equals(""))
            {
                strError          = "BillActionType.Approve";
                strBillActionType = BillActionType.Approve;
            }
            BillModel bill = GetBillById(billId);

            if (bill == null)
            {
                strError = "BillOperateStateService.NotExist";
                return(BillOperateStateService.NotExist);
            }

            BillKindModel billKind = GetBillKindById(bill.KindId);

            if (billKind == null)
            {
                strError = "BillOperateStateService.NotExistKind";
                return(BillOperateStateService.NotExistKind);
            }
            BillStatusModel currentBillStatus = GetBillStatusByKindIdAndStatus(billKind.Id, bill.Status);

            if (currentBillStatus == null)
            {
                strError = "BillOperateStateService.NotExistStatus";
                return(BillOperateStateService.NotExistStatus);
            }
            BillActionModel billApproveAction = GetBillAction(bill.KindId, strBillActionType);

            if (billApproveAction == null)
            {
                strError = "BillOperateStateService.NotSetApproveAction";
                return(BillOperateStateService.NotSetApproveAction);
            }
            //获取审批权限
            DataSet             ds = billService.GetbillCreateActionRole(bill.KindId, billApproveAction.Id, GetBasicRoleId(this.loggingSessionInfo.CurrentUserRole.RoleId), currentBillStatus.Status);
            BillActionRoleModel billApproveActionRole = new BillActionRoleModel();

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                billApproveActionRole = DataTableToObject.ConvertToObject <BillActionRoleModel>(ds.Tables[0].Rows[0]);
            }
            if (billApproveActionRole == null)
            {
                strError = "BillOperateStateService.NotAllowApprove--"
                           //+ "RoleId:" + GetBasicRoleId(loggingSession.CurrentUserRole.RoleId).ToString() + "----"
                           //+ "BillKindId:" + bill.KindId + "----"
                           //+ "BillActionId:" + billApproveAction.Id + "----"
                           //+ "PreviousBillStatus:" + currentBillStatus.Status + "----"
                           + "InoutStatus" + bill.Status + "--" + bill.BillStatusDescription + "--" + bill.Id
                ;
                return(BillOperateStateService.NotAllowApprove);
            }

            //if (billKind.MoneyFlag == 1)
            //{
            //    if ((bill.Money < billApproveActionRole.MinMoney) || (bill.Money > billApproveActionRole.MaxMoney))
            //    {
            //        strError = "BillOperateStateService.OutOfMoneyScope";
            //        return BillOperateStateService.OutOfMoneyScope;
            //    }
            //}

            bill.ModifyUserId = this.loggingSessionInfo.CurrentUser.User_Id;
            bill.ModifyDate   = GetCurrentDateTime();
            bill.Status       = billApproveActionRole.CurrentStatus;

            BillStatusModel nextBillStatus = GetBillStatusByKindIdAndStatus(billKind.Id, billApproveActionRole.CurrentStatus);

            if (nextBillStatus == null)
            {
                strError = "BillOperateStateService.NotExistStatus";
                return(BillOperateStateService.NotExistStatus);
            }
            //修改bill
            billService.UpdateBill(bill);
            //InsertBillActionLog(loggingSession, bill, billApproveAction, billApproveActionRole, remark);
            strError = "BillOperateStateService.ApproveSuccessful";
            return(BillOperateStateService.ApproveSuccessful);
        }
Beispiel #3
0
        /// <summary>
        /// 批准一个Bill(事务由调用方负责) Jermyn2012-09-17
        /// </summary>
        /// <param name="loggingSession">当前登录用户的Session信息</param>
        /// <param name="billId">Bill</param>
        /// <param name="remark">批注</param>
        /// <param name="strBillActionType">状态</param>
        /// <param name="strError">输出错误参数</param>
        /// <returns>操作的状态</returns>
        public BillOperateStateService ApproveBill(LoggingSessionInfo loggingSession, string billId, string remark, BillActionType strBillActionType, out string strError)
        {
            if (strBillActionType.Equals(""))
            {
                strError          = "BillActionType.Approve";
                strBillActionType = BillActionType.Approve;
            }
            BillModel bill = GetBillById(loggingSession, billId);

            if (bill == null)
            {
                strError = "BillOperateStateService.NotExist";
                return(BillOperateStateService.NotExist);
            }

            BillKindModel billKind = GetBillKindById(loggingSession, bill.KindId);

            if (billKind == null)
            {
                strError = "BillOperateStateService.NotExistKind";
                return(BillOperateStateService.NotExistKind);
            }
            BillStatusModel currentBillStatus = GetBillStatusByKindIdAndStatus(loggingSession, billKind.Id, bill.Status);

            if (currentBillStatus == null)
            {
                strError = "BillOperateStateService.NotExistStatus";
                return(BillOperateStateService.NotExistStatus);
            }
            BillActionModel billApproveAction = GetBillAction(loggingSession, bill.KindId, strBillActionType);

            if (billApproveAction == null)
            {
                strError = "BillOperateStateService.NotSetApproveAction";
                return(BillOperateStateService.NotSetApproveAction);
            }
            Hashtable hashTable = new Hashtable();

            //hashTable.Add("RoleId", loggingSession.CurrentUserRole.RoleId);
            hashTable.Add("RoleId", GetBasicRoleId(loggingSession.CurrentUserRole.RoleId));
            hashTable.Add("BillKindId", bill.KindId);
            hashTable.Add("BillActionId", billApproveAction.Id);
            hashTable.Add("PreviousBillStatus", currentBillStatus.Status);
            hashTable.Add("LanguageKindId", loggingSession.CurrentLanguageKindId);
            BillActionRoleModel billApproveActionRole = cSqlMapper.Instance(loggingSession.CurrentLoggingManager).QueryForObject <BillActionRoleModel>("BillActionRole.SelectByKindIdAndActionIdAndRoleIdAndPreviousStatus", hashTable);

            if (billApproveActionRole == null)
            {
                strError = "BillOperateStateService.NotAllowApprove--"
                           //+ "RoleId:" + GetBasicRoleId(loggingSession.CurrentUserRole.RoleId).ToString() + "----"
                           //+ "BillKindId:" + bill.KindId + "----"
                           //+ "BillActionId:" + billApproveAction.Id + "----"
                           //+ "PreviousBillStatus:" + currentBillStatus.Status + "----"
                           + "InoutStatus" + bill.Status + "--" + bill.BillStatusDescription + "--" + bill.Id
                ;
                return(BillOperateStateService.NotAllowApprove);
            }
            //判断是否超出系统设置时间
            //if (billApproveActionRole.ValidateDate == 0)
            //{
            //    return BillOperateStateService.OutDateTime;
            //}
            if (billKind.MoneyFlag == 1)
            {
                if ((bill.Money < billApproveActionRole.MinMoney) || (bill.Money > billApproveActionRole.MaxMoney))
                {
                    strError = "BillOperateStateService.OutOfMoneyScope";
                    return(BillOperateStateService.OutOfMoneyScope);
                }
            }

            bill.ModifyUserId = loggingSession.CurrentUser.User_Id;
            bill.ModifyDate   = GetCurrentDateTime();
            bill.Status       = billApproveActionRole.CurrentStatus;

            BillStatusModel nextBillStatus = GetBillStatusByKindIdAndStatus(loggingSession, billKind.Id, billApproveActionRole.CurrentStatus);

            if (nextBillStatus == null)
            {
                strError = "BillOperateStateService.NotExistStatus";
                return(BillOperateStateService.NotExistStatus);
            }

            cSqlMapper.Instance(loggingSession.CurrentLoggingManager).Update("Bill.Update", bill);
            InsertBillActionLog(loggingSession, bill, billApproveAction, billApproveActionRole, remark);
            strError = "BillOperateStateService.ApproveSuccessful";
            return(BillOperateStateService.ApproveSuccessful);
        }