Пример #1
0
        private bool SubmitProcess()
        {
            InvestmentDecisionApplication application = null;
            InvestmentDecisionOperation   operation   = null;

            var now = _commonService.GetCurrentServerTime();

            if (string.IsNullOrEmpty(ApplyNo))
            {
                if (string.IsNullOrEmpty(this.luStock.SelectedValue()))
                {
                    DXMessage.ShowTips("请选择股票信息!");
                    this.luStock.Focus();
                    return(false);
                }

                var applyDate = CommonHelper.StringToDateTime(this.deApply.EditValue.ToString());
                var tradeType = int.Parse(this.cbOperateType.SelectedValue());
                var stock     = this.luStock.GetSelectedDataRow() as StockInfoModel;

                application = new InvestmentDecisionApplication
                {
                    ApplyNo         = string.Empty,
                    ApplyDate       = applyDate,
                    ApplyUser       = LoginInfo.CurrentUser.UserCode,
                    BuyAmount       = 0,
                    BuyVolume       = 0,
                    CreateTime      = now,
                    DepartmentId    = LoginInfo.CurrentUser.DepartmentId,
                    InitialDealFlag = this.chkBuy.Checked,
                    IsDeleted       = false,
                    PositionVolume  = 0,
                    Profit          = 0,
                    SellAmount      = 0,
                    SellVolume      = 0,
                    Status          = (int)EnumLibrary.IDApplicationStatus.Proceed,
                    StockCode       = stock.FullCode,
                    StockName       = stock.Name,
                    TradePlanNo     = txtPlanNo.Text.Trim(),
                    TradeType       = tradeType,
                    UpdateTime      = now,
                };
            }

            if (string.IsNullOrEmpty(OperateNo))
            {
                if (this.txtPrice.Text.Trim().Length == 0)
                {
                    DXMessage.ShowTips("请输入单价!");
                    this.txtPrice.Focus();
                    return(false);
                }

                if (decimal.Parse(this.txtPrice.Text.Trim()) <= 0)
                {
                    DXMessage.ShowTips("单价应该大于0!");
                    this.txtPrice.Focus();
                    return(false);
                }

                if (this.txtVolume.Text.Trim().Length == 0)
                {
                    DXMessage.ShowTips("请输入数量!");
                    this.txtVolume.Focus();
                    return(false);
                }

                if (decimal.Parse(this.txtVolume.Text.Trim()) <= 0)
                {
                    DXMessage.ShowTips("数量应该大于0!");
                    this.txtVolume.Focus();
                    return(false);
                }

                if (_profitLossBoundSettingFlag)
                {
                    if (this.txtProfitPrice.Text.Trim().Length == 0)
                    {
                        DXMessage.ShowTips("请输入止盈价格!");
                        this.txtProfitPrice.Focus();
                        return(false);
                    }

                    if (decimal.Parse(this.txtProfitPrice.Text.Trim()) <= 0)
                    {
                        DXMessage.ShowTips("止盈价格应该大于0!");
                        this.txtProfitPrice.Focus();
                        return(false);
                    }

                    if (this.txtLossPrice.Text.Trim().Length == 0)
                    {
                        DXMessage.ShowTips("请输入止损价格!");
                        this.txtLossPrice.Focus();
                        return(false);
                    }

                    if (decimal.Parse(this.txtLossPrice.Text.Trim()) <= 0)
                    {
                        DXMessage.ShowTips("止损价格应该大于0!");
                        this.txtLossPrice.Focus();
                        return(false);
                    }
                }

                if (string.IsNullOrEmpty(this.treeListLookUpEdit1.SelectedValue()))
                {
                    DXMessage.ShowTips("请选择理由分类!");
                    this.treeListLookUpEdit1.Focus();
                    return(false);
                }

                if (string.IsNullOrEmpty(this.memoReason.Text.Trim()))
                {
                    DXMessage.ShowTips("请输入理由内容!");
                    this.memoReason.Focus();
                    return(false);
                }

                var price           = decimal.Parse(this.txtPrice.Text.Trim());
                var priceBound      = decimal.Parse(this.spinPriceBound.EditValue.ToString()) / (int)EnumLibrary.NumericUnit.Hundred;
                var volume          = decimal.Parse(this.txtVolume.Text.Trim());
                var amount          = Math.Abs(decimal.Parse(this.txtAmount.Text.Trim()) * (int)EnumLibrary.NumericUnit.TenThousand);
                var operateDate     = CommonHelper.StringToDateTime(this.deOperate.EditValue.ToString());
                var stock           = this.luStock.GetSelectedDataRow() as StockInfoModel;
                var stopProfitPrice = _profitLossBoundSettingFlag ? decimal.Parse(this.txtProfitPrice.Text.Trim()) : 0;
                var stopProfitBound = _profitLossBoundSettingFlag ? decimal.Parse(this.spinProfitBound.EditValue.ToString()) / (int)EnumLibrary.NumericUnit.Hundred : 0;
                var stopLossPrice   = _profitLossBoundSettingFlag ? decimal.Parse(this.txtLossPrice.Text.Trim()) : 0;
                var stopLossBound   = _profitLossBoundSettingFlag ? decimal.Parse(this.spinLossBound.EditValue.ToString()) / (int)EnumLibrary.NumericUnit.Hundred : 0;

                operation = new InvestmentDecisionOperation
                {
                    AccuracyPoint         = 0,
                    AccuracyStatus        = (int)EnumLibrary.IDOperationAccuracyStatus.None,
                    ApplyNo               = ApplyNo,
                    CreateTime            = now,
                    DealAmount            = amount,
                    DealFlag              = chkBuy.Checked,
                    DealPrice             = price,
                    DealVolume            = volume,
                    ExecuteFlag           = (int)EnumLibrary.IDOperationExecuteStatus.None,
                    InitialFlag           = _initialFlag,
                    IsDeleted             = false,
                    IsStopped             = false,
                    Step                  = OperateStep,
                    OperateDate           = operateDate,
                    OperateUser           = LoginInfo.CurrentUser.UserCode,
                    OperateNo             = string.Empty,
                    PriceBound            = priceBound,
                    ReasonCategoryId      = int.Parse(this.treeListLookUpEdit1.SelectedValue()),
                    ReasonContent         = memoReason.Text.Trim(),
                    StockCode             = stock.FullCode,
                    StockName             = stock.Name,
                    StopLossBound         = stopLossBound,
                    StopLossPrice         = stopLossPrice,
                    StopProfitBound       = stopProfitBound,
                    StopProfitPrice       = stopProfitPrice,
                    TradeRecordRelateFlag = false,
                    UpdateTime            = now,
                    VotePoint             = 0,
                    VoteStatus            = (int)EnumLibrary.IDOperationVoteStatus.None,
                };
            }

            _IDService.IDApplicationApplyProcess(application, operation);

            return(true);
        }
