private void WinScoreScale() { DataTable dt = MSSQL.Select(ConnectionString, "select id, PlayTypeID, WinMoney, LotteryNumber, IsuseID, Multiple from T_Schemes where not exists (select 1 from T_SchemeIsCalcuteScore where ScoreType = 2 and T_Schemes.ID = T_SchemeIsCalcuteScore.SchemeID) and ID > isnull((select max(SchemeID) - 10000 from T_SchemeIsCalcuteScore where ScoreType = 2), 0) and exists (select 1 from T_Isuses where LotteryID in (6, 28, 29, 60, 61, 62, 63, 64, 68, 70) and T_Isuses.ID = T_Schemes.IsuseID) and isOpened = 1 order by IsuseID desc"); if (dt == null) { log.Write("Exec WinScoreScale: DataTable \"WinScoreScale\" Fail."); return; } if (dt.Rows.Count < 1) { return; } DAL.Tables.T_SchemeIsCalcuteScore t_SchemeIsCalcuteScore = new DAL.Tables.T_SchemeIsCalcuteScore(); DataTable dtIsuses = null; DataTable dtWinMoney = null; foreach (DataRow dr in dt.Rows) { if (Shove._Convert.StrToDouble(dr["WinMoney"].ToString(), 0) == 0) { t_SchemeIsCalcuteScore.SchemeID.Value = dr["ID"].ToString(); t_SchemeIsCalcuteScore.ScoreType.Value = 2; t_SchemeIsCalcuteScore.Insert(ConnectionString); continue; } dtIsuses = new DAL.Tables.T_Isuses().Open(ConnectionString, "WinLotteryNumber, LotteryID", "ID=" + dr["IsuseID"].ToString(), ""); if (dtIsuses == null) { log.Write("Exec WinScoreScale: DataTable \"T_Isuses\" Fail.期号为:" + dr["IsuseID"].ToString()); continue; } if (dtIsuses.Rows.Count < 1) { continue; } dtWinMoney = MSSQL.Select(ConnectionString, "select DefaultMoney * a.ScoreScale as DefaultMoney, DefaultMoneyNoWithTax * a.ScoreScale as DefaultMoneyNoWithTax, a.WinMoney as WinMoney from T_WinTypes inner join T_WinScoreScale a on T_WinTypes.ID = a.WinTypeID where exists (select * from T_PlayTypes where ID = " + dr["PlayTypeID"].ToString() + " and T_WinTypes.LotteryID = T_PlayTypes.LotteryID) order by [Order]"); if (dtWinMoney == null) { log.Write("Exec WinScoreScale: DataTable \"dtWinMoney\" Fail.期号为:" + dr["IsuseID"].ToString()); continue; } if (dtWinMoney.Rows.Count < 1) { continue; } double[] WinMoneyList = new double[dtWinMoney.Rows.Count * 2]; double MaxMoney = 0; for (int i = 0; i < dtWinMoney.Rows.Count; i++) { WinMoneyList[i * 2] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoney"].ToString(), 0); WinMoneyList[i * 2 + 1] = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["DefaultMoneyNoWithTax"].ToString(), 0); if (Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0) > MaxMoney) { MaxMoney = Shove._Convert.StrToDouble(dtWinMoney.Rows[i]["WinMoney"].ToString(), 0); } } string LotteryNumber = dr["LotteryNumber"].ToString(); string Description = ""; double WinMoneyNoWithTax = 0; double WinMoney = 0; try { WinMoney = new SLS.Lottery()[int.Parse(dtIsuses.Rows[0]["LotteryID"].ToString())].ComputeWin(LotteryNumber, dtIsuses.Rows[0]["WinLotteryNumber"].ToString(), ref Description, ref WinMoneyNoWithTax, int.Parse(dr["PlayTypeID"].ToString()), WinMoneyList); } catch { WinMoney = 0; } log.Write("方案号:" + dr["ID"].ToString() + "-------中奖金额:" + (Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney).ToString() + "-----------最大金额:" + MaxMoney.ToString()); if (DAL.Procedures.P_SchemeWinCalculatedScore(ConnectionString, Shove._Convert.StrToLong(dr["ID"].ToString(), 0), Shove._Convert.StrToDouble(dr["Multiple"].ToString(), 0) * WinMoney, MaxMoney) < 0) { log.Write("Exec WinScoreScale: Procedures \"P_SchemeWinCalculatedScore\" Fail."); continue; } } #endregion }