Example #1
0
 private void bChoose_Click(object sender, EventArgs e)
 {
     if (listBox.SelectedIndex >= 0)
     {
         chosenTournament = turns[listBox.SelectedIndex];
         Close();
     }
 }
Example #2
0
        public void syncNames(Tournament tournament, bool interactive, string startRounds)
        {
            int count = 0, countNew = 0, SKOK_STOLOW = 100;
            data d;
            startRounds = startRounds.Trim();

            if (tournament.type == 1)
            {
                if (startRounds.Length > 0)
                {
                    d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE NSPair>0 AND `Round` in (" + startRounds + ")");
                }
                else
                {
                    string fromRound = sql.selectOne("SELECT min(`Round`) FROM RoundData WHERE NSPair>0");
                    d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE `Round`=" + fromRound);
                }
            }
            else
            {
                d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE `Table`<=100");
            }

            while (d.Read())
            {
                string section = d.GetInt32(0).ToString();
                string table = d.GetInt32(1).ToString();
                string ns = d.GetInt32(2).ToString();
                string ew = d.GetInt32(3).ToString();

                StringBuilder query = new StringBuilder();
                if (tournament.type == 1)
                {
                    query.Append("SELECT CONCAT(SUBSTR(imie,1,1),'.',nazw) name FROM zawodnicy WHERE idp=");
                    query.Append(ns);
                    query.Append(" OR idp=");
                    query.Append(ew);
                    query.Append(" ORDER BY idp ");
                    if (int.Parse(ew) < int.Parse(ns))
                        query.Append("DESC");
                }
                else
                {
                    query.Append("SELECT fullname NAME FROM teams WHERE id=");
                    query.Append(ns);
                    query.Append(" UNION ALL SELECT ' ' UNION ALL");
                    query.Append(" SELECT fullname NAME FROM teams WHERE id=");
                    query.Append(ew);
                    query.Append(" UNION ALL SELECT ' '; ");
                }
                mydata n = tournament.mysql.select(query.ToString());

                try
                {
                    n.Read();
                    countNew += updateName(section, table, "N", n.IsDBNull(0) ? "" : n.GetString(0));
                    if (tournament.type == 2)
                        countNew += updateName(section, (int.Parse(table) + SKOK_STOLOW).ToString(), "E", n.IsDBNull(0) ? "" : n.GetString(0));
                    n.Read();
                    countNew += updateName(section, table, "S", n.IsDBNull(0) ? "" : n.GetString(0));
                    if (tournament.type == 2)
                        countNew += updateName(section, (int.Parse(table) + SKOK_STOLOW).ToString(), "W", n.IsDBNull(0) ? "" : n.GetString(0));
                    n.Read();
                    countNew += updateName(section, table, "E", n.IsDBNull(0) ? "" : n.GetString(0));
                    if (tournament.type == 2)
                        countNew += updateName(section, (int.Parse(table) + SKOK_STOLOW).ToString(), "N", n.IsDBNull(0) ? "" : n.GetString(0));
                    n.Read();
                    countNew += updateName(section, table, "W", n.IsDBNull(0) ? "" : n.GetString(0));
                    if (tournament.type == 2)
                        countNew += updateName(section, (int.Parse(table) + SKOK_STOLOW).ToString(), "S", n.IsDBNull(0) ? "" : n.GetString(0));

                    if (tournament.type == 1) count += 4;
                    else count += 8;
                }
                catch (MySqlException ee)
                {
                    if (interactive)
                    {
                        if (ee.ErrorCode == -2147467259)
                        {
                            DialogResult dr = MessageBox.Show("W bws-ie jest para/team (" + ns + " albo " + ew
                                + "), który nie istnieje w wybranym turnieju. Może to nie ten turniej?",
                                "Zły turniej", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                            if (dr == DialogResult.Abort) return;
                        }
                        else
                        {
                            MessageBox.Show(ee.Message, "Błąd MySQL", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning);
                        }
                    }
                }
                try
                {
                    n.Close();
                }
                catch (Exception) { }
            }
            if (interactive)
            {
                MessageBox.Show("Synchronizacja zakończona!\nPrzejrzanych nazwisk: " + count + "\nZmienionych: " + countNew,
                    "Synchronizacja nazwisk", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (sql.selectOne("SELECT BM2ShowPlayerNames FROM Settings") != "1")
                    MessageBox.Show("Pamiętaj żeby włączyć opcję \"pokazuj nazwiska\"!", "Brakujące ustawienie",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
        private void bTournament_Click(object sender, EventArgs e)
        {
            try
            {
                ChooseTournament choose = new ChooseTournament();
                choose.ShowDialog();
                if (choose.chosenTournament != null)
                {
                    if ((tournament != null) && (tournament.mysql != null))
                        tournament.mysql.close();

                    tournament = choose.chosenTournament;
                    tournament.mysql.connect();

                    lTournament.Text = tournament.name;
                    lType.Text = tournament.type == 1 ? "Pary" : "Teamy";
                    lSections.Text = tournament.getSectionsNum();
                    lTables.Text = tournament.getTablesNum();
                    bSync.Enabled = true;
                    bAutoSync.Enabled = true;
                    eInterval.Enabled = true;
                    if (tournament.type == 2)
                    {
                        lSkok.Visible = true;
                        lNazwyTeamow.Visible = true;
                    }
                    else
                    {
                        lSkok.Visible = false;
                        lNazwyTeamow.Visible = false;
                    }
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Example #4
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            status2.Text = "Wersja " + this.version;
            status3.Text = "Data: " + this.date;

            string detectedVersion = detectBCSVersion();

            if (detectedVersion != null)
            {
                lDetectedVersion.Text = detectedVersion;
                BCSVersion            = new Version(detectedVersion);
            }
            else
            {
                lDetectedVersion.Text = "nie wykryto";
            }

            string filename;

            string[] args = Environment.GetCommandLineArgs();
            if (args.Length > 1)
            {
                filename = args[1];
            }
            else if (open.ShowDialog() == DialogResult.OK)
            {
                filename = open.FileName;
            }
            else
            {
                Close();
                return;
            }

            bws = new Bws(filename, this);
            bws.init();
            bws.convert();

            labelFilename.Text        = filename;
            labelFilename.ToolTipText = filename;
            this.shortenFilenameLabel();

            this.fillSectionSelector(bws.getSections());
            cbNamesSection.Items.Clear();
            foreach (object i in cbSettingsSection.Items)
            {
                cbNamesSection.Items.Add(i);
            }

            // cloning Setting List returned from Bws, because we're going to extend it for version tracking purposes
            this.bwsSettings = new List <Setting>(bws.initSettings());
            this.bwsSettings.Add(new Setting("BM2ShowPlayerNames", this.xShowPlayerNames, bws, new Version(2, 0, 0), new Version(1, 3, 1)));
            this.bwsSettings.Add(new Setting("BM2GameSummary", this.xShowRecap, bws, new Version(3, 6, 0), new Version(3, 0, 1)));
            bindSettingChanges();
            bws.loadSettings();

            this.checkRecordsForSectionGroups();
            this.scoringOptionsWarning();

            tournament = this.detectTeamyTournament();
            if (tournament != null)
            {
                updateTournamentInfo(tournament);
                this.rbIMPTeams.Checked = true;
            }
            else
            {
                syncToolStrip.Visible = false;
                namesPanel.Visible    = false;
            }

            this.WindowState = FormWindowState.Normal;
        }
Example #5
-1
 public static List<Tournament> getTournaments()
 {
     List<Tournament> list = new List<Tournament>();
     MySQL c = new MySQL("");
     data dbs = c.select("SHOW DATABASES;");
     while (dbs.Read())
     {
         Tournament t = new Tournament(dbs.GetString(0));
         if (t.type > 0)
             list.Add(t);
         t.mysql.close();
     }
     return list;
 }