private string GetMatchBuyPattern(DataSet pStockDS) { string mResult = ""; string mBCODE = ""; bool mIsDEFAULT = false; bool mIsFindPattern = false; StockPattern mSP = new StockPattern(); int mSelCost = 0; //Return Value Format = CODE|SelCost|Pattern mIsDEFAULT = mSP.IsDefaultPattern(pStockDS.Tables["LINE1"]); if (mIsDEFAULT) { if (!mIsFindPattern) { if (mSP.IsBuyPattern_B0001(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1)) { mBCODE = "B0001_01"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0002(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1, out mSelCost)) { mBCODE = "B0002_01"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0003(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1)) { mBCODE = "B0003_01"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0004(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1)) { mBCODE = "B0004_01"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0005(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1, out mSelCost)) { mBCODE = "B0005_01"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0006(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1)) { mBCODE = "B0006_01"; mIsFindPattern = true; mSelCost = 0; } } if (!mIsFindPattern) { if (mSP.IsBuyPattern_B0001(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5)) { mBCODE = "B0001_05"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0002(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5, out mSelCost)) { mBCODE = "B0002_05"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0003(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5)) { mBCODE = "B0003_05"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0004(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5)) { mBCODE = "B0004_05"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0005(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5, out mSelCost)) { mBCODE = "B0005_05"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0006(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5)) { mBCODE = "B0006_05"; mIsFindPattern = true; mSelCost = 0; } } if (!mIsFindPattern) { if (mSP.IsBuyPattern_B0001(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10)) { mBCODE = "B0001_10"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0002(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10, out mSelCost)) { mBCODE = "B0002_10"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0003(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10)) { mBCODE = "B0003_10"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0004(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10)) { mBCODE = "B0004_10"; mIsFindPattern = true; mSelCost = 0; } else if (mSP.IsBuyPattern_B0005(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10, out mSelCost)) { mBCODE = "B0005_10"; mIsFindPattern = true; } else if (mSP.IsBuyPattern_B0006(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10)) { mBCODE = "B0006_10"; mIsFindPattern = true; mSelCost = 0; } } string mPattern = ""; if (mBCODE != "") { string mLineCode = mBCODE.Substring(6, 2); if (mLineCode == "01") { mPattern = GetPattern(pStockDS.Tables["LINE1"]); } if (mLineCode == "05") { mPattern = GetPattern(pStockDS.Tables["LINE5"]); } if (mLineCode == "10") { mPattern = GetPattern(pStockDS.Tables["LINE10"]); } mResult = mBCODE + "|" + mSelCost.ToString() + "|" + mPattern; } } mSP = null; return mResult; }
private string GetMatchSelPattern(DataSet pStockDS, DataRow pStockInfoDR, int pNowCost) { string mResult = ""; string mSCODE = ""; bool mIsDEFAULT = false; StockPattern mSP = new StockPattern(); string mBuyPatternCode = pStockInfoDR["BuyPatternCode"].ToString(); DateTime mBuyDate = DateTime.Parse(string.Format("{0}-{1}-{2} {3}:{4}:{5}", new string[] { pStockInfoDR["BuyDate"].ToString().Substring(0, 4), pStockInfoDR["BuyDate"].ToString().Substring(4, 2), pStockInfoDR["BuyDate"].ToString().Substring(6, 2), pStockInfoDR["BuyDate"].ToString().Substring(8, 2), pStockInfoDR["BuyDate"].ToString().Substring(10, 2), "00" })); int mBuyCost = Convert.ToInt32(pStockInfoDR["BuyCost"].ToString()); int mSelCost = Convert.ToInt32(pStockInfoDR["SelCost"].ToString()); if (mSP.IsSelPattern_S0001(pStockDS.Tables["LINE1"], StockPattern.RatioType.Line1)) { mSCODE = "S0001_01"; } else if (mSP.IsSelPattern_S0001(pStockDS.Tables["LINE5"], StockPattern.RatioType.Line5)) { mSCODE = "S0001_05"; } else if (mSP.IsSelPattern_S0001(pStockDS.Tables["LINE10"], StockPattern.RatioType.Line10)) { mSCODE = "S0001_10"; } else if (mSP.IsSelPattern_S0002(mBuyPatternCode, mBuyCost, pNowCost)) { mSCODE = "S0002_01"; } else if (mSP.IsSelPattern_S0003(mBuyPatternCode, mBuyCost, pNowCost)) { mSCODE = "S0003_01"; } else if (mSP.IsSelPattern_S0004(mBuyCost, pNowCost)) { mSCODE = "S0004_01"; } else if (mSP.IsSelPattern_S0005(mBuyPatternCode, mBuyDate, mBuyCost, pNowCost)) { mSCODE = "S0005_01"; } else if (mSP.IsSelPattern_S0006(mSelCost, pNowCost)) { mSCODE = "S0006_01"; } else if (mSP.IsSelPattern_S0007(mBuyPatternCode, mBuyDate, mBuyCost, pNowCost)) { mSCODE = "S0007_01"; } mSP = null; string mPattern = ""; if (mSCODE != "") { string mLineCode = mSCODE.Substring(6, 2); if (mLineCode == "01") { mPattern = GetPattern(pStockDS.Tables["LINE1"]); } if (mLineCode == "05") { mPattern = GetPattern(pStockDS.Tables["LINE5"]); } if (mLineCode == "10") { mPattern = GetPattern(pStockDS.Tables["LINE10"]); } mResult = mSCODE + "|" + mPattern; } return mResult; }