Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            entidades.Profesor objEntidadProfesor = new entidades.Profesor();

            //Pedir al usuario que agregue un profesor

            Console.Write("Ingrese Apellido: ");
            objEntidadProfesor.Apellido = Console.ReadLine();

            Console.Write("Ingrese Nombre: ");
            objEntidadProfesor.Nombre = Console.ReadLine();

            Console.Write("Ingrese Email: ");
            objEntidadProfesor.Email = Console.ReadLine();



            logica.Profesor objLogicaProfesor = new logica.Profesor();
            objLogicaProfesor.Agregar(objEntidadProfesor);

            Console.WriteLine("Profesor Agregado");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        //Metodo Agregar
        public void Agregar(entidades.Profesor profesor)
        {
            string        strConexion   = @"Server=CPX-C5C016FXUF9\TRAINING;database=tecno;Integrated Security=true";
            string        strSQL        = @"insert profesores(apellido,nombre,email) values (@apellido,@nombre,@email)";
            SqlConnection objConnection = new SqlConnection();

            objConnection.ConnectionString = strConexion;

            SqlCommand objCommand = new SqlCommand();

            objCommand.CommandText = strSQL;
            objCommand.Connection  = objConnection;

            //Parametros

            objCommand.Parameters.AddWithValue("@apellido", profesor.Apellido);
            objCommand.Parameters.AddWithValue("@nombre", profesor.Nombre);
            objCommand.Parameters.AddWithValue("@email", profesor.Email);

            //Abro la conexion
            objConnection.Open();
            objCommand.ExecuteNonQuery();
            objConnection.Close();
        }
Ejemplo n.º 3
0
 public void Agregar(entidades.Profesor pProfesor)
 {
     datos.Profesor objProfesor = new datos.Profesor();
     objProfesor.Agregar(pProfesor);
 }