private void AutoComplete_SecuIn_SelectChangedItem(object sender, AutoItem data) { if (sender == null || data == null) { return; } if (string.IsNullOrEmpty(data.Id)) { return; } List <SecurityItem> secuItemList = new List <SecurityItem>(); var inItem = _secuInfoList.Find(p => p.SecuCode.Equals(data.Id)); if (inItem != null) { secuItemList.Add(inItem); } var outItem = _secuInfoList.Find(p => p.SecuCode.Equals(_originItem.SecuCode)); if (outItem != null) { secuItemList.Add(outItem); } //QuoteCenter.Instance.Query(secuItemList); var inPriceData = QuoteCenter.Instance.GetMarketData(inItem); var outPriceData = QuoteCenter.Instance.GetMarketData(outItem); int inAmount = 0; if (inPriceData != null && outPriceData != null) { SetPrice(inPriceData, this.tbInPrice); SetPrice(outPriceData, this.tbOutPrice); if (outPriceData.CurrentPrice > 0) { var temp = _originItem.AvailableAmount * inPriceData.CurrentPrice / outPriceData.CurrentPrice; inAmount = AmountRoundUtil.Round((int)temp); } } if (inAmount > 0) { this.tbInAmount.Text = string.Format("{0}", inAmount); } }
public void Test_Round() { int amount = 146; int actual = AmountRoundUtil.Round(amount); Assert.AreEqual(100, actual); amount = 150; actual = AmountRoundUtil.Round(amount); Assert.AreEqual(200, actual); amount = 1190; actual = AmountRoundUtil.Round(amount); Assert.AreEqual(1200, actual); }
private CancelRedoItem Convert(EntrustSecurity p, Model.Database.TradeCommand tradeCommand) { CancelRedoItem cancelRedoItem = new CancelRedoItem { Selection = true, CommandId = tradeCommand.CommandId, EDirection = p.EntrustDirection, EntrustPrice = p.EntrustPrice, SecuCode = p.SecuCode, SecuType = p.SecuType, EntrustNo = p.EntrustNo, ECommandPrice = p.PriceType, ReportPrice = p.EntrustPrice, EOriginPriceType = p.EntrustPriceType, LeftAmount = p.EntrustAmount - p.TotalDealAmount, ReportAmount = p.EntrustAmount, DealAmount = p.TotalDealAmount, EntrustDate = p.EntrustDate, SubmitId = p.SubmitId, EntrustBatchNo = p.BatchNo, PortfolioName = tradeCommand.PortfolioName, FundName = tradeCommand.AccountName, }; cancelRedoItem.EntrustAmount = cancelRedoItem.LeftAmount; if (cancelRedoItem.SecuType == Model.SecurityInfo.SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot) { if (cancelRedoItem.LeftAmount % 100 > 0) { cancelRedoItem.EntrustAmount = AmountRoundUtil.Round(cancelRedoItem.LeftAmount); } } var secuInfo = SecurityInfoManager.Instance.Get(p.SecuCode, p.SecuType); if (secuInfo != null) { cancelRedoItem.SecuName = secuInfo.SecuName; cancelRedoItem.ExchangeCode = secuInfo.ExchangeCode; } else { cancelRedoItem.ExchangeCode = SecurityItemHelper.GetExchangeCode(p.SecuCode, p.SecuType); } return(cancelRedoItem); }
private TemplateStock GetDialogData() { TemplateStock stock = new TemplateStock { TemplateNo = _templateId }; var autoItem = acSecurity.GetCurrentItem(); stock.SecuCode = autoItem.Id; stock.SecuName = autoItem.Name; if (rdbAmount.Checked && !string.IsNullOrEmpty(tbAmount.Text)) { int temp = -1; if (int.TryParse(tbAmount.Text, out temp)) { if (temp > 0) { temp = AmountRoundUtil.Round(temp); } else { temp = 0; } stock.Amount = temp; } } if (rdbPercent.Checked && !string.IsNullOrEmpty(tbSettingWeight.Text)) { double temp = 0.0f; if (double.TryParse(tbSettingWeight.Text, out temp)) { stock.SettingWeight = temp; } } return(stock); }