Exemplo n.º 1
0
        public void InserirTrainee(Trainee trainee)
        {
            SqlConnection cx = new SqlConnection(ConnectionString);

            try
            {
                string     cmd = "insert into Trainee (Nome) values (@Nome)";
                SqlCommand sc  = new SqlCommand(cmd, cx);

                sc.Parameters.AddWithValue("@Nome", trainee.Nome);

                cx.Open();
                sc.ExecuteNonQuery();
            }
            finally
            {
                cx.Close();
            }
        }
Exemplo n.º 2
0
        public void AtualizarTraineePorID(int id, Trainee c)
        {
            SqlConnection cx = new SqlConnection(ConnectionString);

            try
            {
                string     cmd = "update Trainee set Nome = @newName where Id = @id";
                SqlCommand sc  = new SqlCommand(cmd, cx);

                sc.Parameters.AddWithValue("@id", id);
                sc.Parameters.AddWithValue("@newName", c.Nome);

                cx.Open();

                sc.ExecuteNonQuery();
            }
            finally
            {
                cx.Close();
            }
        }
Exemplo n.º 3
0
        private static void InserirTraineeEF(TraineeRepositorioEF traineedb)
        {
            Trainee newTrainee = new Trainee("Pedro Lucas");

            traineedb.InserirTrainee(newTrainee);
        }