Пример #2
0
        public void IDApplicationApplyProcess(InvestmentDecisionApplication applicationEntity, InvestmentDecisionOperation operationEntity)
        {
            if (operationEntity == null)
            {
                throw new ArgumentNullException(nameof(operationEntity));
            }

            if (_IDCommitteeRepository.Table.Count() == 0)
            {
                throw new Exception("请设置投资决策委员会成员!");
            }

            if (applicationEntity != null && string.IsNullOrEmpty(applicationEntity.ApplyNo))
            {
                applicationEntity.ApplyNo = GenerateIDApplicationApplyNo();

                this._IDApplicationRepository.Insert(applicationEntity);

                operationEntity.ApplyNo = applicationEntity.ApplyNo;
            }

            decimal totalWeight     = 1;
            decimal applyUserWeight = 0;
            decimal otherWeight     = 0;

            var committeeCodes = _IDCommitteeRepository.Table.Select(x => x.Code).ToList();

            if (committeeCodes.Contains(operationEntity.OperateUser))
            {
                applyUserWeight = 0.35M;
                otherWeight     = CommonHelper.SetDecimalDigits((totalWeight - applyUserWeight), 4) / (committeeCodes.Count - 1);
            }
            else
            {
                applyUserWeight = 0;
                otherWeight     = CommonHelper.SetDecimalDigits(totalWeight, 4) / committeeCodes.Count;

                committeeCodes.Add(operationEntity.OperateUser);
            }

            operationEntity.VotePoint = (int)(applyUserWeight * 100);
            operationEntity.OperateNo = GenerateIDOperationNo();

            _IDOperationRepository.Insert(operationEntity);

            var defaultVoteInfos = new List <InvestmentDecisionOperationVote>();

            foreach (var code in committeeCodes)
            {
                var info = new InvestmentDecisionOperationVote
                {
                    ApplyNo          = operationEntity.ApplyNo,
                    AuthorityLevel   = 0,
                    Flag             = operationEntity.OperateUser == code ? (int)EnumLibrary.IDVoteFlag.Approval : (int)EnumLibrary.IDVoteFlag.None,
                    OperateNo        = operationEntity.OperateNo,
                    ReasonCategoryId = operationEntity.OperateUser == code ? operationEntity.ReasonCategoryId : 0,
                    ReasonContent    = operationEntity.OperateUser == code ? operationEntity.ReasonContent : string.Empty,
                    Type             = operationEntity.OperateUser == code ? (int)EnumLibrary.IDVoteType.Applicant : (int)EnumLibrary.IDVoteType.Committee,
                    UserCode         = code,
                    VoteTime         = _commonService.GetCurrentServerTime(),
                    Weight           = operationEntity.OperateUser == code ? applyUserWeight : otherWeight,
                };

                defaultVoteInfos.Add(info);
            }
            _IDOperationVoteRepository.Insert(defaultVoteInfos);
        }