//Given a GroupOfFour, adds each player to the list of constraints for each other player in that group private void setConstraintsWeak(GroupOfFour g) { //GroupOfFour g = eEvent.lstRounds[round].lstGroups[group]; //This is gross. Should do it iteritively if (g.playerA != null) { g.playerA.setConstraintWeak(g.playerA.ID); } if (g.playerA != null && g.playerB != null) { g.playerA.setConstraintWeak(g.playerB.ID); } if (g.playerB != null && g.playerA != null) { g.playerB.setConstraintWeak(g.playerA.ID); } if (g.playerB != null) { g.playerB.setConstraintWeak(g.playerB.ID); } if (g.playerC != null) { g.playerC.setConstraintWeak(g.playerC.ID); } if (g.playerC != null && g.playerD != null) { g.playerC.setConstraintWeak(g.playerD.ID); } if (g.playerD != null && g.playerC != null) { g.playerD.setConstraintWeak(g.playerC.ID); } if (g.playerD != null) { g.playerD.setConstraintWeak(g.playerD.ID); } }
//Populates the initial weak constraints of each player. I.e. themselves, their teammates, and any of the //A vs B and C vs D matchups so far private void populateInitialWeakConstraints() { //Teammates and themselves foreach (Team t in eEvent.lstTeams) { GroupOfFour g = new GroupOfFour(0); g.playerA = t.playerA; g.playerB = t.playerB; g.playerC = t.playerC; g.playerD = t.playerD; setConstraintsStrong(g); } //Previous matchups foreach (Round r in eEvent.lstRounds) { for (int i = 0; i < eEvent.lstTeams.Count; i++) //i.e. for each group { GroupOfFour g = r.lstGroups[i]; setConstraintsWeak(g); } } }
//Populates the form, given a round and group. Assumes isValidGroup(round, group) == true private void populateData(int round, int group, int nextround, int nextgroup) { //populate curr and next labelCurrRound.Text = (round + 1).ToString(); labelCurrGroup.Text = (group + 1).ToString(); textBoxNextRound.Text = (nextround + 1).ToString(); textBoxNextGroup.Text = (nextgroup + 1).ToString(); //populate Player names GroupOfFour g = theEvent.lstRounds[round].lstGroups[group]; labelAPlayer.Text = g.playerA.displayName.PadRight(21).Substring(0, 21); labelBPlayer.Text = g.playerB.displayName.PadRight(21).Substring(0, 21); labelCPlayer.Text = g.playerC.displayName.PadRight(21).Substring(0, 21); labelDPlayer.Text = g.playerD.displayName.PadRight(21).Substring(0, 21); //Get scores from db for current round/group and populate scores/subs if they exist. Else populate with zeroes. if (!doScoresExistFor(theEvent.nID, (round + 1), (group + 1))) { textBoxAPutts.Text = "0"; textBoxBPutts.Text = "0"; textBoxCPutts.Text = "0"; textBoxDPutts.Text = "0"; textBoxAScore.Text = "0"; textBoxBScore.Text = "0"; textBoxCScore.Text = "0"; textBoxDScore.Text = "0"; checkBoxASub.Checked = false; checkBoxBSub.Checked = false; checkBoxCSub.Checked = false; checkBoxDSub.Checked = false; } else { string strCmd = "SELECT * FROM Scores WHERE eventID = " + theEvent.nID; strCmd += " AND roundNumber = " + (round + 1) + " AND groupNumber = " + (group + 1); strCmd += " ORDER BY rowID ASC"; OleDbCommand dbCmd = new OleDbCommand(strCmd, Globals.g_dbConnection); OleDbDataAdapter dbAdapter = new OleDbDataAdapter(dbCmd); DataSet dataSet = new DataSet(); try { dbAdapter.Fill(dataSet, "Scores"); } catch (Exception ex) { MessageBox.Show("ERROR 1013: Could not write to database.\n" + ex.Message); return; } int nRow = 0; foreach (DataRow r in dataSet.Tables["Scores"].Rows) { if (nRow == 0) //0th element { textBoxAPutts.Text = r["puttScore"].ToString(); textBoxAScore.Text = r["pointScore"].ToString(); checkBoxASub.Checked = Convert.ToBoolean(r["isSubstitution"].ToString()); } else if (nRow == 1) { textBoxBScore.Text = r["pointScore"].ToString(); textBoxBPutts.Text = r["puttScore"].ToString(); checkBoxBSub.Checked = Convert.ToBoolean(r["isSubstitution"].ToString()); } else if (nRow == 2) { textBoxCPutts.Text = r["puttScore"].ToString(); textBoxCScore.Text = r["pointScore"].ToString(); checkBoxCSub.Checked = Convert.ToBoolean(r["isSubstitution"].ToString()); } else if (nRow == 3) { textBoxDPutts.Text = r["puttScore"].ToString(); textBoxDScore.Text = r["pointScore"].ToString(); checkBoxDSub.Checked = Convert.ToBoolean(r["isSubstitution"].ToString()); } nRow++; } } }
public void addGroup(GroupOfFour g) { lstGroups.Add(g); }