private int GetRegIdFromBib(string strBib, out bool bIsLibero)
        {
            DataGridView view = (_tabMain.SelectedTab == _tabHeaderTeamB) ? this.dgvPlayerListB : this.dgvPlayerListA;

            for (int i = 0; i < view.RowCount; i++)
            {
                for (int j = 0; j < view.ColumnCount; j++)
                {
                    if (((view[j, i] != null) && (view[j, i].Value != null)) && (view[j, i].Value.ToString() == strBib))
                    {
                        object tag = view[j, i].Tag;
                        if (tag != null)
                        {
                            bIsLibero = Convert.ToBoolean(((DataRow)tag)["F_IsLibero"]);
                            return(Common.Str2Int(((DataRow)tag)["F_RegisterID"].ToString()));
                        }
                        bIsLibero = false;
                        return(0);
                    }
                }
            }

            bIsLibero = false;
            return(0);
        }
        private void btnDeleteLast_Click(object sender, EventArgs e)
        {
            bool   bIsTeamB = _tabMain.SelectedTab == _tabHeaderTeamB ? true : false;
            string str4     = bIsTeamB ? "CodeB" : "CodeA";

            for (int i = dgvActionList.RowCount - 1; i >= 0; i--)
            {
                if ((dgvActionList[str4, i] != null) && (dgvActionList[str4, i].Tag != null))
                {
                    if (MessageBox.Show("Delete?", "Delete last action.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                    {
                        return;
                    }

                    int nActionID = Common.Str2Int(dgvActionList[str4, i].Tag);
                    if (nActionID <= 0)
                    {
                        labStatEntryErrMsg.Text = "获取最后一条技术统计失败,删除最后技术统计失败!";
                    }
                    else if (!Common.dbActionListDelete(nActionID))
                    {
                        labStatEntryErrMsg.Text = "执行删除操作失败,删除最后一条技术统计失败!";
                    }
                    else
                    {
                        labStatEntryErrMsg.Text = "";

                        OnStatChanged(bIsTeamB);
                    }

                    return;
                }
            }
        }
        //根据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 UpdateMemberPosition(int iTeamPos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            int              iColumnIndex  = e.ColumnIndex;
            int              iRowIndex     = e.RowIndex;
            String           strColumnName = dgv.Columns[iColumnIndex].Name;
            DataGridViewCell CurCell       = dgv.Rows[iRowIndex].Cells[iColumnIndex];

            if (CurCell != null)
            {
                int iPositionID = 0;
                if (CurCell is DGVCustomComboBoxCell)
                {
                    DGVCustomComboBoxCell CurCell1 = CurCell as DGVCustomComboBoxCell;
                    iPositionID = Common.Str2Int(CurCell1.Tag);
                }
                else
                {
                    return;
                }
                int iMemberID = Common.Str2Int(dgv.Rows[iRowIndex].Cells["F_MemberID"].Value);
                UpdateMatchMembePosition(m_iMatchID, iMemberID, iTeamPos, iPositionID);
            }
        }
        private void UpdateMemberStartup(int iTeampos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= dgv.RowCount || e.RowIndex < 0)
            {
                return;
            }
            if (e.ColumnIndex != dgv.Columns["Startup"].Index)
            {
                return;
            }


            string strRegisterID = dgv.Rows[e.RowIndex].Cells["F_MemberID"].Value.ToString();

            if (Common.Str2Int(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) == 1)
            {
                UpdateMemberStartup(m_iMatchID, iTeampos, strRegisterID, false);
            }
            else
            {
                if ((iTeampos == 1 && m_iHomeStartup < 7) || (iTeampos == 2 && m_iVisitStartup < 7))
                {
                    UpdateMemberStartup(m_iMatchID, iTeampos, strRegisterID, true);
                }
            }

            if (iTeampos == 1)
            {
                ResetMemberGrid(m_iMatchID, m_iHomeRegisterID, 1, ref dgvMember_Home, ref m_iHomeStartup);
            }
            else if (iTeampos == 2)
            {
                ResetMemberGrid(m_iMatchID, m_iVisitRegisterID, 2, ref dgvMember_Visit, ref m_iVisitStartup);
            }
        }
        public void ResetAvailableGrid(int iMatchID, int iTeamID, int iTeamPos, ref DataGridView dgv)
        {
            if (Common.g_DataBaseCon.State == System.Data.ConnectionState.Closed)
            {
                Common.g_DataBaseCon.Open();
            }

            try
            {
                #region DML Command Setup for Get AvailbleTeamMember
                SqlCommand cmd = new SqlCommand("Proc_VB_EXT_GetTeamAvailable", Common.g_DataBaseCon);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter cmdParameter0 = new SqlParameter("@RegisterID", SqlDbType.Int);
                SqlParameter cmdParameter1 = new SqlParameter("@MatchID", SqlDbType.Int);
                SqlParameter cmdParameter2 = new SqlParameter("@LanguageCode", SqlDbType.NVarChar, 3);
                SqlParameter cmdParameter3 = new SqlParameter("@TeamPos", SqlDbType.Int);

                cmdParameter0.Value = iTeamID;
                cmdParameter1.Value = iMatchID;
                cmdParameter2.Value = Common.g_strLanguage;
                cmdParameter3.Value = iTeamPos;

                cmd.Parameters.Add(cmdParameter0);
                cmd.Parameters.Add(cmdParameter1);
                cmd.Parameters.Add(cmdParameter2);
                cmd.Parameters.Add(cmdParameter3);
                #endregion

                SqlDataReader dr = cmd.ExecuteReader();
                OVRDataBaseUtils.FillDataGridView(dgv, dr, null, null);

                if (dgv.RowCount >= 0)
                {
                    dgv.Columns["F_MemberID"].Visible   = false;
                    dgv.Columns["F_FunctionID"].Visible = false;


                    for (int i = 0; i < dgv.RowCount; i++)
                    {
                        int iDSQ = Common.Str2Int(dgv.Rows[i].Cells["DSQ"].Value);
                        if (iDSQ == 1)
                        {
                            dgv.Rows[i].ReadOnly = true;
                            dgv.Rows[i].DefaultCellStyle.BackColor = System.Drawing.Color.DarkGray;
                        }
                    }
                }
                dr.Close();
            }
            catch (System.Exception e)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show(e.Message);
            }
        }
        private void dgvStatItem_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvStatItem.CurrentCell == null || dgvStatItem.CurrentCell.Tag == null)
            {
                Debug.Assert(false);
                return;
            }

            String strStatCode = dgvStatItem.CurrentCell.Tag.ToString();
            String strStat     = dgvStatItem.CurrentCell.Value.ToString();

            //如果队员已选,就添加STAT
            if (labStatTeam.Tag == null || labStatPlayer.Tag == null || strStatCode.Length <= 0)
            {
                return;
            }

            int  nCurSet     = GetStatCurSet();
            bool bIsTeamA    = (bool)labStatTeam.Tag;
            int  nRegisterID = Common.Str2Int(labStatPlayer.Tag);

            Debug.Assert(nRegisterID > 0);

            //判断是插入还是添加,如果是插入,就处理一下nBeforeActionID
            int nBeforeActionID = 0;

            if (btnStatInsert.Tag != null && _curSelActionNum > 0)
            {
                if (bIsTeamA != _curSelIsTeamA)
                {
                    MessageBox.Show("只能插入被选中队伍的技术统计!");
                    return;
                }

                nBeforeActionID = _curSelActionNum;
            }

            if (strStat == "OPP_ERR" || strStat == "TEM_FLT")
            {
                Common.dbActionListAdd(Common.g_nMatchID, nCurSet, strStatCode, -1, nBeforeActionID, !bIsTeamA);
            }
            else
            {
                Common.dbActionListAdd(Common.g_nMatchID, nCurSet, strStatCode, nRegisterID, nBeforeActionID, !bIsTeamA);
            }

            labStatPlayer.Text      = "";
            labStatPlayer.Tag       = null;
            labStatTeam.Text        = "";
            labStatTeam.Tag         = null;
            dgvStatItem.CurrentCell = null;

            OnStatChanged(!bIsTeamA);
        }
