Esempio n. 1
0
 private void bLoadHands_Click(object sender, EventArgs e)
 {
     if (openPBN.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
     {
         try
         {
             PBN           pbn        = new PBN(openPBN.FileName, bws.lowBoard(), bws.highBoard());
             StringBuilder confirmMsg = new StringBuilder();
             confirmMsg.Append("Wczytane zostaną rozkłady z następującego pliku:\n" + "");
             if (pbn.title != null && !pbn.title.Equals(""))
             {
                 confirmMsg.Append("\nNagłówek pliku: " + pbn.title);
             }
             confirmMsg.Append("\nPierwszy rozkład: ");
             int lowBoard = bws.lowBoard();
             while (lowBoard < pbn.handRecords.Length && pbn.handRecords[lowBoard] == null)
             {
                 lowBoard++;
             }
             for (int i = 0; i < pbn.handRecords[lowBoard].north.Length; i++)
             {
                 if ("".Equals(pbn.handRecords[lowBoard].north[i]))
                 {
                     confirmMsg.Append("renons, ");
                 }
                 else
                 {
                     confirmMsg.Append(pbn.handRecords[lowBoard].north[i]);
                     break;
                 }
             }
             if (MessageBox.Show(confirmMsg.ToString(), "Potwierdź rozkłady", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 int count = bws.loadHandRecords(pbn);
                 MessageBox.Show("Wczytanych rozkładów: " + count, "Rozkłady wczytane!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Błąd wczytywania rozkładów", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 2
0
 public void loadHandRecords(PBN pbn)
 {
     sql.query("DELETE FROM HandRecord");
     sql.query("DELETE FROM HandEvaluation");
     for (int i = 0; i < pbn.handRecords.Length; i++)
         if (pbn.handRecords[i] != null)
             for (int section = 1; section <= highSection(); section++)
             {
                 HandRecord b = pbn.handRecords[i];
                 StringBuilder str = new StringBuilder(50);
                 str.Append("INSERT INTO HandRecord VALUES (");
                 str.Append(section); str.Append(",");
                 str.Append(i); str.Append(",'");
                 str.Append(b.north[0]); str.Append("','");
                 str.Append(b.north[1]); str.Append("','");
                 str.Append(b.north[2]); str.Append("','");
                 str.Append(b.north[3]); str.Append("','");
                 str.Append(b.east[0]); str.Append("','");
                 str.Append(b.east[1]); str.Append("','");
                 str.Append(b.east[2]); str.Append("','");
                 str.Append(b.east[3]); str.Append("','");
                 str.Append(b.south[0]); str.Append("','");
                 str.Append(b.south[1]); str.Append("','");
                 str.Append(b.south[2]); str.Append("','");
                 str.Append(b.south[3]); str.Append("','");
                 str.Append(b.west[0]); str.Append("','");
                 str.Append(b.west[1]); str.Append("','");
                 str.Append(b.west[2]); str.Append("','");
                 str.Append(b.west[3]); str.Append("')");
                 sql.query(str.ToString());
                 int[,] ddTable = pbn.ddTables[i].GetDDTable();
                 if (ddTable != null)
                 {
                     StringBuilder ddStr = new StringBuilder();
                     ddStr.Append("INSERT INTO HandEvaluation VALUES(");
                     ddStr.Append(section); ddStr.Append(",");
                     ddStr.Append(i); ddStr.Append(",");
                     for (int player = 0; player < 4; player++)
                     {
                         for (int denom = 0; denom < 5; denom++)
                         {
                             ddStr.Append(ddTable[player, denom]);
                             ddStr.Append(",");
                         }
                     }
                     for (int j = 0; j < 4; j++)
                     {
                         ddStr.Append(b.hpcs[j]);
                         if (j < 3)
                         {
                             ddStr.Append(",");
                         }
                     }
                     ddStr.Append(")");
                     sql.query(ddStr.ToString());
                 }
             }
 }
Esempio n. 3
0
 private void bLoadHands_Click(object sender, EventArgs e)
 {
     if (openPBN.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
     {
         try
         {
             PBN pbn = new PBN(openPBN.FileName, bws.lowBoard(), bws.highBoard());
             bws.loadHandRecords(pbn);
             MessageBox.Show("Wczytanych rozkładów: " + pbn.count, "Rozkłady wczytane!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Błąd wczytywania rozkładów", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }