Esempio n. 1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (Check())
     {
         Player player = new Player();
         player.Id = Model.Players.Last().Id + 1;
         player.Name = tbName.Text;
         player.Score = 0;
         Model.AddPlayer(player);
         Close();
     }
 }
Esempio n. 2
0
 public static void AddPlayer(Player player)
 {
     IDbCommand command = new SqlCeCommand();
     IDbConnection connection = new SqlCeConnection();
     string dbfile = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\MainDB.sdf";
     connection.ConnectionString = "Data Source=" + dbfile;
     command.Connection = connection;
     command.Connection.Open();
     command.Parameters.Clear();
     command.CommandText = String.Format(@"
         INSERT INTO [PlayersData]
         VALUES (
         {0},
         '{1}',
         {2}	)
     ", player.Id, player.Name,player.Score);
     command.ExecuteNonQuery();
     command.Connection.Close();
 }