Beispiel #8
0
        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 void RemoveMember(int iTeamPos, ref DataGridView dgv)
        {
            int iColIdx = dgv.Columns["F_MemberID"].Index;

            for (int i = 0; i < dgv.SelectedRows.Count; i++)
            {
                int iRowIdx = dgv.SelectedRows[i].Index;

                string strMemberID = dgv.Rows[iRowIdx].Cells[iColIdx].Value.ToString();
                int    iMemberID   = Common.Str2Int(strMemberID);

                RemoveMatchMember(m_iMatchID, iMemberID, iTeamPos);
            }
        }
Beispiel #10
0
        //从数据库获取比赛状态ID
        public static Int32 dbGetMatchStatusID()
        {
            String strSql           = "SELECT F_matchstatusID FROM TS_Match WHERE F_MatchID = " + Common.g_nMatchID;
            object objMatchStatusID = dbGetValue(strSql);

            if (objMatchStatusID == null)
            {
                return(0);
            }
            else
            {
                return(Common.Str2Int(objMatchStatusID));
            }
        }
Beispiel #11
0
        public bool timeoutSubtitutionRefresh()
        {
            DataTable dt = Common.dbSetInfo(Common.g_Game.GetCurSet());

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

            _labSubA.Text  = Common.Str2Int(dt.Rows[0]["F_SubtitutionA"].ToString()).ToString();
            _labSubB.Text  = Common.Str2Int(dt.Rows[0]["F_SubtitutionB"].ToString()).ToString();
            _labTimeA.Text = Common.Str2Int(dt.Rows[0]["F_TimeoutCountA"].ToString()).ToString();             //确保为数字
            _labTimeB.Text = Common.Str2Int(dt.Rows[0]["F_TimeoutCountB"].ToString()).ToString();

            return(true);
        }
        private void UpdateMemberOrder(int iTeamPos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            int iColumnIndex = e.ColumnIndex;
            int iRowIndex    = e.RowIndex;

            DataGridViewCell CurCell = dgv.Rows[iRowIndex].Cells[iColumnIndex];

            int iBatOrder = 0;

            if (CurCell.Value != null)
            {
                iBatOrder = Common.Str2Int(CurCell.Value);
            }
            int iMemberID = Common.Str2Int(dgv.Rows[iRowIndex].Cells["F_MemberID"].Value);

            UpdatePlayerOrder(m_iMatchID.ToString(), iMemberID, iBatOrder);
        }
        private void UpdateMemberShirtNumber(int iTeamPos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            int iColumnIndex = e.ColumnIndex;
            int iRowIndex    = e.RowIndex;

            DataGridViewCell CurCell = dgv.Rows[iRowIndex].Cells[iColumnIndex];

            string strShirtNumber = "";

            if (CurCell.Value != null)
            {
                strShirtNumber = CurCell.Value.ToString();
            }
            int iMemberID = Common.Str2Int(dgv.Rows[iRowIndex].Cells["F_MemberID"].Value);

            UpdateMatchMemberShirtNumber(m_iMatchID, iMemberID, iTeamPos, strShirtNumber);
        }
        private void btnStatEntryActionResult_Click(object sender, EventArgs e)
        {
            if (m_btnStatEntryPlayerSelected == null || m_btnStatEntryPlayerSelected.Tag == null)
            {
                Debug.Assert(false);
                return;
            }

            bool bIsTeamB    = _tabMain.SelectedTab == _tabHeaderTeamB ? true : false;
            int  nRegisterID = Common.Str2Int(m_btnStatEntryPlayerSelected.Tag);

            String strStatTypeCode = "";

            if (sender == btnStatEntryResult_SUC)                         //得分
            {
                strStatTypeCode = m_strStatEntryActionType + "_" + "SUC"; //目前应该只有ATK,BLO,SRV有
            }
            else
            if (sender == btnStatEntryResult_EXC)                         //好球没得分
            {
                strStatTypeCode = m_strStatEntryActionType + "_" + "EXC"; //目前应该只有DIG,SET,RCV有
            }
            else
            if (sender == btnStatEntryResult_CNT)               //一般
            {
                strStatTypeCode = m_strStatEntryActionType + "_" + "CNT";
            }
            else
            if (sender == btnStatEntryResult_BAD)                         //坏球没丢分
            {
                strStatTypeCode = m_strStatEntryActionType + "_" + "BAD"; //目前应该不存在
            }
            else
            if (sender == btnStatEntryResult_FLT)               //丢分
            {
                strStatTypeCode = m_strStatEntryActionType + "_" + "FLT";
            }

            if (!StatEntryAddAction(nRegisterID, strStatTypeCode))
            {
                labStatEntryErrMsg.Text = ("添加技术统计失败!");
            }

            OnStatChanged(bIsTeamB);
        }
        private void UpdateMemberSrvSpeed(int iTeamPos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            int iColumnIndex = e.ColumnIndex;
            int iRowIndex    = e.RowIndex;

            DataGridViewCell CurCell = dgv.Rows[iRowIndex].Cells[iColumnIndex];

            int?nValue = null;

            if (CurCell.Value != null)
            {
                nValue = Common.Str2Int(CurCell.Value.ToString());
            }

            int iMemberID = Common.Str2Int(dgv.Rows[iRowIndex].Cells["F_MemberID"].Value);

            UpdateMatchMemberSrvSpeed(m_iMatchID, iMemberID, iTeamPos, nValue);
        }
Beispiel #16
0
        private bool dgvActionListSetCurSelMarkColor(int selRow, bool selTeamA, int actionNum, bool selMark)
        {
            if (selRow >= dgvActionList.RowCount || actionNum <= 0)
            {
                return(false);
            }

            object objTag = dgvActionList[selTeamA ? "CodeA" : "CodeB", selRow].Tag;

            if (objTag == null || Common.Str2Int(objTag) != actionNum)
            {
                return(false);
            }

            dgvActionList[selTeamA ? "CodeA" : "CodeB", selRow].Style.BackColor = selMark ? m_clrDgvActionBackSelection : m_clrDgvActionBack;
            dgvActionList[selTeamA ? "BibA" : "BibB", selRow].Style.BackColor   = selMark ? m_clrDgvActionBackSelection : m_clrDgvActionBack;
            dgvActionList[selTeamA ? "NameA" : "NameB", selRow].Style.BackColor = selMark ? m_clrDgvActionBackSelection : m_clrDgvActionBack;

            return(true);
        }
        private void AddMember(int iTeamPos, ref DataGridView dgv)
        {
            int iColIdx          = dgv.Columns["F_MemberID"].Index;
            int iFuncColIdx      = dgv.Columns["F_FunctionID"].Index;
            int iShirtNumberIdex = dgv.Columns["ShirtNumber"].Index;

            for (int i = 0; i < dgv.SelectedRows.Count; i++)
            {
                int iRowIdx = dgv.SelectedRows[i].Index;

                if (dgv.Rows[iRowIdx].ReadOnly == true)
                {
                    continue;
                }
                string strMemberID    = dgv.Rows[iRowIdx].Cells[iColIdx].Value.ToString();
                string strFunctionID  = dgv.Rows[iRowIdx].Cells[iFuncColIdx].Value.ToString();
                string strShirtNumber = dgv.Rows[iRowIdx].Cells[iShirtNumberIdex].Value.ToString();

                int iMemberID    = Common.Str2Int(strMemberID);
                int iFunctionID  = 0;
                int iShirtNumber = 0;
                if (strFunctionID.Length == 0)
                {
                    iFunctionID = -1;
                }
                else
                {
                    iFunctionID = Common.Str2Int(strFunctionID);
                }

                if (strShirtNumber.Length == 0)
                {
                    iShirtNumber = -1;
                }
                else
                {
                    iShirtNumber = Common.Str2Int(strShirtNumber);
                }
                AddMatchMember(m_iMatchID, iMemberID, iTeamPos, iFunctionID, iShirtNumber);
            }
        }
