public static void LoadStockCode_ByWatchList(data.tmpDS.stockCodeDataTable stockCodeTbl, StringCollection codes) { StringCollection retList = new StringCollection(); StringCollection list; data.tmpDS.stockCodeDataTable tmpTbl = new data.tmpDS.stockCodeDataTable(); data.baseDS.portfolioDataTable portfolioTbl = new data.baseDS.portfolioDataTable(); data.baseDS.portfolioRow portfolioRow; for (int idx1 = 0; idx1 < codes.Count; idx1++) { portfolioRow = SysLibs.FindAndCache(portfolioTbl, codes[idx1]); if (portfolioRow == null) { continue; } list = common.MultiValueString.String2List(portfolioRow.interestedStock); if (list.Count <= 0) { continue; } tmpTbl.Clear(); LoadStockCode_ByCodeList(tmpTbl, list); for (int idx2 = 0; idx2 < tmpTbl.Count; idx2++) { if (stockCodeTbl.FindBycode(tmpTbl[idx2].code) == null) { stockCodeTbl.ImportRow(tmpTbl[idx2]); } } } portfolioTbl.Dispose(); }
public static data.tmpDS.stockCodeRow FindAndCache(data.tmpDS.stockCodeDataTable tbl, string code) { data.tmpDS.stockCodeRow row = tbl.FindBycode(code); if (row != null) { return(row); } data.tmpDSTableAdapters.stockCodeTA dataTA = new data.tmpDSTableAdapters.stockCodeTA(); dataTA.ClearBeforeFill = false; dataTA.FillByCode(tbl, code); row = tbl.FindBycode(code); if (row != null) { return(row); } return(null); }
private static data.tmpDS.stockCodeDataTable StockFromCodeList(string[] codes) { data.tmpDS.stockCodeDataTable retTbl = new data.tmpDS.stockCodeDataTable(); data.tmpDS.stockCodeRow stockRow; data.tmpDS.stockCodeDataTable stockCodeTbl = myStockCodeTbl; for (int idx = 0; idx < codes.Length; idx++) { stockRow = stockCodeTbl.FindBycode(codes[idx]); if (stockRow != null) { retTbl.ImportRow(stockRow); } } return(retTbl); }
private void DoRefreshPrice(data.tmpDS.stockCodeDataTable dataTbl) { //Open price is the same all day. if (openPriceTbl == null || openPriceDate != DateTime.Today) { openPriceTbl = DataAccess.Libs.GetLastPrice(commonClass.PriceDataType.Open); openPriceDate = DateTime.Today; } data.baseDS.lastPriceDataDataTable priceTbl = DataAccess.Libs.GetLastPrice(commonClass.PriceDataType.Close); if (priceTbl == null) { return; } data.tmpDS.stockCodeRow stockCodeRow; data.baseDS.lastPriceDataRow openPriceRow, closePriceRow; dataTbl.priceColumn.ReadOnly = false; dataTbl.priceVariantColumn.ReadOnly = false; for (int idx = 0; idx < stockGV.RowCount; idx++) { stockCodeRow = dataTbl.FindBycode(stockGV.Rows[idx].Cells[codeColumn.Name].Value.ToString()); if (stockCodeRow == null) { continue; } closePriceRow = priceTbl.FindBystockCode(stockGV.Rows[idx].Cells[codeColumn.Name].Value.ToString()); if (stockCodeRow.price != closePriceRow.value) { stockCodeRow.price = closePriceRow.value; openPriceRow = openPriceTbl.FindBystockCode(stockGV.Rows[idx].Cells[codeColumn.Name].Value.ToString()); if (openPriceRow != null) { stockCodeRow.priceVariant = closePriceRow.value - openPriceRow.value; } else { stockCodeRow.priceVariant = 0; } } } }
protected void LoadStockList(data.tmpDS.stockCodeDataTable toTbl, string[] watchCodes) { //Load stocks in portfolio data.tmpDS.stockCodeDataTable myStockCodeTbl = null; switch (this.watchType) { case AppTypes.PortfolioTypes.Portfolio: myStockCodeTbl = DataAccess.Libs.GetStock_InPortfolio(common.system.List2Collection(watchCodes)); break; case AppTypes.PortfolioTypes.WatchList: myStockCodeTbl = DataAccess.Libs.GetStock_ByWatchList(common.system.List2Collection(watchCodes)); break; default: common.system.ThrowException("Invalid WatchType"); break; } DataView myStockView = new DataView(myStockCodeTbl); data.baseDS.stockCodeRow stockRow; myStockView.Sort = myStockCodeTbl.codeColumn.ColumnName + "," + myStockCodeTbl.stockExchangeColumn.ColumnName; data.tmpDS.stockCodeRow reportRow; for (int idx1 = 0; idx1 < myStockView.Count; idx1++) { stockRow = (data.baseDS.stockCodeRow)myStockView[idx1].Row; //Ignore duplicate stocks reportRow = toTbl.FindBycode(stockRow.code); if (reportRow != null) { continue; } reportRow = toTbl.NewstockCodeRow(); commonClass.AppLibs.InitData(reportRow); reportRow.code = stockRow.code; reportRow.stockExchange = stockRow.stockExchange; toTbl.AddstockCodeRow(reportRow); } }