//开奖派奖 private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber) { Log log = new Log("SystemGetLotteryOpenNumber"); if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber)) { log.Write("开奖号码不正确!"); return; } int ReturnValue = 0; string ReturnDescription = ""; DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", ""); if (dtIsuse == null) { log.Write("数据读写错误001"); return; } if (dtIsuse.Rows.Count <= 0) { //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName); return; } if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false)) { //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖"); return; } long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1); DataTable dtWin = null; dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", ""); if (dtWin == null) { log.Write("数据读写错误002"); return; } // 准备开奖,开奖之前,对出票不完整的方案进行出票处理 ReturnValue = 0; ReturnDescription = ""; DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]"); if (dtWinTypes == null) { log.Write("奖金读取数据读写错误"); return; } double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2]; for (int y = 0; y < dtWinTypes.Rows.Count; y++) { WinMoneyList[y * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0); WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0); if (WinMoneyList[y * 2] < 0) { log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!"); return; } } dtWin = null; #region 开奖第一步 dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]"); if (dtWin == null) { log.Write("方案数据读取错误"); return; } for (int y = 0; y < dtWin.Rows.Count; y++) { string LotteryNumber = ""; try { LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString(); } catch { } string Description = ""; double WinMoneyNoWithTax = 0; try { double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList); if (WinMoney > 0) { log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString()); } Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(), new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)), new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)), new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description)); } catch { log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误"); continue; } } #endregion log.Write("开奖-----------------------------4"); #region 开奖第三步 string OpenAffiche = new OpenAfficheTemplates()[LotteryID]; int SchemeCount, QuashCount, WinCount, WinNoBuyCount; bool isEndOpen = false; while (!isEndOpen) { SchemeCount = 0; QuashCount = 0; WinCount = 0; WinNoBuyCount = 0; // 总方案数,处理时撤单数,中奖数,中奖但未成功数 ReturnValue = 0; ReturnDescription = ""; DataSet dsWin = null; P_Win(conn, ref dsWin, IsuseID, WinNumber, OpenAffiche, 1, true, ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount, ref isEndOpen, ref ReturnValue, ref ReturnDescription); if ((dsWin == null) || (ReturnDescription != "")) { log.Write(ReturnDescription); return; } string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。"; if (isEndOpen) { Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。"; } log.Write(String.Format(Message, LotteryID, WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount)); } #endregion log.Write("开奖-----------------------------5"); }
//开奖派奖 private void DrawingLottery(int LotteryID, string IsuseName, string WinNumber) { Log log = new Log("SystemGetLotteryOpenNumber"); if (!new SLS.Lottery()[LotteryID].AnalyseWinNumber(WinNumber)) { log.Write("开奖号码不正确!"); return; } int ReturnValue = 0; string ReturnDescription = ""; DataTable dtIsuse = new DAL.Tables.T_Isuses().Open(conn, "top 1 [ID], IsOpened", "LotteryID = " + LotteryID.ToString() + " and [Name] = '" + IsuseName + "' and IsOpened=0 and year(StartTime) = YEAR(GETDATE())", ""); if (dtIsuse == null) { log.Write("数据读写错误001"); return; } if (dtIsuse.Rows.Count <= 0) { //log.Write("暂无对应期号信息,彩种ID:" + LotteryID.ToString() + ", 期号:" + IsuseName); return; } if (Shove._Convert.StrToBool(dtIsuse.Rows[0]["IsOpened"].ToString(), false)) { //log.Write("彩种ID:" + LotteryID + "第" + IsuseName + "期已开奖"); return; } long IsuseID = Shove._Convert.StrToLong(dtIsuse.Rows[0]["ID"].ToString(), -1); DataTable dtWin = null; dtWin = new DAL.Tables.T_Schemes().Open(conn, "ID", "IsuseID = " + IsuseID.ToString() + " and isOpened = 0", ""); if (dtWin == null) { log.Write("数据读写错误002"); return; } // 准备开奖,开奖之前,对出票不完整的方案进行出票处理 ReturnValue = 0; ReturnDescription = ""; DataTable dtWinTypes = new DAL.Tables.T_WinTypes().Open(conn, "[DefaultMoney],[DefaultMoneyNoWithTax]", "LotteryID = " + LotteryID.ToString(), "[Order]"); if (dtWinTypes == null) { log.Write("奖金读取数据读写错误"); return; } double[] WinMoneyList = new double[dtWinTypes.Rows.Count * 2]; for (int y = 0; y < dtWinTypes.Rows.Count; y++) { WinMoneyList[y * 2] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoney"].ToString(), 0); WinMoneyList[y * 2 + 1] = Shove._Convert.StrToDouble(dtWinTypes.Rows[y]["DefaultMoneyNoWithTax"].ToString(), 0); if (WinMoneyList[y * 2] < 0) { log.Write("第 " + (y + 1).ToString() + " 项奖金输入错误!"); return; } } dtWin = null; #region 开奖第一步 dtWin = new DAL.Tables.T_Schemes().Open(conn, "LotteryNumber,PlayTypeID,Multiple,ID", "isOpened = 0 and IsuseID = " + IsuseID.ToString(), "[ID]"); if (dtWin == null) { log.Write("方案数据读取错误"); return; } for (int y = 0; y < dtWin.Rows.Count; y++) { string LotteryNumber = ""; try { LotteryNumber = dtWin.Rows[y]["LotteryNumber"].ToString(); } catch { } string Description = ""; double WinMoneyNoWithTax = 0; try { double WinMoney = new SLS.Lottery()[LotteryID].ComputeWin(LotteryNumber, WinNumber, ref Description, ref WinMoneyNoWithTax, int.Parse(dtWin.Rows[y]["PlayTypeID"].ToString()), WinMoneyList); if (WinMoney > 0) { log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 中奖金额:" + WinMoney.ToString()); } Shove.Database.MSSQL.ExecuteNonQuery(conn, "update T_Schemes set EditWinMoney = @p1, EditWinMoneyNoWithTax = @p2, WinDescription = @p3 where [ID] = " + dtWin.Rows[y]["ID"].ToString(), new Shove.Database.MSSQL.Parameter("p1", SqlDbType.Money, 0, ParameterDirection.Input, WinMoney * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)), new Shove.Database.MSSQL.Parameter("p2", SqlDbType.Money, 0, ParameterDirection.Input, WinMoneyNoWithTax * Shove._Convert.StrToInt(dtWin.Rows[y]["Multiple"].ToString(), 1)), new Shove.Database.MSSQL.Parameter("p3", SqlDbType.VarChar, 0, ParameterDirection.Input, Description)); } catch { log.Write("方案ID:" + dtWin.Rows[y]["ID"].ToString() + " 开奖号码出现错误"); continue; } } #endregion log.Write("开奖-----------------------------4"); #region 开奖第三步 string OpenAffiche = new OpenAfficheTemplates()[LotteryID]; int SchemeCount, QuashCount, WinCount, WinNoBuyCount; bool isEndOpen = false; while (!isEndOpen) { SchemeCount = 0; QuashCount = 0; WinCount = 0; WinNoBuyCount = 0; // 总方案数,处理时撤单数,中奖数,中奖但未成功数 ReturnValue = 0; ReturnDescription = ""; DataSet dsWin = null; P_Win(conn, ref dsWin, IsuseID, WinNumber, OpenAffiche, 1, true, ref SchemeCount, ref QuashCount, ref WinCount, ref WinNoBuyCount, ref isEndOpen, ref ReturnValue, ref ReturnDescription); if ((dsWin == null) || (ReturnDescription != "")) { log.Write(ReturnDescription); return; } string Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖还未全部完成, 请继续操作第三步。"; if (isEndOpen) { Message = "彩种ID:{0},开奖成功,开奖号码:{1},总方案 {2} 个,撤单未满员或未出票方案 {3} 个,有效中奖方案 {4} 个,中奖但未成功方案 {5} 个。本期开奖已全部完成。"; } log.Write(String.Format(Message,LotteryID,WinNumber, SchemeCount, QuashCount, WinCount, WinNoBuyCount)); } #endregion log.Write("开奖-----------------------------5"); }