Beispiel #18
0
        /// <summary>
        /// 点击队员完成后,把队员AB方放入labStatTeam.Tag, 把队员RegID放入labStatPlayer.Tag
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvPlayerList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (((DataGridView)sender).CurrentCell == null)
            {
                Debug.Assert(false);
                return;
            }

            DataRow cellCur = (DataRow)((DataGridView)sender).CurrentCell.Tag;

            if (cellCur == null)
            {
                return;
            }

            Int32  nRegID  = Common.Str2Int(cellCur["F_RegisterID"]);
            String strName = cellCur["F_NameS"].ToString();
            String strBib  = cellCur["F_ShirtNumber"].ToString();

            if (nRegID <= 0)
            {
                return;
            }

            bool bIsTeamA = (sender == dgvPlayerListA) ? true : false;

            labStatTeam.Tag    = bIsTeamA;
            labStatTeam.Text   = bIsTeamA ? Common.g_strNocA : Common.g_strNocB;
            labStatPlayer.Text = strBib + " " + strName;
            labStatPlayer.Tag  = nRegID;

            if (bIsTeamA)
            {
                dgvPlayerListB.CurrentCell = null;
            }
            else
            {
                dgvPlayerListA.CurrentCell = null;
            }
        }
        public frmTeamMemberEntry(int nMatchID, String strLangCode)
        {
            InitializeComponent();

            if (nMatchID <= 0 || strLangCode.Length == 0)
            {
                Debug.Assert(false);
                return;
            }

            DataTable tbl = Common.dbGetMatchInfo(Common.g_nMatchID, Common.g_strLanguage);

            if (tbl == null || tbl.Rows.Count < 1 || tbl.Columns.Count < 1)
            {
                return;
            }

            m_iMatchID         = Common.Str2Int(tbl.Rows[0]["F_MatchID"]);
            m_iHomeRegisterID  = Common.Str2Int(tbl.Rows[0]["F_TeamARegID"]);
            m_iVisitRegisterID = Common.Str2Int(tbl.Rows[0]["F_TeamBRegID"]);
            m_strHomeName      = tbl.Rows[0]["F_TeamAName"].ToString();
            m_strVisitName     = tbl.Rows[0]["F_TeamBName"].ToString();
        }
        private void UpdateMemberDSQ(int iTeamPos, ref DataGridView dgv, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }

            int iColumnIndex         = e.ColumnIndex;
            int iRowIndex            = e.RowIndex;
            DataGridViewCell CurCell = dgv.Rows[iRowIndex].Cells[iColumnIndex];

            if (CurCell != null)
            {
                int iIRMID = 0;
                if (CurCell is DGVCustomComboBoxCell)
                {
                    DGVCustomComboBoxCell CurCell1 = CurCell as DGVCustomComboBoxCell;
                    iIRMID = Common.Str2Int(CurCell1.Tag);
                }
                else
                {
                    return;
                }

                int iMemberID   = Common.Str2Int(dgv.Rows[iRowIndex].Cells["F_MemberID"].Value);
                int iRegisterID = 0;
                if (iTeamPos == 1)
                {
                    iRegisterID = m_iHomeRegisterID;
                }
                else if (iTeamPos == 2)
                {
                    iRegisterID = m_iVisitRegisterID;
                }
                UpdateMemberDSQ(iRegisterID, iMemberID, iIRMID);
            }
        }
        private void textBoxStat_KeyUp(object sender, KeyEventArgs e)
        {
            ////Esc: 清空输入框,退出
            ////Enter:进行判断
            if (e.KeyCode == Keys.Escape)
            {
                textBoxStat.Text = "";
                return;
            }
            else if (e.KeyCode != Keys.Return)
            {
                return;
            }

            ////开始处理
            string strN1    = (textBoxStat.Text.Length >= 1) ? textBoxStat.Text.Substring(0, 1) : "";
            string strN2    = (textBoxStat.Text.Length >= 2) ? textBoxStat.Text.Substring(1, 1) : "";
            string strN3    = (textBoxStat.Text.Length >= 3) ? textBoxStat.Text.Substring(2, 1) : "";
            bool   bIsTeamB = _tabMain.SelectedTab == _tabHeaderTeamB;

            strN1 = strN1.ToUpper();
            strN2 = strN2.ToUpper();
            strN3 = strN3.ToUpper();


            if (strN1 == "")
            {
                labStatEntryErrMsg.Text = "内容为空,请先输入内容";
                return;
            }

            if (strN1 == "?" || strN1 == "/")
            {
                string strHelp =
                    @"
Code	Desc.		Example
1-10:	队员号码 1-10
q-p:	队员号码 11-20
Esc:	清空输入
A:	整队失败
S:	对方失误
D:	交换操作队
Z:	删除最后一条技术统计
V:	队员上场	V3:3号上场
C:	换人	C32:换人,3号下,2号上
G:	ATK		1G+:1号进攻得分
H:	BLO		2H-:2号拦网失败
J:	SRV
K:	DIG
L:	SET
;:	RCV
+	SUC & EXC
-	FLT
?	显示帮助信息
";
                MessageBox.Show(strHelp, "Help", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                textBoxStat.Text        = "";
                labStatEntryErrMsg.Text = "";
                return;
            }

            if (strN1 == "D")             //换到另一方技术统计
            {
                _tabMain.SelectedTab = bIsTeamB ? _tabHeaderTeamA : _tabHeaderTeamB;

                textBoxStat.Text        = "";
                labStatEntryErrMsg.Text = "";
                //statInfoReferesh();
                Common.dbMatchModifyTimeSet();

                return;
            }
            else if (strN1 == "A")             // A:	TEM_FLT
            {
                if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), "TEM_FLT", -1, 0, bIsTeamB))
                {
                    textBoxStat.Text        = "";
                    labStatEntryErrMsg.Text = "";

                    OnStatChanged(bIsTeamB);
                }
                else
                {
                    labStatEntryErrMsg.Text = string.Format("添加{0}方TEM_FLT失败!", bIsTeamB ? "B" : "A");
                }

                return;
            }
            else if (strN1 == "S")             // S: OPP_ERR
            {
                if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), "OPP_ERR", -1, 0, bIsTeamB))
                {
                    textBoxStat.Text        = "";
                    labStatEntryErrMsg.Text = "";

                    OnStatChanged(bIsTeamB);
                }
                else
                {
                    labStatEntryErrMsg.Text = string.Format("添加{0}方OPP_ERR失败!", bIsTeamB ? "B" : "A");
                }

                return;
            }
            else if (strN1 == "Z")             // Z:	删除最后一条
            {
                string str4 = bIsTeamB ? "CodeB" : "CodeA";
                for (int i = dgvActionList.RowCount - 1; i >= 0; i--)
                {
                    if ((dgvActionList[str4, i] != null) && (dgvActionList[str4, i].Tag != null))
                    {
                        int nActionID = Common.Str2Int(dgvActionList[str4, i].Tag);
                        if (nActionID <= 0)
                        {
                            labStatEntryErrMsg.Text = "获取最后一条技术统计失败,删除最后技术统计失败!";
                        }
                        else if (!Common.dbActionListDelete(nActionID))
                        {
                            labStatEntryErrMsg.Text = "执行删除操作失败,删除最后一条技术统计失败!";
                        }
                        else
                        {
                            textBoxStat.Text        = "";
                            labStatEntryErrMsg.Text = "";

                            OnStatChanged(bIsTeamB);
                        }

                        return;
                    }
                }

                labStatEntryErrMsg.Text = "删除最后一条技术统计失败! 未找到可删除的!";
                return;
            }
            else if (strN1 == "V")              //队员上场
            {
                if (strN2 == "")
                {
                    labStatEntryErrMsg.Text = "未输入上场队员,无法上场!";
                    return;
                }

                string bibIdInN2 = GetRegBibFromKeyBoard(strN2);
                if (bibIdInN2 == "")
                {
                    labStatEntryErrMsg.Text = "上场队员BIB号输入有误,无法上场!";
                    return;
                }

                bool isLiberoInN2;
                int  nRegIdInN2 = GetRegIdFromBib(bibIdInN2, out isLiberoInN2);
                if (nRegIdInN2 <= 0)
                {
                    labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的上场队员,无法上场!", bIsTeamB ? "B" : "A", bibIdInN2);
                    return;
                }

                if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoInN2 ? "LIB_IN" : "PLY_IN", nRegIdInN2, 0, bIsTeamB))
                {
                    textBoxStat.Text        = "";
                    labStatEntryErrMsg.Text = "";

                    OnStatChanged(bIsTeamB);
                }
                else
                {
                    labStatEntryErrMsg.Text = "执行人员上场失败,无法上场!";
                }

                return;
            }
            else if (strN1 == "C")             //换人
            {
                if (strN2 == "")
                {
                    labStatEntryErrMsg.Text = "未输入下场队员,无法换人!";
                    return;
                }

                if (strN3 == "")
                {
                    labStatEntryErrMsg.Text = "未输入上场队员,无法换人!";
                    return;
                }

                string strBibOut = GetRegBibFromKeyBoard(strN2);
                if (strBibOut == "")
                {
                    labStatEntryErrMsg.Text = "下场队员BIB号输入有误,无法换人!";
                    return;
                }

                string regBibIn = GetRegBibFromKeyBoard(strN3);
                if (regBibIn == "")
                {
                    labStatEntryErrMsg.Text = "上场队员BIB号输入有误,无法换人!";
                    return;
                }

                bool isLiberoOut;
                int  nRegIdOut = GetRegIdFromBib(strBibOut, out isLiberoOut);
                if (nRegIdOut <= 0)
                {
                    labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的下场队员,无法换人!", bIsTeamB ? "B" : "A", strBibOut);
                    return;
                }

                bool isLiberoIn;
                int  nRegIdIn = GetRegIdFromBib(regBibIn, out isLiberoIn);
                if (nRegIdIn <= 0)
                {
                    labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的上场队员,无法换人!", bIsTeamB ? "B" : "A", regBibIn);
                    return;
                }

                if (isLiberoOut != isLiberoIn)
                {
                    labStatEntryErrMsg.Text = "上下场人员身份不一致,无法换人!";
                    return;
                }

                if (!Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoOut ? "LIB_OUT" : "PLY_OUT", nRegIdOut, 0, bIsTeamB))
                {
                    labStatEntryErrMsg.Text = "执行人员下场失败,无法换人!";
                    return;
                }

                if (Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), isLiberoIn ? "LIB_IN"  : "PLY_IN", nRegIdIn, 0, bIsTeamB))
                {
                    textBoxStat.Text        = "";
                    labStatEntryErrMsg.Text = "";

                    OnStatChanged(bIsTeamB);
                }
                else
                {
                    labStatEntryErrMsg.Text = "执行人员上场失败,无法换人!";
                }

                return;
            }

            //剩下的动作,第一位应为队员BIB号
            string strBibInN1 = GetRegBibFromKeyBoard(strN1);

            if (strBibInN1.Length == 0)
            {
                labStatEntryErrMsg.Text = "第一位代码不正确!";
                return;
            }

            bool isLiberoInN1 = false;
            int  nRegIdInN1   = GetRegIdFromBib(strBibInN1, out isLiberoInN1);

            if (nRegIdInN1 <= 0)
            {
                labStatEntryErrMsg.Text = string.Format("未在{0}方找到BIB号为{1}的队员,无法添加技术统计!", bIsTeamB ? "B" : "A", strBibInN1);
                return;
            }

            //判断第二位是否为Acton
            if (strN2 == "G" || strN2 == "H" || strN2 == "J" || strN2 == "K" || strN2 == "L" || strN2 == ":" || strN2 == ";")
            {
                string strErrMsg;
                string actionCodeInN2 = _AnalyzeKeyCode_StatAction(strN2, strN3, out strErrMsg);
                if (actionCodeInN2 == null || actionCodeInN2.Length < 1)
                {
                    labStatEntryErrMsg.Text = strErrMsg;
                    return;
                }

                if (!Common.dbActionListAdd(Common.g_nMatchID, GetStatCurSet(), actionCodeInN2, nRegIdInN1, 0, bIsTeamB))
                {
                    labStatEntryErrMsg.Text = string.Format("添加技术统计{0}方{1}号队员{2}动作失败!", bIsTeamB ? "B" : "A", strBibInN1, actionCodeInN2);
                }
                else
                {
                    textBoxStat.Text        = "";
                    labStatEntryErrMsg.Text = "";

                    OnStatChanged(bIsTeamB);
                }
            }
            else
            {
                labStatEntryErrMsg.Text = "代码不正确!";
            }

            return;
        }
        private void cmbUniform_Visit_SelectionChangeCommitted(object sender, EventArgs e)
        {
            m_iVisitUniformID = Common.Str2Int(cmbUniform_Visit.SelectedValue);

            UpdateMatchUniform(m_iMatchID, 2, m_iVisitUniformID);
        }
        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;
                }
            }
        }
        private void dgvStatEntryPlayerAll_Click(object sender, EventArgs e)
        {
            if (dgvStatEntryPlayerAll.SelectedRows.Count < 1 ||
                dgvStatEntryPlayerAll.SelectedRows[0].Tag == null ||
                dgvStatEntryPlayerAll.SelectedRows[0].Cells["Bib"] == null ||
                dgvStatEntryPlayerAll.SelectedRows[0].Cells["Bib"].Tag == null)
            {
                Debug.Assert(false);
                return;
            }

            int  nInRegID    = Common.Str2Int(dgvStatEntryPlayerAll.SelectedRows[0].Tag);
            bool nInIsLibero = Common.Str2Int(dgvStatEntryPlayerAll.SelectedRows[0].Cells["Bib"].Tag) == 1;

            if (btnStatEntryPlayerChange.Enabled == true)             //换人模式
            {
                if (m_btnStatEntryPlayerSelected == null || m_btnStatEntryPlayerSelected.Tag == null)
                {
                    Debug.Assert(false);
                    return;
                }

                int  nOutRegID    = Common.Str2Int(m_btnStatEntryPlayerSelected.Tag);
                bool bOutIsLibero = m_btnStatEntryPlayerSelected == btnStatEntryPlayer_Pos7;

                if (nInIsLibero != bOutIsLibero)
                {
                    labStatEntryErrMsg.Text = "上下场队员职务不同一,换人失败!";
                    statInfoReferesh();
                    return;
                }

                //如果在换人模式,就先下场
                if (!StatEntryAddAction(nOutRegID, bOutIsLibero ? "Lib_OUT" : "Ply_OUT"))
                {
                    labStatEntryErrMsg.Text = "在换人时,下场失败!";
                    statInfoReferesh();
                    return;
                }

                //换人的上场

                if (!StatEntryAddAction(nInRegID, nInIsLibero ? "Lib_IN" : "Ply_IN"))
                {
                    labStatEntryErrMsg.Text = "在换人时,上场失败!";
                    statInfoReferesh();
                    return;
                }
            }
            else             //上场模式
            {
                if (!StatEntryAddAction(nInRegID, nInIsLibero ? "Lib_IN" : "Ply_IN"))
                {
                    labStatEntryErrMsg.Text = "上场失败!";
                    statInfoReferesh();
                    return;
                }
            }

            OnStatChanged();
        }
