예제 #1
0
        //Action GamePoint MatchPoint
        bool AddActionList(Int32 nPosition, Int32 nRegisterID, Int32 nResultA, Int32 nResultB, Int32 nScore)
        {
            Int32 nPointType;
            Int32 nActionID;

            Int32 nMatchA = BDCommon.Str2Int(lb_A_GameTotal.Text);
            Int32 nMatchB = BDCommon.Str2Int(lb_B_GameTotal.Text);

            m_CurMatchRule.StatGameMatchPoint(nResultA, nResultB, nMatchA, nMatchB, out nPointType);
            nActionID = BDCommon.g_ManageDB.GetActionID(BDCommon.strAction_addScore);

            if (IsDouble())
            {
                BDCommon.g_ManageDB.AddDoubleActionList(nPosition, m_nCurMatchID, m_nCurGameID, m_nDoubleRegisterA1,
                                                        m_nDoubleRegisterA2, m_nDoubleRegisterB1, m_nDoubleRegisterB2, nScore);
            }
            else
            {
                BDCommon.g_ManageDB.AddActionList(nPosition, m_nCurMatchID, m_nCurGameID, nRegisterID, nActionID, nScore, nPointType);
            }


            BDCommon.g_BDPlugin.DataChangedNotify(OVRDataChangedType.emMatchStatistic, -1, -1, -1, m_nCurMatchID, m_nCurMatchID, null);
            return(true);
        }
예제 #2
0
        void UIGamesTotal2MatchResultsToDB()
        {
            String strGameATScore, strGameBTScore;
            Int32  nGameATScore, nGameBTScore;

            strGameATScore = lb_A_GameTotal.Text;
            strGameBTScore = lb_B_GameTotal.Text;
            nGameATScore   = BDCommon.Str2Int(strGameATScore);
            nGameBTScore   = BDCommon.Str2Int(strGameBTScore);

            if (m_nCurMatchType == BDCommon.MATCH_TYPE_TEAM && m_nCurTeamSplitID > 0)
            {
                if (!m_CurMatchRule.UpdateTeamSplitResultsToDB(m_nCurTeamSplitID, nGameATScore, nGameBTScore, m_nRegAPos, m_nRegBPos))
                {
                    UpdateTeamSplitResult(true);             // Recover if not valid
                    return;
                }

                if (m_CurMatchRule.IsGamesTotalScoreFinished(nGameATScore, nGameBTScore))
                {
                    // Statistic Match Score and Update to DB
                    Int32 nMatchScoreA = 0;
                    Int32 nMatchScoreB = 0;
                    if (m_CurMatchRule.GetMatchScoreFromTeamSplits(ref nMatchScoreA, ref nMatchScoreB))
                    {
                        // Update match result
                        if (m_CurMatchRule.UpdateMatchResultsToDB(nMatchScoreA, nMatchScoreB, m_nRegAPos, m_nRegBPos))
                        {
                            lb_Home_Score.Text = nMatchScoreA.ToString();
                            lb_Away_Score.Text = nMatchScoreB.ToString();
                        }
                    }
                    //还应该更新TeamSplit的状态
                    BDCommon.g_ManageDB.SetMatchSplitStatus(m_nCurMatchID, m_nCurTeamSplitID, BDCommon.STATUS_FINISHED);
                }
                else
                {
                    BDCommon.g_ManageDB.SetMatchSplitStatus(m_nCurMatchID, m_nCurTeamSplitID, BDCommon.STATUS_RUNNING);
                }

                EnableTeamSplitRbtn(true, false);
                EnableGamesRbtnsAndLabels(true, false);
            }
            else
            {
                // Update match result
                if (m_CurMatchRule.UpdateMatchResultsToDB(nGameATScore, nGameBTScore, m_nRegAPos, m_nRegBPos))
                {
                    lb_Home_Score.Text = strGameATScore;
                    lb_Away_Score.Text = strGameBTScore;
                }
                else         // Recover from Match result
                {
                    UI_MatchScoreToGamesTotal();
                }

                EnableGamesRbtnsAndLabels(true, false);
            }
        }
