public static bool dbGetMatch2GameObj(Int32 nMatchID, ref GameGeneralBall gameObj) { if (nMatchID <= 0) { Debug.Assert(false); return(false); } DataTable tbl = dbGetMatchInfo(nMatchID, g_strLanguage); if (tbl == null || tbl.Rows.Count < 1) { return(false); } //开始读取记录 //先初始化Game gameObj.SetRuleModel(Common.g_isVB ? EGbGameType.emGameVolleyBall : EGbGameType.emGameBeachVolleyBall); int nServe = Common.Str2Int(tbl.Rows[0]["F_Serve"]); int nCurSet = Common.Str2Int(tbl.Rows[0]["F_CurSet"]); if (nCurSet < 1 || nCurSet > GameGeneralBall.MAX_SET) { nCurSet = 1; } for (int nCycSet = 1; nCycSet <= 5; nCycSet++) { Int32 nSetTime = Common.Str2Int(tbl.Rows[0]["F_SetTime" + nCycSet.ToString()]); Int32 nSetScoreA = Common.Str2Int(tbl.Rows[0]["F_PtsA" + nCycSet.ToString()]); Int32 nSetScoreB = Common.Str2Int(tbl.Rows[0]["F_PtsB" + nCycSet.ToString()]); if (nSetTime < 0 || nSetScoreA < 0 || nSetScoreB < 0) { Debug.Assert(false); } else { gameObj.SetScore(nSetScoreA, false, nCycSet); gameObj.SetScore(nSetScoreB, true, nCycSet); gameObj.SetTimeSet((nSetTime).ToString(), nCycSet); } } gameObj.SetServeTeamB(nServe == 1); gameObj.SetCurSet(nCurSet); string matchTime = tbl.Rows[0]["F_MatchTime"].ToString(); gameObj.SetTimeMatch(matchTime); return(true); }
//从数据库刷新界面 //未从新刷新队员等信息,所以只能用于中途刷新 private bool scoreInfoRefresh() { //获取比分 GameGeneralBall gameObj = new GameGeneralBall(); if (Common.dbGetMatch2GameObj(Common.g_nMatchID, ref gameObj)) { //将比分对象覆盖当前的 Common.g_Game = gameObj; //刷新比分 dgvMatchScoreRefresh(); } else { Debug.Assert(false); } return(true); }
public bool dgvMatchScoreRefresh(GameGeneralBall gameObj = null) { if (gameObj == null) { gameObj = Common.g_Game; } dgvMatchScore[2, 1].Value = gameObj.IsServeTeamB() ? "" : "●"; dgvMatchScore[2, 2].Value = gameObj.IsServeTeamB() ? "●" : ""; dgvMatchScore[3, 1].Value = gameObj.GetScoreSetStr(false, 1); dgvMatchScore[3, 2].Value = gameObj.GetScoreSetStr(true, 1); dgvMatchScore[4, 1].Value = gameObj.GetScoreSetStr(false, 2); dgvMatchScore[4, 2].Value = gameObj.GetScoreSetStr(true, 2); dgvMatchScore[5, 1].Value = gameObj.GetScoreSetStr(false, 3); dgvMatchScore[5, 2].Value = gameObj.GetScoreSetStr(true, 3); dgvMatchScore[6, 1].Value = gameObj.GetScoreSetStr(false, 4); dgvMatchScore[6, 2].Value = gameObj.GetScoreSetStr(true, 4); dgvMatchScore[7, 1].Value = gameObj.GetScoreSetStr(false, 5); dgvMatchScore[7, 2].Value = gameObj.GetScoreSetStr(true, 5); dgvMatchScore[8, 1].Value = gameObj.GetScoreMatchStr(false); dgvMatchScore[8, 2].Value = gameObj.GetScoreMatchStr(true); dgvMatchScore[3, 1].Style.ForeColor = gameObj.GetWinSet(1) == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[3, 2].Style.ForeColor = gameObj.GetWinSet(1) == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[4, 1].Style.ForeColor = gameObj.GetWinSet(2) == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[4, 2].Style.ForeColor = gameObj.GetWinSet(2) == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[5, 1].Style.ForeColor = gameObj.GetWinSet(3) == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[5, 2].Style.ForeColor = gameObj.GetWinSet(3) == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[6, 1].Style.ForeColor = gameObj.GetWinSet(4) == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[6, 2].Style.ForeColor = gameObj.GetWinSet(4) == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[7, 1].Style.ForeColor = gameObj.GetWinSet(5) == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[7, 2].Style.ForeColor = gameObj.GetWinSet(5) == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[8, 1].Style.ForeColor = gameObj.GetWinMatch() == EGbTeam.emTeamA ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[8, 2].Style.ForeColor = gameObj.GetWinMatch() == EGbTeam.emTeamB ? ClrScr_Win : ClrScr_Nor; dgvMatchScore[3, 3].Value = gameObj.GetTimeSetStr(1); dgvMatchScore[4, 3].Value = gameObj.GetTimeSetStr(2); dgvMatchScore[5, 3].Value = gameObj.GetTimeSetStr(3); dgvMatchScore[6, 3].Value = gameObj.GetTimeSetStr(4); dgvMatchScore[7, 3].Value = gameObj.GetTimeSetStr(5); dgvMatchScore[8, 3].Value = gameObj.GetTimeMatchStr(); Int32 nCurSet = gameObj.GetCurSet(); dgvMatchScore[3, 0].Value = (nCurSet == 1) ? "●" : ""; dgvMatchScore[4, 0].Value = (nCurSet == 2) ? "●" : ""; dgvMatchScore[5, 0].Value = (nCurSet == 3) ? "●" : ""; dgvMatchScore[6, 0].Value = (nCurSet == 4) ? "●" : ""; dgvMatchScore[7, 0].Value = (nCurSet == 5) ? "●" : ""; DataTable tblMatchInfo = Common.dbGetMatchInfo(Common.g_nMatchID, Common.g_strLanguage); if (tblMatchInfo != null) { dgvMatchScore[1, 1].Value = tblMatchInfo.Rows[0]["F_IRMCodeA"].ToString(); dgvMatchScore[1, 2].Value = tblMatchInfo.Rows[0]["F_IRMCodeB"].ToString(); } dgvMatchScore[8, 0].Value = gameObj.GetPointInfo().GetCountStr() + ' ' + gameObj.GetPointInfo().GetPointStr(); return(true); }
protected override void OnMgrEvent(object sender, OVRMgr2PluginEventArgs e) { switch (e.Type) { case OVRMgr2PluginEventType.emMatchSelected: //选择比赛时 { if (m_frmPlugin.Enabled) { if (MessageBox.Show("直接切换比赛?", "切换比赛", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } } int nMatchID = Common.Str2Int(e.Args.ToString()); if (nMatchID <= 0) { Debug.Assert(false); return; } DataTable tblMatch = Common.dbGetMatchInfo(nMatchID, Common.g_strLanguage); if (tblMatch == null || tblMatch.Rows.Count < 1 || tblMatch.Columns.Count < 1) { MessageBox.Show("exec proc_VB_PRG_MatchInfo failed.\n读取新比赛基础数据失败! 未切换比赛!"); return; } Int32 nDisciplineID = Common.Str2Int(tblMatch.Rows[0]["F_DisciplineID"]); Int32 nEventID = Common.Str2Int(tblMatch.Rows[0]["F_EventID"]); Int32 nTeamRegIDA = Common.Str2Int(tblMatch.Rows[0]["F_TeamARegID"]); Int32 nTeamRegIDB = Common.Str2Int(tblMatch.Rows[0]["F_TeamBRegID"]); String strTeamANoc = tblMatch.Rows[0]["F_TeamANoc"].ToString(); String strTeamBNoc = tblMatch.Rows[0]["F_TeamBNoc"].ToString(); String strTeamAName = tblMatch.Rows[0]["F_TeamAName"].ToString(); String strTeamBName = tblMatch.Rows[0]["F_TeamBName"].ToString(); String strVenue = tblMatch.Rows[0]["F_VenueDes"].ToString(); if (nDisciplineID <= 0 || nEventID <= 0) { MessageBox.Show("SprotID,nDispID,nEventID不正确! 未切换比赛!"); return; } if (nTeamRegIDA <= 0 || nTeamRegIDB <= 0) { MessageBox.Show("该场比赛未指派双方队伍! 未切换比赛!"); return; } if (strVenue.Length == 0) { if (MessageBox.Show("该比赛未指定场馆,是否继续?", "切换比赛", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } } //如果是新建比赛,通过GameObject写入一次库 int nCretaeMatchResult = Common.dbInitMatch(nMatchID, 5, false); if (nCretaeMatchResult == 0) { MessageBox.Show("exec proc_VB_PRG_MatchCreate failed.\n在数据库中初始化新比赛局信息失败! 未切换比赛!"); return; } else if (nCretaeMatchResult == 1) { GameGeneralBall newGameObj = new GameGeneralBall(); if (!Common.dbGetMatch2GameObj(nMatchID, ref newGameObj)) { MessageBox.Show("exec proc_VB_PRG_MatchInfo failed.\n读取新比赛比分数据失败! 未切换比赛!"); //以后改成强行重置选项 return; } //再往库中写一次,是为了避免第一次进入比赛后,没有局标示的问题5 if (!Common.dbGameObj2Db(nMatchID, newGameObj)) { MessageBox.Show("exec proc_VB_PRG_MatchSetScore failed.\n写入新比分数据失败! 未切换比赛!"); return; } } GameGeneralBall gameObj = new GameGeneralBall(); if (!Common.dbGetMatch2GameObj(nMatchID, ref gameObj)) { MessageBox.Show("exec proc_VB_PRG_MatchInfo failed.\n读取比赛比分数据失败! 未切换比赛!"); return; } //开始切换比赛 Common.g_Game = gameObj; Common.g_nDiscID = nDisciplineID; Common.g_nEventID = nEventID; Common.g_nMatchID = nMatchID; Common.g_nTeamRegIDA = nTeamRegIDA; Common.g_nTeamRegIDB = nTeamRegIDB; Common.g_strNocA = strTeamANoc; Common.g_strNocB = strTeamBNoc; SetReportContext("MatchID", Common.g_nMatchID.ToString()); m_frmPlugin.OnMatchChanged(0); break; } case OVRMgr2PluginEventType.emRptContextQuery: { if (e == null || e.Args == null) { return; } OVRReportContextQueryArgs rptQuery = e.Args as OVRReportContextQueryArgs; switch (rptQuery.Name) { case "MatchID": { rptQuery.Value = Common.g_nMatchID.ToString(); rptQuery.Handled = true; } break; case "DisciplineID": { rptQuery.Value = Common.g_nDiscID.ToString(); rptQuery.Handled = true; } break; default: break; } break; } } }
public static bool dbGameObj2Db(Int32 nMatchID, GameGeneralBall gameObj) { if (nMatchID <= 0) { Debug.Assert(false); return(false); } StringBuilder strWin = new StringBuilder(); StringBuilder strTime = new StringBuilder(); StringBuilder strPoint = new StringBuilder(); StringBuilder strScoreIntA = new StringBuilder(); StringBuilder strScoreIntB = new StringBuilder(); StringBuilder strScoreStrA = new StringBuilder(); StringBuilder strScoreStrB = new StringBuilder(); //先往字符串里装入总的信息 Int32 nWin = 0; EGbTeam eTeam = gameObj.GetWinMatch(); if (eTeam == EGbTeam.emTeamA) { nWin = 1; } else if (eTeam == EGbTeam.emTeamB) { nWin = 2; } else { nWin = 0; } strWin.Append(nWin); strTime.Append(gameObj.GetTimeMatch() / 1000 / 60); //获取Point信息 { SGbPointInfo ePoint = gameObj.GetPointInfo(); if (ePoint.m_ePoint == EGbPointInfo.emPointSet) { strPoint.Append("1,"); } else if (ePoint.m_ePoint == EGbPointInfo.emPointGame || ePoint.m_ePoint == EGbPointInfo.emPointMatch) { strPoint.Append("2,"); } else { strPoint.Append("0,"); } if (ePoint.m_eTeam == EGbTeam.emTeamA) { strPoint.Append("1,"); } else if (ePoint.m_eTeam == EGbTeam.emTeamB) { strPoint.Append("2,"); } else { strPoint.Append("0,"); } strPoint.Append(ePoint.m_byCount.ToString()); strPoint.Append(","); } strScoreIntA.Append(gameObj.GetScoreMatch(false)); strScoreIntB.Append(gameObj.GetScoreMatch(true)); strScoreStrA.Append(gameObj.GetScoreMatchStr(false)); strScoreStrB.Append(gameObj.GetScoreMatchStr(true)); strWin.Append(','); strTime.Append(','); strScoreIntA.Append(','); strScoreIntB.Append(','); strScoreStrA.Append(','); strScoreStrB.Append(','); //再循环装入每局信息 for (int nCycSet = 1; nCycSet < GameGeneralBall.MAX_SET; nCycSet++) { Int32 nSetWin = 0; EGbTeam eSetTeam = gameObj.GetWinSet(nCycSet); if (eSetTeam == EGbTeam.emTeamA) { nSetWin = 1; } else if (eSetTeam == EGbTeam.emTeamB) { nSetWin = 2; } else { nSetWin = 0; } strWin.Append(nSetWin); strTime.Append(gameObj.GetTimeSet(nCycSet) / 1000 / 60); strScoreIntA.Append(gameObj.GetScoreSet(false, nCycSet)); strScoreIntB.Append(gameObj.GetScoreSet(true, nCycSet)); strScoreStrA.Append(gameObj.GetScoreSetStr(false, nCycSet)); strScoreStrB.Append(gameObj.GetScoreSetStr(true, nCycSet)); strWin.Append(','); strTime.Append(','); strScoreIntA.Append(','); strScoreIntB.Append(','); strScoreStrA.Append(','); strScoreStrB.Append(','); } SqlCommand dbCmd = new SqlCommand("proc_VB_PRG_MatchSetScore", g_DataBaseCon); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.Parameters.AddWithValue("@MatchID", nMatchID); dbCmd.Parameters.AddWithValue("@SetCount", 5); dbCmd.Parameters.AddWithValue("@CurSet", gameObj.GetCurSet()); dbCmd.Parameters.AddWithValue("@ServeTeamB", gameObj.IsServeTeamB() ? 1 : 0); dbCmd.Parameters.AddWithValue("@PointInfo", strPoint.ToString()); dbCmd.Parameters.AddWithValue("@SetWinList", strWin.ToString()); dbCmd.Parameters.AddWithValue("@SetTimeList", strTime.ToString()); dbCmd.Parameters.AddWithValue("@SetScoreListA", strScoreIntA.ToString()); dbCmd.Parameters.AddWithValue("@SetScoreListB", strScoreIntB.ToString()); dbCmd.Parameters.AddWithValue("@SetScoreListStrA", strScoreStrA.ToString()); dbCmd.Parameters.AddWithValue("@SetScoreListStrB", strScoreStrB.ToString()); dbCmd.Parameters.AddWithValue("@Result", DBNull.Value); dbCmd.Parameters["@Result"].Size = 4; dbCmd.Parameters["@Result"].SqlDbType = SqlDbType.Int; dbCmd.Parameters["@Result"].Direction = ParameterDirection.Output; if (!dbExecuteNonQuery(ref dbCmd)) { MessageBox.Show("proc_VB_PRG_MatchSetScore exec failed!"); return(false); } if ((int)dbCmd.Parameters["@Result"].Value <= 0) { MessageBox.Show("proc_VB_PRG_MatchSetScore return failed!"); return(false); } return(true); }