Beispiel #1
0
        public virtual void SubmitInvestmentDecisionApplication(InvestmentDecisionForm entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

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

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

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

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

                committeeCodes.Add(entity.ApplyUser);
            }

            entity.Point    = (int)(applyUserWeight * 100);
            entity.SerialNo = GenerateIDFSerialNo(entity.ApplyDate);
            _IDFormRepository.Insert(entity);

            var defaultVoteInfos = new List <InvestmentDecisionVote>();

            foreach (var code in committeeCodes)
            {
                var info = new InvestmentDecisionVote
                {
                    AuthorityLevel = 0,
                    Flag           = code == entity.ApplyUser ? (int)EnumLibrary.IDVoteFlag.Approval : (int)EnumLibrary.IDVoteFlag.None,
                    FormSerialNo   = entity.SerialNo,
                    Reason         = code == entity.ApplyUser ? entity.Reason : string.Empty,
                    Type           = code == entity.ApplyUser ? (int)EnumLibrary.IDVoteType.Applicant : (int)EnumLibrary.IDVoteType.Committee,
                    UserCode       = code,
                    VoteTime       = _commonService.GetCurrentServerTime(),
                    Weight         = code == entity.ApplyUser ? applyUserWeight : otherWeight,
                };

                defaultVoteInfos.Add(info);
            }
            _IDVoteRepository.Insert(defaultVoteInfos);
        }
Beispiel #2
0
        private bool SubmitProcess()
        {
            if (string.IsNullOrEmpty(this.luInvestor.SelectedValue()))
            {
                DXMessage.ShowTips("请选择投资发起人!");
                this.luInvestor.Focus();
                return(false);
            }

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

            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.txtPriceBound.Text.Trim().Length == 0)
            {
                DXMessage.ShowTips("请输入单价上下限!");
                this.txtPriceBound.Focus();
                return(false);
            }

            int priceBound;

            if (!int.TryParse(txtPriceBound.Text.Trim(), out priceBound))
            {
                DXMessage.ShowTips("单价上下限应该输入数字!");
                this.txtPriceBound.Focus();
                return(false);
            }

            if (int.Parse(this.txtPriceBound.Text.Trim()) <= 0)
            {
                DXMessage.ShowTips("单价上下限应该大于0!");
                this.txtPriceBound.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 (string.IsNullOrEmpty(this.memoReason.Text.Trim()))
            {
                DXMessage.ShowTips("请输入申请理由!");
                this.memoReason.Focus();
                return(false);
            }

            var investorInfo = this.luInvestor.GetSelectedDataRow() as UserInfo;
            var applyDate    = CommonHelper.StringToDateTime(this.deApply.EditValue.ToString());
            var tradeType    = int.Parse(this.cbOperateType.SelectedValue());
            var price        = decimal.Parse(this.txtPrice.Text.Trim());
            var volume       = decimal.Parse(this.txtVolume.Text.Trim());
            var amount       = Math.Abs(decimal.Parse(this.txtAmount.Text.Trim()) * (int)EnumLibrary.NumericUnit.TenThousand);

            var stock = this.luStock.GetSelectedDataRow() as StockInfoModel;
            var now   = _commonService.GetCurrentServerTime();

            var form = new InvestmentDecisionForm
            {
                Amount            = this.chkBuy.Checked ? amount : -amount,
                ApplyDate         = applyDate,
                ApplyUser         = investorInfo.Code,
                CreateTime        = now,
                DealFlag          = this.chkBuy.Checked ? true : false,
                DepartmentId      = investorInfo.DepartmentId,
                Price             = price,
                PriceBound        = (decimal)priceBound / (int)EnumLibrary.NumericUnit.Hundred,
                Reason            = this.memoReason.Text.Trim(),
                RelateTradePlanNo = txtPlanNo.Text.Trim(),
                SerialNo          = string.Empty,
                Status            = (int)EnumLibrary.IDFormStatus.Submited,
                StockFullCode     = stock.FullCode,
                StockName         = stock.Name,
                TradeType         = tradeType,
                UpdateTime        = now,
                Volume            = volume,
            };

            _IDService.SubmitInvestmentDecisionApplication(form);

            return(true);
        }