예제 #3
0
        protected override void OnMgrEvent(object sender, OVRMgr2PluginEventArgs e)
        {
            switch (e.Type)
            {
            case OVRMgr2PluginEventType.emMatchSelected:
            {
                if (m_frmBDPlugin != null)
                {
                    m_frmBDPlugin.OnMsgFlushSelMatch(0, BDCommon.Str2Int(e.Args.ToString()));
                }
                break;
            }

            case OVRMgr2PluginEventType.emRptContextQuery:
            {
                m_frmBDPlugin.QueryReportContext(e.Args as OVRReportContextQueryArgs);
                break;
            }
            }
        }
        private void EnableTeamSplitRbtn(Boolean bEnable, Boolean bClear)
        {
            if (bClear && m_nCurTeamSplitID > 0)
            {
                if (m_rbtnCurChkedSplit != null)
                {
                    m_rbtnCurChkedSplit.Checked = false;
                }
            }

            // Get enable games count
            Int32 nEnableCount = m_nTeamSplitCount;

            if (m_CurMatchRule != null)
            {
                String strMatchScoreA, strMatchScoreB;
                BDCommon.g_ManageDB.GetMatchScore(m_nCurMatchID, out strMatchScoreA, out strMatchScoreB);
                Int32 nMatchScoreA = BDCommon.Str2Int(strMatchScoreA);
                Int32 nMatchScoreB = BDCommon.Str2Int(strMatchScoreB);

                if (m_CurMatchRule.IsMatchScoreFinished(nMatchScoreA, nMatchScoreB))
                {
                    nEnableCount = nMatchScoreA + nMatchScoreB;
                }
                else
                {
                    nEnableCount = nMatchScoreA + nMatchScoreB + 1;
                }
            }

            btnx_Split1.Enabled          = nEnableCount >= 1 ? bEnable : false;
            btnx_Split2.Enabled          = nEnableCount >= 2 ? bEnable : false;
            btnx_Split3.Enabled          = nEnableCount >= 3 ? bEnable : false;
            btnx_Split4.Enabled          = nEnableCount >= 4 ? bEnable : false;
            btnx_Split5.Enabled          = nEnableCount >= 5 ? bEnable : false;
            btnx_SubMatch_Result.Enabled = nEnableCount > 0 ? bEnable : false;
        }
        private void EnableGamesRbtnsAndLabels(Boolean bEnable, Boolean bClear)
        {
            if (bClear && m_rbtnCurChkedGame != null)
            {
                m_rbtnCurChkedGame.Checked = false;
            }

            // Get enable games count
            int nEnableCount = m_nGamesCount;

            if (m_CurMatchRule != null)
            {
                int nTotalScoreA = BDCommon.Str2Int(lb_A_GameTotal.Text);
                int nTotalScoreB = BDCommon.Str2Int(lb_B_GameTotal.Text);
                if (m_CurMatchRule.IsGamesTotalScoreFinished(nTotalScoreA, nTotalScoreB))
                {
                    nEnableCount = nTotalScoreA + nTotalScoreB;
                }
                else
                {
                    nEnableCount = nTotalScoreA + nTotalScoreB + 1;
                }
            }

            btnx_Game_Result.Enabled = nEnableCount > 0 ? bEnable : false;

            // Use Reflection
            Type theType = typeof(frmOVRBDDataEntry);

            for (Int32 i = 1; i < 10; i++)
            {
                String strVarNameA      = "lb_A_Game" + i.ToString();
                String strVarNameB      = "lb_B_Game" + i.ToString();
                String strVarRadBtnName = "rad_Game" + i.ToString();

                FieldInfo fi_VarA      = theType.GetField(strVarNameA, BindingFlags.Instance | BindingFlags.NonPublic);
                FieldInfo fi_VarB      = theType.GetField(strVarNameB, BindingFlags.Instance | BindingFlags.NonPublic);
                FieldInfo fi_VarRadBtn = theType.GetField(strVarRadBtnName, BindingFlags.Instance | BindingFlags.NonPublic);
                if (fi_VarA == null || fi_VarB == null || fi_VarRadBtn == null)
                {
                    break;
                }

                Label       lbTempA  = (Label)fi_VarA.GetValue(this);
                Label       lbTempB  = (Label)fi_VarB.GetValue(this);
                RadioButton rbtnTemp = (RadioButton)fi_VarRadBtn.GetValue(this);

                if (i <= nEnableCount)
                {
                    lbTempA.Enabled  = bEnable;
                    lbTempB.Enabled  = bEnable;
                    rbtnTemp.Enabled = bEnable;

                    if (bClear)
                    {
                        lbTempA.Text = "0";
                        lbTempB.Text = "0";
                    }
                }
                else
                {
                    lbTempA.Enabled  = false;
                    lbTempB.Enabled  = false;
                    rbtnTemp.Enabled = false;
                    //lbTempA.Text = "0";
                    //lbTempB.Text = "0";
                }
            }
        }
