예제 #1
0
 public static void Delete(Vasarlok model)
 {
     using (var con = new MySqlConnection(DatabaseConnection.DatabaseCon.ConnectionString))
     {
         con.Open();
         var sql = "delete from vasarlok " +
                   " where id = @id";
         using (var cmd = new MySqlCommand(sql, con))
         {
             cmd.Parameters.AddWithValue("@id", model.id);
             cmd.ExecuteNonQuery();
         }
     }
 }
예제 #2
0
        public static int Insert(Vasarlok model)
        {
            using (var con = new MySqlConnection(DatabaseConnection.DatabaseCon.ConnectionString))
            {
                con.Open();
                var sql = " INSERT INTO vasarlok( nev, cim, email, telefon) " +
                          "values ( @nev, @cim, @email, @telefon)";
                using (var cmd = new MySqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@nev", model.nev);
                    cmd.Parameters.AddWithValue("@cim", model.cim);
                    cmd.Parameters.AddWithValue("@email", model.email);
                    cmd.Parameters.AddWithValue("@telefon", model.telefon);


                    cmd.ExecuteNonQuery();
                    return((int)cmd.LastInsertedId);
                }
            }
        }
예제 #3
0
        public static void Update(Vasarlok model)
        {
            using (var con = new MySqlConnection(DatabaseConnection.DatabaseCon.ConnectionString))
            {
                con.Open();
                var sql = "update vasarlok set " +
                          " id = @id, " +
                          " nev = @nev, cim = @cim, email = @email, " +
                          " telefon = @telefon"
                          +
                          " where id = @id";
                using (var cmd = new MySqlCommand(sql, con))
                {
                    cmd.Parameters.AddWithValue("@id", model.id);
                    cmd.Parameters.AddWithValue("@nev", model.nev);
                    cmd.Parameters.AddWithValue("@cim", model.cim);
                    cmd.Parameters.AddWithValue("@email", model.email);
                    cmd.Parameters.AddWithValue("@telefon", model.telefon);


                    cmd.ExecuteNonQuery();
                }
            }
        }