public virtual void InsertMarginTradingInfo(MarginTradingInfo marginTradingEntity) { if (marginTradingEntity == null) { throw new ArgumentNullException(nameof(marginTradingEntity)); } _marginInfoRepository.Insert(marginTradingEntity); }
private void AddMarginInfo(bool isFinancing) { if (!InputCheck(isFinancing)) { return; } var source = this.gridControl1.DataSource as List <MarginTradingEntity>; var investorInfo = this.luInvestor.GetSelectedDataRow() as UserInfo; var marginModel = new MarginTradingInfo { IsRepay = _isRepay, IsFinancing = isFinancing, AccountId = int.Parse(this.luAccount.SelectedValue()), DepartmentId = investorInfo.DepartmentId, InvestorCode = investorInfo.Code, MarginDate = CommonHelper.StringToDateTime(this.deTradeDate.EditValue.ToString()), TradeType = int.Parse(cbTradeType.SelectedValue()), }; if (isFinancing) { marginModel.Amount = Math.Abs(decimal.Parse(this.txtFinancingAmount.Text.Trim())); } else { var stockInfo = this.luStock.GetSelectedDataRow() as StockInfoModel; marginModel.StockFullCode = stockInfo.FullCode; marginModel.StockName = stockInfo.Name; marginModel.LoanOwnerCode = this.luLoanOwner.SelectedValue(); marginModel.LoanVolume = Math.Abs(int.Parse(this.txtLoanVolume.Text.Trim())); marginModel.Amount = Math.Abs(decimal.Parse(this.txtLoanAmount.Text.Trim())); if (source != null && source.Any()) { var existedInfo = source.SingleOrDefault(x => x.TradeType == marginModel.TradeType && x.IsRepay == _isRepay && x.InvestorCode == marginModel.InvestorCode && x.MarginDate == marginModel.MarginDate && x.AccountId == marginModel.AccountId && x.StockFullCode == marginModel.StockFullCode); if (existedInfo != null) { DXMessage.ShowTips("该信息已经存在,请核对后重新输入!"); return; } } } if (DXMessage.ShowYesNoAndTips("确定添加该信息么?") == System.Windows.Forms.DialogResult.Yes) { this._marginService.InsertMarginTradingInfo(marginModel); BindTodayMarginInfo(); this.txtFinancingAmount.Text = null; this.luLoanOwner.EditValue = null; this.luStock.EditValue = null; this.txtLoanVolume.Text = null; this.txtLoanAmount.Text = null; } }