Ejemplo n.º 1
0
        private void BtnScoreAddReduce_Click(object sender, EventArgs e)
        {
            bool exchangeAB = _chkScoreExchangeLR.Checked;

            if (sender == btnScoreAddA)
            {
                Common.g_Game.SetScoreAR(exchangeAB ? true : false, true);
            }
            else
            if (sender == btnScoreAddB)
            {
                Common.g_Game.SetScoreAR(exchangeAB ? false : true, true);
            }
            else
            if (sender == btnScoreReduceA)
            {
                Common.g_Game.SetScoreAR(exchangeAB ? true : false, false);
            }
            else
            if (sender == btnScoreReduceB)
            {
                Common.g_Game.SetScoreAR(exchangeAB ? false : true, false);
            }
            else
            {
                Debug.Assert(false);
                return;
            }

            Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);
            RefreshAll();

            Common.NotifyMatchResult();
            Common.dbMatchModifyTimeSet();
        }
        //根据STAT推算比分,在STAT编辑完成后,调用此函数,
        private bool CalScoreFromStat(bool bTeamA)
        {
            //首先根据当前STAT,推算单方比分,
            //之后和当前分数进行比较,一样,就返回False
            //不一样,就修改比分。并返回True,通知上层刷新
            object objScore = Common.dbGetScoreFromStat(bTeamA);

            if (objScore == null)
            {
                Debug.Assert(false);
                return(false);
            }

            int nNewScore = Common.Str2Int(objScore);
            int nOldScore = Common.g_Game.GetScoreSet(!bTeamA);

            if (nNewScore == nOldScore)
            {
                return(false);
            }

            Common.g_Game.SetScore(nNewScore, !bTeamA);

            if (nNewScore > nOldScore)                  //如果是赢球,需要设球权
            {
                Common.g_Game.SetServeTeamB(!bTeamA);
            }

            Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);

            return(true);
        }
        private void dgvMatchScore_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == 0)              //更换当前局
            {
                if (e.ColumnIndex >= 3 && e.ColumnIndex <= 7)
                {
                    Common.g_Game.SetCurSet(e.ColumnIndex - 2);
                    Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);

                    RefreshAll();

                    Common.NotifyMatchResult();
                    Common.g_Plugin.DataChangedNotify(OVRDataChangedType.emSplitCompetitorMember, -1, -1, -1, Common.g_nMatchID, Common.g_nMatchID, null);
                }
            }
            else
            if (e.RowIndex == 1)                //设球权
            {
                if (e.ColumnIndex == 2)
                {
                    Common.g_Game.SetServeTeamB(false);
                    Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);
                    dgvMatchScoreRefresh();

                    Common.NotifyMatchResult();
                }
            }
            else
            if (e.RowIndex == 2)                //设球权
            {
                if (e.ColumnIndex == 2)
                {
                    Common.g_Game.SetServeTeamB(true);
                    Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);
                    dgvMatchScoreRefresh();

                    Common.NotifyMatchResult();
                }
            }
            else
            {
                //Debug.Assert(false);
            }
        }
        private void dgvMatchScore_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            //没有选中的当前单元格,肯定不会
            if (dgvMatchScore.CurrentCell == null)
            {
                return;
            }

            //判断是否编辑的是IRM
            if (e.RowIndex >= 1 && e.RowIndex <= 2 && e.ColumnIndex == 1)
            {
                //有可能为空
                Int32 nIRM_ID = Common.Str2Int(dgvMatchScore.CurrentCell.Tag);

                if (!Common.dbIRMSet(Common.g_nMatchID, nIRM_ID, (e.RowIndex == 1)))
                {
                    MessageBox.Show("设置IRM信息失败!");
                }

                Common.dbMatchModifyTimeSet();
                Common.NotifyMatchResult();
                return;
            }

            //是否为编辑值
            if (((DataGridView)sender).CurrentCell.Value != null)
            {
                String strNewValue = ((DataGridView)sender).CurrentCell.Value.ToString();

                //判断是否编辑比分
                if (e.RowIndex >= 1 && e.RowIndex <= 2 && e.ColumnIndex >= 3 && e.ColumnIndex <= 7)
                {
                    Int32 nCurScore = Common.Str2Int(strNewValue);
                    nCurScore = Math.Max(nCurScore, 0);
                    bool  bTeamB     = (e.RowIndex == 2);
                    Int32 nSet       = e.ColumnIndex - 2;
                    Int32 ptsSetOppr = Common.g_Game.GetScoreSet(!bTeamB, nSet);
                    Int32 scoreWin   = Common.g_isVB ? 25 : 21;

                    //在第五局如果输入的值大于15分,给予一个提示
                    if (Common.g_isVB && nCurScore > 15 && nSet == 5 && nCurScore > ptsSetOppr + 2)
                    {
                        if (MessageBox.Show("第5局比分一般不会大于15. 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                            == System.Windows.Forms.DialogResult.Yes)
                        {
                            Common.g_Game.SetScore(nCurScore, bTeamB, nSet);
                        }
                    }
                    else
                    if (!Common.g_isVB && nCurScore > 15 && nSet == 3 && nCurScore > ptsSetOppr + 2)
                    {
                        if (MessageBox.Show("第3局比分一般不会大于15. 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                            == System.Windows.Forms.DialogResult.Yes)
                        {
                            Common.g_Game.SetScore(nCurScore, bTeamB, nSet);
                        }
                    }
                    else
                    if (nCurScore > scoreWin && nCurScore > ptsSetOppr + 2)
                    {
                        if (MessageBox.Show("比分一般不会大于" + scoreWin.ToString() + ". 是否继续?", "比分提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                            == System.Windows.Forms.DialogResult.Yes)
                        {
                            Common.g_Game.SetScore(nCurScore, bTeamB, nSet);
                        }
                    }
                    else
                    {
                        Common.g_Game.SetScore(nCurScore, bTeamB, nSet);
                    }

                    Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);
                    dgvMatchScoreRefresh();
                    Common.NotifyMatchResult();

                    return;
                }

                //时间
                if (e.RowIndex == 3 && e.ColumnIndex >= 3 && e.ColumnIndex <= 8)
                {
                    int nTime  = 0;
                    int nIndex = strNewValue.IndexOf(':');

                    if (nIndex > 0)
                    {
                        nTime  = Common.Str2Int(strNewValue.Substring(0, nIndex)) * 60;
                        nTime += Common.Str2Int(strNewValue.Substring(nIndex + 1, strNewValue.Length - nIndex - 1));
                    }
                    else
                    {
                        nTime = Common.Str2Int(strNewValue);
                    }

                    if (nTime > 999)
                    {
                        nTime = 999;
                    }

                    if (nTime < 0)
                    {
                        nTime = 0;
                    }

                    if (e.ColumnIndex - 2 == 6)
                    {
                        Common.g_Game.SetTimeMatch(nTime.ToString());
                    }
                    else
                    if (e.ColumnIndex - 2 < 6 && e.ColumnIndex - 2 > 0)
                    {
                        int nSet = e.ColumnIndex - 2;
                        Common.g_Game.SetTimeSet(nTime.ToString(), nSet);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }

                    Common.dbGameObj2Db(Common.g_nMatchID, Common.g_Game);
                    dgvMatchScoreRefresh();
                    Common.NotifyMatchResult();

                    return;
                }
            }
        }
Ejemplo n.º 5
0
        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;
            }
            }
        }