Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            BwsHelper file = new BwsHelper(label3.Text);

            List <OleDbConnection> dbs = new List <OleDbConnection>(2);

            dbs.Add(new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label1.Text)));
            dbs[0].Open();

            dbs.Add(new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label2.Text)));
            dbs[1].Open();

            OleDbConnection Myconnection3 = new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label3.Text));

            Myconnection3.Open();

            OleDbCommand ins = Myconnection3.CreateCommand();


            for (int i = 0; i < 2; i++)
            {
                OleDbCommand read = dbs[i].CreateCommand();
                read.CommandText = "SELECT * FROM PlayerNumbers";

                OleDbDataReader dr = read.ExecuteReader();

                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO PlayerNumbers ([Section], [Table], Direction, [Number]) VALUES ({0}, {1}, '{2}', {3})",
                                                    i + 1, dr[1], dr[2], "NULL");
                    ins.ExecuteNonQuery();
                }

                dr.Close();

                read.CommandText = "SELECT * FROM [Section]";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO [Section] ([ID], [Letter], [Tables], [MissingPair]) VALUES ({0}, '{1}', {2}, {3})",
                                                    i + 1, i == 0 ? "A" : "B", dr[2], dr[4]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();


                read.CommandText = "SELECT * FROM RoundData";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO RoundData ([Section], [Table], [Round], [NSPair], [EWPair], [LowBoard], [HighBoard]) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6})",
                                                    i + 1, dr[1], dr[2], dr[3], dr[4], dr[5], dr[6]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();


                read.CommandText = "SELECT * FROM [Tables]";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO [Tables] ([Section], [Table], [ComputerID], [Status], [LogOnOff], [CurrentRound], [CurrentBoard], [UpdateFromRound]) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})",
                                                    i + 1, dr[1], dr[2], dr[3], dr[4], dr[5], dr[6], dr[7]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();
            }

            dbs[0].Close();
            dbs[1].Close();

            Myconnection3.Close();
            label4.Text = "Done";

            fBMSettings form = new fBMSettings(false);

            if (form.ShowDialog() == DialogResult.OK)
            {
                for (int i = 1; i < 3; i++)
                {
                    file.SetSettings(form.options);
                    Myconnection3.Open();
                    ins.CommandText = String.Format("UPDATE [Settings] SET [Section]={0} WHERE [Section]=0", i);
                    ins.ExecuteNonQuery();
                    Myconnection3.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            BwsHelper file = new BwsHelper(label3.Text);

            List<OleDbConnection> dbs = new List<OleDbConnection>(2);

            dbs.Add(new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label1.Text)));
            dbs[0].Open();

            dbs.Add(new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label2.Text)));
            dbs[1].Open();

            OleDbConnection Myconnection3 = new OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source='{0}'", label3.Text));
            Myconnection3.Open();

            OleDbCommand ins = Myconnection3.CreateCommand();

            for (int i = 0; i < 2; i++)
            {

                OleDbCommand read = dbs[i].CreateCommand();
                read.CommandText = "SELECT * FROM PlayerNumbers";

                OleDbDataReader dr = read.ExecuteReader();

                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO PlayerNumbers ([Section], [Table], Direction, [Number]) VALUES ({0}, {1}, '{2}', {3})",
                        i + 1, dr[1], dr[2], "NULL");
                    ins.ExecuteNonQuery();
                }

                dr.Close();

                read.CommandText = "SELECT * FROM [Section]";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO [Section] ([ID], [Letter], [Tables], [MissingPair]) VALUES ({0}, '{1}', {2}, {3})",
                        i + 1, i == 0 ? "A" : "B", dr[2], dr[4]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();

                read.CommandText = "SELECT * FROM RoundData";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO RoundData ([Section], [Table], [Round], [NSPair], [EWPair], [LowBoard], [HighBoard]) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6})",
                        i + 1, dr[1], dr[2], dr[3], dr[4], dr[5], dr[6]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();

                read.CommandText = "SELECT * FROM [Tables]";

                dr = read.ExecuteReader();
                while (dr.Read())
                {
                    ins.CommandText = String.Format("INSERT INTO [Tables] ([Section], [Table], [ComputerID], [Status], [LogOnOff], [CurrentRound], [CurrentBoard], [UpdateFromRound]) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})",
                        i + 1, dr[1], dr[2], dr[3], dr[4], dr[5], dr[6], dr[7]);
                    ins.ExecuteNonQuery();
                }
                dr.Close();
            }

            dbs[0].Close();
            dbs[1].Close();

            Myconnection3.Close();
            label4.Text = "Done";

            fBMSettings form = new fBMSettings(false);
            if (form.ShowDialog() == DialogResult.OK)
            {
                for (int i = 1; i < 3; i++)
                {
                    file.SetSettings(form.options);
                    Myconnection3.Open();
                    ins.CommandText = String.Format("UPDATE [Settings] SET [Section]={0} WHERE [Section]=0", i);
                    ins.ExecuteNonQuery();
                    Myconnection3.Close();
                }
            }
        }