public void SetScore(int iNS, int iEW, bool bCompl) { DealScore old = score; bool oldCompleted = robCompleted; this.score.NS = iNS; this.score.EW = iEW; this.robCompleted = bCompl; if ((!old.Equals(this.score) || !oldCompleted.Equals(this.robCompleted)) && IsChangedHandlers()) { OnChanged(this, null); //OnChanged(this, new ChangedEventsArgs(old, this.score)); //OnChanged(this, new ChangedEventsArgs(oldCompleted, this.robCompleted)); } }
public void SetScore(int iNS, int iEW, bool bCompl) { DealScore old = score; bool oldCompleted = matchCompleted; this.score.NS = iNS; this.score.EW = iEW; this.matchCompleted = bCompl; if (matchCompleted) { score_VP = BridgeGameScoring.IMPtoVP(score, dealsInMatch); } else { score_VP = new DealScore(0, 0); } if ((!old.Equals(this.score) || !oldCompleted.Equals(this.matchCompleted)) && IsChangedHandlers()) { OnChanged(this, null); //OnChanged(this, new ChangedEventsArgs(old, this.score)); //OnChanged(this, new ChangedEventsArgs(oldCompleted, this.matchCompleted)); } }
void DB_SaveMatchScore(int matchNo_real, DealScore ds) { // Узнать id матча в БД int matchId = (PAGE__VIEW ? DB_Matches_Ids_ALL[matchNo_real] : DB_Matches_Ids[matchNo_real]); // Сохранить счет матча в БД System.Data.SqlServerCe.SqlCeCommand sqlQuery = DB.CreateQuery(); sqlQuery.CommandText = "UPDATE Matches SET SCORE_NS='" + ds.NS + "', SCORE_EW='" + ds.EW + "' WHERE id=" + matchId + ""; while (DB.ExecuteNonQuery(sqlQuery, true) == 0) { if (MessageBox.Show("Счет матча не был сохранен!", "db error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Retry) { DB.sqlConnection.Close(); DB.sqlConnection.Open(); } else { break; } } // Сохранить счет матча в [] DB_Matches_TotalScores[matchNo_real] = ds; // обновить селектор матчей TS_SHOW_UPDATE(matchNo_real); }
public static DealScore IMPtoVP(DealScore imp, int dealsInMatch) { if (!VP_Table.Keys.Contains(dealsInMatch)) { // MessageBox.Show("В таблице VP нет данных для " + dealsInMatch + " сдач в матче"); return new DealScore(0, 0); } int diff = imp.NS - imp.EW; int d = (diff < 0 ? -diff : diff); //разница по модулю int vp_pos = VP_Table[dealsInMatch].Count; for (int i = 0; i < VP_Table[dealsInMatch].Count; i++) { if (d <= (VP_Table[dealsInMatch])[i]) { vp_pos = i; break; } } int vp1 = (vp_total / 2) + vp_pos; int vp2 = (vp_total / 2) - vp_pos; if (vp1 > vp_max) vp1 = vp_max; if (diff >= 0) //NS выиграл return new DealScore(vp1, vp2); else //EW выиграл return new DealScore(vp2, vp1); }