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; } } }