public virtual void UpdateStockPoolInfo(StockPoolInfo stockPool) { if (stockPool == null) { throw new ArgumentNullException(nameof(stockPool)); } _stockPoolInfoRepository.Update(stockPool); var preivousRecord = _stockPoolEntryRepository.Table.Where(x => x.StockId == stockPool.StockId).OrderByDescending(x => x.FromDate).FirstOrDefault(); if (preivousRecord != null) { if (stockPool.TargetPrincipal != preivousRecord.TargetPrincipal || stockPool.BandPrincipal != preivousRecord.BandPrincipal) { var poolRecord = new StockPoolEntry { StockId = stockPool.StockId, AddFlag = false, BandPrincipal = stockPool.BandPrincipal, TargetPrincipal = stockPool.TargetPrincipal, FromDate = _commonService.GetCurrentServerTime(), ToDate = null, Remarks = null, }; _stockPoolEntryRepository.Insert(poolRecord); preivousRecord.ToDate = _commonService.GetCurrentServerTime(); _stockPoolEntryRepository.Update(preivousRecord); } } }
private void btnOk_Click(object sender, EventArgs e) { var targetPrincipal = this.luTarget.SelectedValue(); var bandPrincipal = this.luBand.SelectedValue(); var logModel = new StockPoolLog() { StockId = _stockId, BandPrincipal = bandPrincipal, TargetPrincipal = targetPrincipal, OperatorCode = LoginInfo.CurrentUser.UserCode, OperateTime = _commonService.GetCurrentServerTime(), }; //修改股票池的场合 if (this._isEdit) { var stockPool = _stockService.GetStockPoolInfoByStockId(this._stockId); stockPool.BandPrincipal = bandPrincipal; stockPool.TargetPrincipal = targetPrincipal; stockPool.StockId = _stockId; stockPool.Remarks = this.memoRemarks.Text.Trim(); _stockService.UpdateStockPoolInfo(stockPool); logModel.Type = (int)EnumLibrary.OperateType.Edit; } //添加股票池的场合 else { var stockPool = new StockPoolInfo { BandPrincipal = bandPrincipal, TargetPrincipal = targetPrincipal, StockId = _stockId, Remarks = this.memoRemarks.Text.Trim(), }; _stockService.AddStockPoolInfo(stockPool); logModel.Type = (int)EnumLibrary.OperateType.Add; } //添加股票池操作日志 _stockService.AddStockPoolLog(logModel); RefreshEvent?.Invoke(); this.Close(); }
public virtual void AddStockPoolInfo(StockPoolInfo stockPool) { if (stockPool == null) { throw new ArgumentNullException(nameof(stockPool)); } _stockPoolInfoRepository.Insert(stockPool); var poolRecord = new StockPoolEntry { StockId = stockPool.StockId, AddFlag = true, BandPrincipal = stockPool.BandPrincipal, TargetPrincipal = stockPool.TargetPrincipal, FromDate = _commonService.GetCurrentServerTime(), ToDate = null, Remarks = null, }; _stockPoolEntryRepository.Insert(poolRecord); }