You are on page 1of 6

Joshua Sotomayor

Pregunta 3

class humano

public string nombre { get; set; }

class profesor : humano

public decimal sueldo { get; set; }

class estudiante : humano

public int calificacion { get; set; }

Pregunta 6

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using MySql.Data.MySqlClient;

namespace prueba

public partial class menuingresar : Form


{

MySqlConnection conn;

public menuingresar(MySqlConnection conn)

InitializeComponent();

this.conn = conn;

private void button1_Click(object sender, EventArgs e)

try {

conn.Open();

MySqlCommand cmd = new MySqlCommand("SP_REGISTRA_ITEM", conn);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("NOMBRE", MySqlDbType.VarChar).Value =
textBox1.Text.ToString();

cmd.Parameters.Add("APELLIDO", MySqlDbType.VarChar).Value =
textBox2.Text.ToString();

cmd.Parameters.Add("TELEFONO", MySqlDbType.VarChar).Value =
textBox3.Text.ToString();

cmd.Parameters.Add("DIRECCION", MySqlDbType.VarChar).Value =
textBox4.Text.ToString();

cmd.ExecuteNonQuery();

conn.Close();

catch (MySqlException ex)

MessageBox.Show(ex.ToString());

}
}

Pregunta 7

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using MySql.Data.MySqlClient;

namespace prueba

public partial class mostrador : Form

MySqlConnection conn;

public mostrador(MySqlConnection conn)

InitializeComponent();

this.conn = conn;

cargarItems();

private void cargarItems()

try

{
conn.Open();

MySqlCommand cmd = new MySqlCommand("SP_CONSULTA_ITEMS", conn);

cmd.CommandType = CommandType.StoredProcedure;

MySqlDataReader reader = cmd.ExecuteReader();

while (reader.Read())

int renglon = dataGridView1.Rows.Add();

dataGridView1.Rows[renglon].Cells["nombre"].Value = reader["nombre"];

dataGridView1.Rows[renglon].Cells["apellido"].Value = reader["apellido"];

dataGridView1.Rows[renglon].Cells["telefono"].Value = reader["telefono"];

dataGridView1.Rows[renglon].Cells["direccion"].Value = reader["direccion"];

conn.Close();

catch (MySqlException ex)

MessageBox.Show(ex.ToString());

}
CREATE DEFINER=`examenyo`@`localhost` PROCEDURE `SP_CONSULTA_ITEMS`()

BEGIN

SELECT nombre, apellido, telefono, direccion FROM persona;

END
CREATE DEFINER=`examenyo`@`localhost` PROCEDURE `SP_REGISTRA_ITEM`(

IN NOMBRE VARCHAR(50),

IN APELLIDO VARCHAR(50),

IN TELEFONO VARCHAR(10),

IN DIRECCION VARCHAR(150)

BEGIN

INSERT INTO persona(Nombre, Apellido, Telefono, Direccion)

VALUES(NOMBRE, APELLIDO, TELEFONO, DIRECCION);

END

You might also like