Beispiel #25
0
        private bool dgvActionListRefresh(DataTable tblActionList)
        {
            //错误检测
            if (tblActionList == null)
            {
                Debug.Assert(false);
                return(false);
            }

            //如果记录集为空,特殊处理
            //直接清空列表,清空记录
            if (tblActionList.Rows.Count == 0)
            {
                _lastActionList = null;

                _curSelRow       = -1;
                _curSelActionNum = -1;
                _curSelIsTeamA   = true;

                dgvActionList.Rows.Clear();
                return(true);
            }

            //开始刷新
            dgvActionList.SuspendLayout();

            //填入数据
            int nCurRowInList = 0;
            int nCurRowInData = 0;

            while (nCurRowInData < tblActionList.Rows.Count)
            {
                if (_lastActionList != null && _lastActionList.Rows.Count >= nCurRowInData + 1 &&
                    Common.isEqualDataRow(_lastActionList.Rows[nCurRowInData], tblActionList.Rows[nCurRowInData], tblActionList.Columns.Count)
                    )
                {
                    //把新记录每一行与Last记录每一行进行对应,同时位移列表的坐标
                    //如果是Rally最后一行,占2行,否则占一行
                    if (tblActionList.Rows[nCurRowInData]["F_IsLastRowInRally"] != DBNull.Value)
                    {
                        nCurRowInList += 2;
                    }
                    else
                    {
                        nCurRowInList += 1;
                    }

                    nCurRowInData++;
                    continue;
                }
                else
                {
                    //跳出While
                    break;
                }
            }

            //发现一行不一致的,或者多出来,将列表中此行及以下全都删去,重新添加
            while (dgvActionList.Rows.Count > nCurRowInList)
            {
                dgvActionList.Rows.RemoveAt(dgvActionList.Rows.Count - 1);
            }

            //从对比后的最后一行,到数据源最后一行,加入到列表
            for (int cycRowData = nCurRowInData; cycRowData < tblActionList.Rows.Count; cycRowData++)
            {
                int cycRowList = dgvActionList.Rows.Add();

                dgvActionList.Rows[cycRowList].Tag    = cycRowData;
                dgvActionList.Rows[cycRowList].Height = 17;

                try
                {
                    dgvActionList["CodeA", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ActionCode_A"].ToString();
                    dgvActionList["CodeB", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ActionCode_B"].ToString();
                    dgvActionList["BibA", cycRowList].Value  = tblActionList.Rows[cycRowData]["F_Bib_A"].ToString();
                    dgvActionList["BibB", cycRowList].Value  = tblActionList.Rows[cycRowData]["F_Bib_B"].ToString();
                    dgvActionList["NameA", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ShortName_A"].ToString();
                    dgvActionList["NameB", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ShortName_B"].ToString();

                    //Code.Tag 放ActionNumberID
                    if (tblActionList.Rows[cycRowData]["F_ActionNumID_A"].ToString() != "")
                    {
                        dgvActionList["CodeA", cycRowList].Tag = Common.Str2Int(tblActionList.Rows[cycRowData]["F_ActionNumID_A"]);
                    }

                    if (tblActionList.Rows[cycRowData]["F_ActionNumID_B"].ToString() != "")
                    {
                        dgvActionList["CodeB", cycRowList].Tag = Common.Str2Int(tblActionList.Rows[cycRowData]["F_ActionNumID_B"]);
                    }

                    //根据F_ActionKindID的值,设置双方Action的背景色
                    int nActionKindID_A = Common.Str2Int(tblActionList.Rows[cycRowData]["F_ActionKindID_A"]);
                    int nActionKindID_B = Common.Str2Int(tblActionList.Rows[cycRowData]["F_ActionKindID_B"]);

                    if (nActionKindID_A >= 0 && nActionKindID_A <= 8)
                    {
                        dgvActionList["CodeA", cycRowList].Style.ForeColor = m_clrDgvActionFore[nActionKindID_A];
                        dgvActionList["BibA", cycRowList].Style.ForeColor  = m_clrDgvActionFore[nActionKindID_A];
                        dgvActionList["NameA", cycRowList].Style.ForeColor = m_clrDgvActionFore[nActionKindID_A];
                        dgvActionList["CodeA", cycRowList].Style.BackColor = m_clrDgvActionFore[ActClr_Null];

                        dgvActionList["Rally", cycRowList].Style.BackColor = m_clrDgvActionFore[ActClr_Split];
                    }

                    if (nActionKindID_B >= 0 && nActionKindID_B <= 8)
                    {
                        dgvActionList["CodeB", cycRowList].Style.ForeColor = m_clrDgvActionFore[nActionKindID_B];
                        dgvActionList["BibB", cycRowList].Style.ForeColor  = m_clrDgvActionFore[nActionKindID_B];
                        dgvActionList["NameB", cycRowList].Style.ForeColor = m_clrDgvActionFore[nActionKindID_B];

                        dgvActionList["Rally", cycRowList].Style.BackColor = m_clrDgvActionFore[ActClr_Split];
                    }

                    if (tblActionList.Rows[cycRowData]["F_ActionIsError_A"] != DBNull.Value)
                    {
                        dgvActionList["BibA", cycRowList].Style.Font  = m_gridFont_Err;
                        dgvActionList["BibA", cycRowList].Style.Font  = m_gridFont_Err;
                        dgvActionList["CodeA", cycRowList].Style.Font = m_gridFont_Err;
                        dgvActionList["BibA", cycRowList].Style.Font  = m_gridFont_Err;
                        dgvActionList["NameA", cycRowList].Style.Font = m_gridFont_Err;
                    }

                    if (tblActionList.Rows[cycRowData]["F_ActionIsError_B"] != DBNull.Value)
                    {
                        dgvActionList["BibB", cycRowList].Style.Font  = m_gridFont_Err;
                        dgvActionList["CodeB", cycRowList].Style.Font = m_gridFont_Err;
                        dgvActionList["BibB", cycRowList].Style.Font  = m_gridFont_Err;
                        dgvActionList["NameB", cycRowList].Style.Font = m_gridFont_Err;
                    }

                    //添加Rally信息, 包括下面的横线,是否为红色等
                    if (tblActionList.Rows[cycRowData]["F_IsLastRowInRally"] != DBNull.Value)
                    {
                        //双方计算比分不同,变红色
                        if (tblActionList.Rows[cycRowData]["F_ScoreAbEquel"].ToString() == "0")
                        {
                            dgvActionList["Rally", cycRowList].Style.BackColor     = m_clrDgvActionScoreInCorrect;
                            dgvActionList["ScoreAcdA", cycRowList].Style.BackColor = m_clrDgvActionScoreInCorrect;
                            dgvActionList["ScoreAcdB", cycRowList].Style.BackColor = m_clrDgvActionScoreInCorrect;

                            dgvActionList["ScoreAcdA", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ScoreAccord_A"].ToString();
                            dgvActionList["ScoreAcdB", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ScoreAccord_B"].ToString();
                        }
                        else
                        if (tblActionList.Rows[cycRowData]["F_ScoreAbEquel"].ToString() == "1")
                        {
                            if (tblActionList.Rows[cycRowData]["F_RallyEffect"].ToString() == "1")
                            {
                                dgvActionList["ScoreAcdA", cycRowList].Style.BackColor = m_clrDgvActionScoreWin;
                                dgvActionList["ScoreAcdB", cycRowList].Style.BackColor = m_clrDgvActionScoreLost;

                                dgvActionList["ScoreAcdA", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ScoreAccord_A"].ToString();
                            }
                            else
                            if (tblActionList.Rows[cycRowData]["F_RallyEffect"].ToString() == "2")
                            {
                                dgvActionList["ScoreAcdA", cycRowList].Style.BackColor = m_clrDgvActionScoreLost;
                                dgvActionList["ScoreAcdB", cycRowList].Style.BackColor = m_clrDgvActionScoreWin;
                                dgvActionList["ScoreAcdB", cycRowList].Value           = tblActionList.Rows[cycRowData]["F_ScoreAccord_B"].ToString();
                            }
                            else
                            {
                                dgvActionList["ScoreAcdA", cycRowList].Style.BackColor = m_clrDgvActionScoreInCorrect;
                                dgvActionList["ScoreAcdB", cycRowList].Style.BackColor = m_clrDgvActionScoreInCorrect;

                                dgvActionList["ScoreAcdA", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ScoreAccord_A"].ToString();
                                dgvActionList["ScoreAcdB", cycRowList].Value = tblActionList.Rows[cycRowData]["F_ScoreAccord_B"].ToString();
                            }
                        }
                        else
                        if (tblActionList.Rows[cycRowData]["F_RallyNum"].ToString() == "0")
                        {
                        }

                        dgvActionList["Rally", cycRowList].Value = tblActionList.Rows[cycRowData]["F_RallyNum"].ToString();

                        //添加分割线
                        cycRowList = dgvActionList.Rows.Add();
                        dgvActionList.Rows[cycRowList].Tag    = null;
                        dgvActionList.Rows[cycRowList].Height = 1;

                        for (int nCol = 0; nCol < dgvActionList.Columns.Count; nCol++)
                        {
                            dgvActionList[nCol, cycRowList].Style.BackColor = m_clrDgvActionFore[ActClr_Split];
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    dgvActionList.Rows.Clear();
                    dgvActionList.ResumeLayout();
                    return(false);
                }
            }

            //清空所有选中信息
            for (int nRow = 0; nRow < dgvActionList.RowCount; nRow++)
            {
                //don't mention split.
                if (dgvActionList.Rows[nRow].Height <= 3)
                {
                    continue;
                }

                if (dgvActionList["CodeA", nRow].Style.BackColor != m_clrDgvActionBack)
                {
                    dgvActionList["CodeA", nRow].Style.BackColor = m_clrDgvActionBack;
                    dgvActionList["BibA", nRow].Style.BackColor  = m_clrDgvActionBack;
                    dgvActionList["NameA", nRow].Style.BackColor = m_clrDgvActionBack;
                }

                if (dgvActionList["CodeB", nRow].Style.BackColor != m_clrDgvActionBack)
                {
                    dgvActionList["CodeB", nRow].Style.BackColor = m_clrDgvActionBack;
                    dgvActionList["BibB", nRow].Style.BackColor  = m_clrDgvActionBack;
                    dgvActionList["NameB", nRow].Style.BackColor = m_clrDgvActionBack;
                }
            }

            //恢复以前选择
            if (dgvActionList.RowCount > 0 && _curSelRow >= 0)             //以前有选择,那就尝试恢复之前选择,
            {
                bool bSelected = false;

                if (!bSelected && dgvActionListSetCurSelMarkColor(_curSelRow, _curSelIsTeamA, _curSelActionNum, true))
                {
                    //以前的行没变,直接恢复
                    bSelected = true;
                }

                if (!bSelected)
                {
                    //尝试寻找之前的动作
                    for (int nRow = 0; nRow < dgvActionList.Rows.Count; nRow++)
                    {
                        if (dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag != null &&
                            Common.Str2Int(dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag) == _curSelActionNum)
                        {
                            if (dgvActionListSetCurSelMarkColor(nRow, _curSelIsTeamA, _curSelActionNum, true))
                            {
                                _curSelRow = nRow;
                                bSelected  = true;
                            }

                            break;
                        }
                    }
                }

                if (!bSelected)
                {
                    //尝试选相同队的那行位置下有条目的行,因为那行内容估计是删除了
                    for (int nRow = _curSelRow; nRow >= 0 && nRow < dgvActionList.RowCount; nRow++)
                    {
                        if (dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag != null)
                        {
                            int newActionNum = Common.Str2Int(dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag);
                            if (dgvActionListSetCurSelMarkColor(nRow, _curSelIsTeamA, newActionNum, true))
                            {
                                _curSelRow       = nRow;
                                _curSelActionNum = newActionNum;
                                bSelected        = true;
                            }

                            break;
                        }
                    }
                }

                if (!bSelected)
                {
                    //尝试选相同队的那行位置上有条目的行,因为那行内容估计是删除了
                    for (int nRow = _curSelRow - 1; nRow >= 0 && nRow < dgvActionList.RowCount; nRow--)
                    {
                        if (dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag != null)
                        {
                            int newActionNum = Common.Str2Int(dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", nRow].Tag);
                            if (dgvActionListSetCurSelMarkColor(nRow, _curSelIsTeamA, newActionNum, true))
                            {
                                _curSelRow       = nRow;
                                _curSelActionNum = newActionNum;
                                bSelected        = true;
                            }

                            break;
                        }
                    }
                }

                //应该是没有内容了,放弃选择
                if (!bSelected)
                {
                    _curSelRow       = -1;
                    _curSelIsTeamA   = true;
                    _curSelActionNum = 0;
                }
            }


            //控制显示位置
            if (dgvActionList.RowCount > 0)
            {
                if (_tabMain.SelectedTab == _tabHeaderTeamA)                 //在TeamA标签下,显示出TeamA最后一行
                {
                    //寻找最后一行的有内容TeamA,并显示出来
                    for (int nRow = dgvActionList.Rows.Count - 1; nRow >= 0; nRow--)
                    {
                        if (dgvActionList["CodeA", nRow].Tag != null)
                        {
                            nRow -= 15;                                 //最后一行上面显示10行
                            nRow  = System.Math.Max(0, nRow);
                            dgvActionList.FirstDisplayedScrollingRowIndex = nRow;
                            break;
                        }
                    }
                }
                else if (_tabMain.SelectedTab == _tabHeaderTeamB)                 //在TeamB标签下,显示出TeamB最后一行
                {
                    //寻找最后一行的有内容TeamB,并显示出来
                    for (int nRow = dgvActionList.Rows.Count - 1; nRow >= 0; nRow--)
                    {
                        if (dgvActionList["CodeB", nRow].Tag != null)
                        {
                            nRow -= 15;                                 //最后一行上面显示10行
                            nRow  = System.Math.Max(0, nRow);
                            dgvActionList.FirstDisplayedScrollingRowIndex = nRow;
                            break;
                        }
                    }
                }
                else if (_curSelRow >= 0)                 //Double, Score页, 插入,显示选中行
                {
                    int nFirstDisplayRow = _curSelRow - 15;
                    nFirstDisplayRow = System.Math.Max(0, nFirstDisplayRow);
                    dgvActionList.FirstDisplayedScrollingRowIndex = nFirstDisplayRow;
                }
                else                 //Common页,非插入,显示最后
                {
                    dgvActionList.FirstDisplayedScrollingRowIndex = dgvActionList.RowCount - 1;
                }
            }

            dgvActionList.ResumeLayout();

            _lastActionList = tblActionList;

            return(true);
        }
        //From LiYan
        public void ResetMemberGrid(int iMatchID, int iTeamID, int iTeamPos, ref DataGridView dgv, ref int iStartupNumber)
        {
            if (Common.g_DataBaseCon.State == System.Data.ConnectionState.Closed)
            {
                Common.g_DataBaseCon.Open();
            }

            try
            {
                #region DML Command Setup for Get MatchMember
                SqlCommand cmd = new SqlCommand("Proc_VB_EXT_MatchMemberGetList", Common.g_DataBaseCon);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter cmdParameter1 = new SqlParameter("@MatchID", SqlDbType.Int);
                SqlParameter cmdParameter2 = new SqlParameter("@LanguageCode", SqlDbType.NVarChar, 3);
                SqlParameter cmdParameter3 = new SqlParameter("@TeamPos", SqlDbType.Int);

                cmdParameter1.Value = iMatchID;
                cmdParameter2.Value = Common.g_strLanguage;
                cmdParameter3.Value = iTeamPos;

                cmd.Parameters.Add(cmdParameter1);
                cmd.Parameters.Add(cmdParameter2);
                cmd.Parameters.Add(cmdParameter3);
                #endregion

                SqlDataReader dr = cmd.ExecuteReader();

                int iSelRowIndex = -1;
                if (dgv.Rows.Count > 0 && dgv.SelectedRows != null)
                {
                    //	iSelRowIndex = dgv.SelectedRows[0].Index;
                }

                List <int> lstCmbColumns = new List <int>();
                lstCmbColumns.Add(3);
                lstCmbColumns.Add(5);
                lstCmbColumns.Add(6);

                List <OVRCheckBoxColumn> lstChkColumns = new List <OVRCheckBoxColumn>();
                lstChkColumns.Add(new OVRCheckBoxColumn(0, 1, 0));
                OVRDataBaseUtils.FillDataGridView(dgv, dr, lstCmbColumns, lstChkColumns);

                dr.Close();

                if (dgv.RowCount > 0)
                {
                    dgv.Columns["F_MemberID"].Visible   = false;
                    dgv.Columns["F_StartupNum"].Visible = false;
                    dgv.Columns["Order"].ReadOnly       = false;
                    dgv.Columns["ShirtNumber"].ReadOnly = false;
                    dgv.Columns["DSQ"].ReadOnly         = false;

                    dgv.Columns["Startup"].Visible        = false;
                    dgv.Columns["MaxServeSpeed"].ReadOnly = false;

                    iStartupNumber = Common.Str2Int(dgv.Rows[0].Cells["F_StartupNum"].Value);

                    dgv.ClearSelection();
                    if (iSelRowIndex > 0 && iSelRowIndex < dgv.Rows.Count)
                    {
                        dgv.Rows[iSelRowIndex].Selected = true;
                    }
                }
            }
            catch (System.Exception e)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show(e.Message);
            }
        }
        private void cmbUniform_Home_SelectionChangeCommitted(object sender, EventArgs e)
        {
            m_iHomeUniformID = Common.Str2Int(cmbUniform_Home.SelectedValue);

            UpdateMatchUniform(m_iMatchID, 1, m_iHomeUniformID);
        }
        public void UpdateMemberStartup(int iMatchID, int iTeamPos, string strPlayerID, bool bStartup)
        {
            int iActive = bStartup ? 1 : 0;

            if (Common.g_DataBaseCon.State == System.Data.ConnectionState.Closed)
            {
                Common.g_DataBaseCon.Open();
            }

            try
            {
                #region DML Command Setup for Update BatOrder
                string strSQL;
                strSQL = string.Format(@"UPDATE TS_Match_Member SET F_Startup = {0} WHERE F_MatchID = {1} AND F_RegisterID = {2}", iActive, iMatchID, Common.Str2Int(strPlayerID));
                SqlCommand cmd = new SqlCommand(strSQL, Common.g_DataBaseCon);
                cmd.ExecuteNonQuery();

                #endregion
            }
            catch (System.Exception e)
            {
                DevComponents.DotNetBar.MessageBoxEx.Show(e.Message);
            }
        }
Beispiel #29
0
        //Should be in ActionList
        private void dgvActionList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //新的选中是否合法
            int nNewCol = e.ColumnIndex;
            int nNewRow = e.RowIndex;

            if (nNewCol < 0 || nNewCol >= dgvActionList.Columns.Count ||
                nNewRow < 0 || nNewRow >= dgvActionList.Rows.Count)
            {
                return;
            }

            dgvActionList.SuspendLayout();



            //去掉之前选择的颜色,如果有的话
            if (_curSelRow >= 0)
            {
                dgvActionListSetCurSelMarkColor(_curSelRow, _curSelIsTeamA, _curSelActionNum, false);

                //恢复成空值
                _curSelRow       = -1;
                _curSelActionNum = 0;
                _curSelIsTeamA   = true;
            }

            //开始设置新的选中
            if (nNewCol >= 0 && nNewCol <= 2)                    //点中的是TeamA内容
            {
                if (dgvActionList["CodeA", nNewRow].Tag != null) //点中的是Stat,不是空
                {
                    int newActionNum = Common.Str2Int(dgvActionList["CodeA", nNewRow].Tag);

                    if (dgvActionListSetCurSelMarkColor(nNewRow, true, newActionNum, true))
                    {
                        _curSelRow       = nNewRow;
                        _curSelIsTeamA   = true;
                        _curSelActionNum = newActionNum;
                    }
                }
            }

            if (nNewCol >= 6 && nNewCol <= 8)
            {
                if (dgvActionList["CodeB", nNewRow].Tag != null)                 //点中的是Stat,不是空
                {
                    int newActionNum = Common.Str2Int(dgvActionList["CodeB", nNewRow].Tag);

                    if (dgvActionListSetCurSelMarkColor(nNewRow, false, newActionNum, true))
                    {
                        _curSelRow       = nNewRow;
                        _curSelIsTeamA   = false;
                        _curSelActionNum = newActionNum;
                    }
                }
            }

            dgvActionList.ResumeLayout();

            int nRowFirstDisplayed = dgvActionList.FirstDisplayedScrollingRowIndex;
            int nRowDisplayed      = dgvActionList.GetCellCount(DataGridViewElementStates.Displayed) / dgvActionList.Columns.GetColumnCount(DataGridViewElementStates.Displayed);
            int nRowLastDisplayed  = nRowFirstDisplayed + nRowDisplayed;

            if (nNewRow < nRowFirstDisplayed)
            {
                dgvActionList.FirstDisplayedScrollingRowIndex = nNewRow;
            }

            if (nNewRow >= nRowLastDisplayed)
            {
                dgvActionList.FirstDisplayedScrollingRowIndex = nNewRow - nRowDisplayed + 2;
            }

            if (_curSelRow >= 0)
            {
                Debug.Assert(_curSelRow < dgvActionList.RowCount);
                Debug.Assert(Common.Str2Int(dgvActionList[_curSelIsTeamA ? "CodeA" : "CodeB", _curSelRow].Tag) == _curSelActionNum);
            }
        }
Beispiel #30
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;
            }
            }
        }