예제 #6
0
        public bool GetGamesTotalFromGames(Int32 nTeamSplitID, ref Int32 nPointsA, ref Int32 nPointsB)
        {
            if (m_nMatchID <= 0 || nTeamSplitID < 0 || m_nGamesCount <= 0)
            {
                return(false);
            }

            // nTeamSplitID=0, means not team type match
            if (nTeamSplitID == 0 && m_nMatchType == BDCommon.MATCH_TYPE_TEAM)
            {
                return(false);
            }

            Int32 nTotalScoreA = 0;
            Int32 nTotalScoreB = 0;

            STableRecordSet stRecords;

            if (!BDCommon.g_ManageDB.GetSubSplitInfo(m_nMatchID, nTeamSplitID, out stRecords))
            {
                return(false);
            }

            Int32 nCount = stRecords.GetRecordCount();

            for (Int32 i = 0; i < nCount; i++)
            {
                Int32 nGameID = Convert.ToInt32(stRecords.GetFieldValue(i, "F_MatchSplitID"));

                STableRecordSet stSplitResults;
                if (!BDCommon.g_ManageDB.GetMatchSplitResult(m_nMatchID, nGameID, out stSplitResults))
                {
                    continue;
                }

                Int32 nResultA = BDCommon.Str2Int(stSplitResults.GetFieldValue(0, "F_ResultID"));
                Int32 nResultB = BDCommon.Str2Int(stSplitResults.GetFieldValue(1, "F_ResultID"));

                if (nResultA == BDCommon.RESULT_TYPE_WIN && nResultB == BDCommon.RESULT_TYPE_LOSE)
                {
                    nTotalScoreA++;
                }
                else if (nResultB == BDCommon.RESULT_TYPE_WIN && nResultA == BDCommon.RESULT_TYPE_LOSE)
                {
                    nTotalScoreB++;
                }
                else if (nResultA == BDCommon.RESULT_TYPE_TIE && nResultB == BDCommon.RESULT_TYPE_TIE)
                {
                    nTotalScoreA++;
                    nTotalScoreB++;
                }
                else
                {
                    continue; // The Game has not been completed
                }
            }

            nPointsA = nTotalScoreA;
            nPointsB = nTotalScoreB;

            return(true);
        }
예제 #7
0
        public bool GetMatchScoreFromTeamSplits(ref Int32 nPointsA, ref Int32 nPointsB)
        {
            if (m_nMatchID <= 0 || m_nMatchType != BDCommon.MATCH_TYPE_TEAM || m_nSplitsCount <= 0)
            {
                return(false);
            }

            Int32 nMatchScoreA = 0;
            Int32 nMatchScoreB = 0;

            STableRecordSet stRecords;

            if (!BDCommon.g_ManageDB.GetSubSplitInfo(m_nMatchID, 0, out stRecords))
            {
                return(false);
            }

            Int32 nCount = stRecords.GetRecordCount();

            for (Int32 i = 0; i < nCount; i++)
            {
                Int32 nTeamSplitID = BDCommon.Str2Int(stRecords.GetFieldValue(i, "F_MatchSplitID"));

                STableRecordSet stSplitResults;
                if (!BDCommon.g_ManageDB.GetMatchSplitResult(m_nMatchID, nTeamSplitID, out stSplitResults))
                {
                    continue;
                }

                Int32 nResultA = BDCommon.Str2Int(stSplitResults.GetFieldValue(0, "F_ResultID"));
                Int32 nResultB = BDCommon.Str2Int(stSplitResults.GetFieldValue(1, "F_ResultID"));

                // Statistic the score of each valid team split
                if (nResultA == BDCommon.RESULT_TYPE_WIN && nResultB == BDCommon.RESULT_TYPE_LOSE)
                {
                    nMatchScoreA++;
                }
                else if (nResultB == BDCommon.RESULT_TYPE_WIN && nResultA == BDCommon.RESULT_TYPE_LOSE)
                {
                    nMatchScoreB++;
                }
                else if (nResultA == BDCommon.RESULT_TYPE_TIE && nResultB == BDCommon.RESULT_TYPE_TIE)
                {
                    nMatchScoreA++;
                    nMatchScoreB++;
                }
                else
                {
                    continue; // The Split has not been completed
                }
                if (IsValidMatchScore(nMatchScoreA, nMatchScoreB) && IsMatchScoreFinished(nMatchScoreA, nMatchScoreB))
                {
                    break;
                }
            }

            nPointsA = nMatchScoreA;
            nPointsB = nMatchScoreB;

            return(true);
        }