Reporte de Bases de Datos

35
Instituto Tecnológico Superior de Teposcolula Ingeniería en Sistemas Computacionales PRESENTA: Elioenaí García García MATRICULA: 13ISC215 ASESOR: Ing. Eloy Sánchez Salmorán MATERIA: Tópicos avanzados de programación MODULO: Unidad 3: componentes y librerías ACTIVIDAD: Reporte de Prácticas FECHA: 12 de Mayo del 2015

description

ddfdf

Transcript of Reporte de Bases de Datos

Instituto Tecnolgico Superior de Teposcolula

Ingeniera en Sistemas Computacionales

PRESENTA:

Elioena Garca Garca

MATRICULA:

13ISC215

ASESOR:

Ing. Eloy Snchez Salmorn

MATERIA:

Tpicos avanzados de programacin

MODULO:

Unidad 3: componentes y libreras

ACTIVIDAD:

Reporte de Prcticas

FECHA:

12 de Mayo del 2015

TTULO:

Manejo de componentes y libreras

ContenidoINTRODUCCIN33.1 PROGRAMA QUE COMPRUEBA LA CONEXIN CON MYSQL.43.2 PRINTSCREEN DE EJECUCIN DEL PROGRAMA.73.3 CRUP CON MYSQL.83.4 PRINTSCREEN DE EJECUCIN DEL PROGRAMA.26CONCLUSIN.28BIBLIOGRAFIA29

INTRODUCCIN

Un componente en c# es el elemento bsico de una interfaz grfica. Los componentes permiten al usuario interactuar con la aplicacin y proporcionar informacin desde el programa al usuario sobre el estado de la aplicacin. Ejemplos de componentes son: los botones, las barras de desplazamiento, las etiquetas, las listas, las cajas de seleccin o los campos de texto, entre otros.

Cabe mencionar que los componentes nunca se encuentran de forma aislada, sino agrupados dentro de contenedores. Los contenedores contienen y organizan la situacin de los componentes; adems, son en s mismos componentes y como tales pueden ser situados dentro de otros contenedores.

Los paquetes en c# son una manera de organizar nuestras clases, ya sea por finalidad, por su relacin con la herencia que tienen, etc.

De manera introductoria es as como los componentes y libreras se comportan; cuando se generan y como ocurren mediante practicas sencillas para su compresin.

As mismo necesitamos conocer trminos bsicos de programacin para entender conceptos abstractos en la programacin.

El propsito indispensable de estas prcticas es conocer los tpicos de programacin que existen para programar ciertas aplicaciones con conexin de bases de datos.

3.1 PROGRAMA QUE COMPRUEBA LA CONEXIN CON MYSQL.

OBJETIVO: Conocer las clases correspondientes para poder realizar una conexin a mysql.

Clase 1:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

using MySql.Data.Types;

using System.Windows.Forms;

namespace Unidad3

{

class MYSQL

{

public MySqlConnection conexion;

public bool exito;

public MYSQL() {

conexion = Conexion.connection();

try

{

conexion.Open();

exito = true;

}

catch {

exito = false;

}

}

}

}

Clase 2:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

using MySql.Data.Types;

using System.Windows.Forms;

namespace Unidad3

{

class MYSQL

{

public MySqlConnection conexion;

public bool exito;

public MYSQL() {

conexion = Conexion.connection();

try

{

conexion.Open();

exito = true;

}

catch {

exito = false;

}

}

}

}

Clase 3:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

using MySql.Data.Types;

namespace Unidad3

{

//creamos una clase abstracta

public abstract class Conexion

{

// metodo connection que devuelve un valor de tipo mysqlConection

public static MySqlConnection connection() {

MySqlConnection con = new MySqlConnection("SERVER =localhost; DATABASE=pruebas;UID=root");

return con;

}

}

}

Clase 4:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace Unidad3

{

static class Program

{

///

/// Punto de entrada principal para la aplicacin.

///

// [STAThread]

public static MYSQL con = new MYSQL();

static void Main()

{

if (con.exito == true)

{

MessageBox.Show("Conexion existosa", "MYSQL", MessageBoxButtons.OK, MessageBoxIcon.Information);

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

else {

MessageBox.Show("Error al conectar la base de datos","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}

}

}

3.2 PRINTSCREEN DE EJECUCIN DEL PROGRAMA.

3.3 CRUP CON MYSQL.

OBJETIVO: Aprender a conectar c# con mysql y realizar las consultas bsicas de bases de datos.

Clase 1:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

using MySql.Data.Types;

namespace CONBASESDED

{

public abstract class BdComun

{

public static MySqlConnection ObtenerConexion()

{

string cadena = "SERVER=localhost;DATABASE=pruebas;UID=root;";

MySqlConnection conexion = new MySqlConnection(cadena);

try

{

conexion.Open();

// return conexion;

}

catch {

throw;

}

return conexion;

}

}

}

Clase 2:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace CONBASESDED

{

public class Cliente

{

public int Codigo { get; set; }

public string Nombre { get; set; }

public string Apellidos { get; set; }

public string FechaNac { get; set; }

public string Direccion { get; set; }

public Cliente (){}

public Cliente(int pCodigo,string pNombre,string pApellidos,string pFechaNac,string pDireccion)

{

this.Codigo = pCodigo;

this.Nombre = pNombre;

this.Apellidos = pApellidos;

this.FechaNac = pFechaNac;

this.Direccion = pDireccion;

}

}

}

Clase 3:

sing System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

namespace CONBASESDED

{

class ClienteDAL

{

public static int Agregar(Cliente pUsuario) {

int retorno= 0;

//string sql="";

MySqlCommand comando = new MySqlCommand(

string.Format(

"INSERT INTO cliente (nombre, apellido, fechaNac,direccion)VALUES ('{0}','{1}','{2}','{3}')",

pUsuario.Nombre,pUsuario.Apellidos,pUsuario.FechaNac,pUsuario.Direccion),BdComun.ObtenerConexion());

retorno=comando.ExecuteNonQuery();

return retorno;

}

public static List Buscar(string pNombre, string pApellidos) {

List lista = new List();

MySqlCommand comando=new MySqlCommand(

string.Format("SELECT codigo,nombre,apellido,fechaNac,direccion FROM cliente WHERE nombre='{0}' OR apellido='{1}'",

pNombre,pApellidos),BdComun.ObtenerConexion());

MySqlDataReader reader = comando.ExecuteReader();

while (reader.Read()) {

Cliente pUsuario = new Cliente();

pUsuario.Codigo = reader.GetInt32(0);

pUsuario.Nombre = reader.GetString(1);

pUsuario.Apellidos = reader.GetString(2);

pUsuario.FechaNac = reader.GetString(3);

pUsuario.Direccion = reader.GetString(4);

lista.Add(pUsuario);

}

return lista;

}

public static Cliente ObtenerCliente(int pCodigo) {

Cliente pUsuario = new Cliente();

MySqlConnection conexion = BdComun.ObtenerConexion();

MySqlCommand comando = new MySqlCommand(String.Format("SELECT codigo,nombre,apellido,fechaNac,direccion FROM cliente WHERE codigo={0}", pCodigo), conexion);

MySqlDataReader reader = comando.ExecuteReader();

while (reader.Read())

{

pUsuario.Codigo = reader.GetInt32(0);

pUsuario.Nombre = reader.GetString(1);

pUsuario.Apellidos = reader.GetString(2);

pUsuario.FechaNac = reader.GetString(3);

pUsuario.Direccion = reader.GetString(4);

}

conexion.Close();

return pUsuario;

}

public static int Actualizar(Cliente pUsuario) {

int retorno = 0;

MySqlConnection conexion = BdComun.ObtenerConexion();

MySqlCommand comando = new MySqlCommand(

string.Format("UPDATE cliente SET nombre='{0}',apellido='{1}',fechaNac='{2}',direccion='{3}'WHERE codigo='{4}'",

pUsuario.Nombre,pUsuario.Apellidos,pUsuario.FechaNac,

pUsuario.Direccion,pUsuario.Codigo),conexion);

retorno=comando.ExecuteNonQuery();

conexion.Close();

return retorno;

}

public static int Eliminar (double pCoodigo){

int retorno=0;

MySqlConnection conexion=BdComun.ObtenerConexion();

MySqlCommand comando=new MySqlCommand(string.Format("DELETE FROM cliente WHERE codigo ={0}",pCoodigo),conexion);

retorno =comando.ExecuteNonQuery();

conexion.Close();

return retorno;

}

}

}

Clase 4:

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;

namespace CONBASESDED

{

public partial class frmenai : Form

{

public Cliente ClienteSeleccionado { get; set; }

public frmenai()

{

InitializeComponent();

}

private void btnBuscar_Click(object sender, EventArgs e)

{

dataGridView1.DataSource = ClienteDAL.Buscar(txtNomE.Text, txtApelliE.Text);

}

private void btnAceptar_Click(object sender, EventArgs e)

{

if (dataGridView1.SelectedRows.Count == 1)

{

int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);

ClienteSeleccionado = ClienteDAL.ObtenerCliente(id);

this.Close();

}

else {

MessageBox.Show("Debe seleccionar una fila");

}

}

}

}

Clase 5:

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;

using MySql.Data.Types;

namespace CONBASESDED

{

public partial class frmPrincipal : Form

{

public Cliente clienteActual { get; set; }

public frmPrincipal()

{

InitializeComponent();

}

private void btnGuardar_Click(object sender, EventArgs e)

{

if (string.IsNullOrWhiteSpace(txtNombre.Text) ||

string.IsNullOrWhiteSpace(txtApellidos.Text) ||

string.IsNullOrWhiteSpace(txtDireccion.Text))

MessageBox.Show("Hay uno om mas campos vacios", "campos vacios",

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

else

{

Cliente pCliente = new Cliente();

pCliente.Nombre = txtNombre.Text.Trim();

pCliente.Apellidos = txtApellidos.Text.Trim();

pCliente.FechaNac = dateTimePicker1.Value.Year + "/" +

dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day;

pCliente.Direccion = txtDireccion.Text.Trim();

int resultado = ClienteDAL.Agregar(pCliente);

if (resultado > 0)

{

MessageBox.Show("Cliente Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo guardar el cliente", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

}

void limpiar()

{

txtNombre.Clear();

txtApellidos.Clear();

txtDireccion.Clear();

dateTimePicker1.ResetText();

}

void Habilitar() {

txtNombre.Enabled = true;

txtApellidos.Enabled = true;

txtDireccion.Enabled = true;

dateTimePicker1.Enabled = true;

btnGuardar.Enabled = true;

btnCancelar.Enabled = true;

}

void deshabilitar() {

txtNombre.Enabled = false;

txtApellidos.Enabled = false;

txtDireccion.Enabled = false;

dateTimePicker1.Enabled = false;

btnGuardar.Enabled = false;

btnEliminar.Enabled = false;

btnActualizar.Enabled = false;

btnCancelar.Enabled = false;

btnNuevo.Enabled = true;

}

private void btnNuevo_Click(object sender, EventArgs e)

{

limpiar();

Habilitar();

txtNombre.Focus();

}

private void btnActualizar_Click(object sender, EventArgs e)

{

if (string.IsNullOrWhiteSpace(txtNombre.Text) || string.IsNullOrWhiteSpace(txtApellidos.Text) ||

string.IsNullOrWhiteSpace(txtDireccion.Text))

MessageBox.Show("Hay Uno o mas Campos Vacios", "Campos Vacios", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

else

{

Cliente pCliente = new Cliente();

pCliente.Nombre = txtNombre.Text.Trim();

pCliente.Apellidos = txtApellidos.Text.Trim();

pCliente.FechaNac = dateTimePicker1.Value.Year + "/" + dateTimePicker1.Value.Month + "/" + dateTimePicker1.Value.Day;

pCliente.Direccion = txtDireccion.Text.Trim();

pCliente.Codigo = clienteActual.Codigo;

if (ClienteDAL.Actualizar(pCliente) > 0)

{

MessageBox.Show("Los datos del cliente se actualizaron", "Datos Actualizados", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo actualizar", "Error al Actualizar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

}

private void btnEliminar_Click(object sender, EventArgs e)

{

if (MessageBox.Show("Esta Seguro que desea eliminar el Cliente Actual", "Estas Seguro??", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

{

if (ClienteDAL.Eliminar(clienteActual.Codigo) > 0)

{

MessageBox.Show("Cliente Eliminado Correctamente!", "Cliente Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo eliminar el Cliente", "Cliente No Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

else

MessageBox.Show("Se cancelo la eliminacion", "Eliminacion Cancelada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

private void btnBuscar_Click(object sender, EventArgs e)

{

frmenai buscar = new frmenai();

buscar.ShowDialog();

if (buscar.ClienteSeleccionado != null)

{

clienteActual = buscar.ClienteSeleccionado;

txtNombre.Text = buscar.ClienteSeleccionado.Nombre;

txtApellidos.Text = buscar.ClienteSeleccionado.Apellidos;

txtDireccion.Text = buscar.ClienteSeleccionado.Direccion;

dateTimePicker1.Text = buscar.ClienteSeleccionado.FechaNac;

btnActualizar.Enabled = true;

btnEliminar.Enabled = true;

Habilitar();

btnGuardar.Enabled = false;

}

}

private void btnCancelar_Click(object sender, EventArgs e)

{

limpiar();

deshabilitar();

}

private void frmPrincipal_Load(object sender, EventArgs e)

{

deshabilitar();

}

}

}

Clase 6:

sing System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace CONBASESDED

{

class ClassProducto

{

public double CodigoBarra { get; set; }

public string NombreProducto { get; set; }

public string FechaCad { get; set; }

public ClassProducto() { }

public ClassProducto(double pCodigob,string pNombreP,string pFechaCad) {

this.CodigoBarra = pCodigob;

this.NombreProducto = pNombreP;

this.FechaCad = pFechaCad;

}

}

}

Clase 7:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using MySql.Data.MySqlClient;

using MySql.Data.Types;

namespace CONBASESDED

{

class ProductoDAL

{

public static double Agregar(ClassProducto Productoss)

{

double retorno = 0.00;

MySqlCommand comando = new MySqlCommand(

String.Format(

"Insert into productos (codigo,producto,fechaCad) values('{0}','{1}','{2}')",

Productoss.CodigoBarra,Productoss.NombreProducto,Productoss.FechaCad),BdComun.ObtenerConexion());

retorno =comando.ExecuteNonQuery();

return retorno;

}

public static List Buscar(double CodigoBarra)

{

List lista = new List();

MySqlCommand comando = new MySqlCommand(string.Format(

"SELECT codigo,producto,fechaCad FROM productos where codigo ='{0}'", CodigoBarra), BdComun.ObtenerConexion());

MySqlDataReader leer = comando.ExecuteReader();

while (leer.Read()) {

ClassProducto Producto = new ClassProducto();

Producto.CodigoBarra = leer.GetDouble(0);

Producto.NombreProducto = leer.GetString(1);

Producto.FechaCad = leer.GetString(2);

lista.Add(Producto);

}

return lista;

}

public static ClassProducto ObtenerProducto(double CodBarra) {

ClassProducto Producto = new ClassProducto();

MySqlConnection conexion = BdComun.ObtenerConexion();

MySqlCommand comando = new MySqlCommand(String.Format("SELECT codigo,producto,fechaCad FROM productos where codigo={0}", CodBarra), conexion);

MySqlDataReader reader = comando.ExecuteReader();

while(reader.Read()){

Producto.CodigoBarra = reader.GetDouble(0);

Producto.NombreProducto = reader.GetString(1);

Producto.FechaCad = reader.GetString(2);

}

conexion.Close();

return Producto;

}

public static double Actualizar(ClassProducto Product) {

double retorno = 0.00;

MySqlConnection conexion = BdComun.ObtenerConexion();

MySqlCommand comando = new MySqlCommand(string.Format("UPDATE productos SET producto='{0}',fechaCad='{1}'WHERE codigo='{2}'",

Product.NombreProducto, Product.FechaCad, Product.CodigoBarra), conexion);

retorno = comando.ExecuteNonQuery();

conexion.Close();

return retorno;

}

public static double Eliminar(double pId) {

double retorno = 0.00;

MySqlConnection conexion = BdComun.ObtenerConexion();

MySqlCommand comando = new MySqlCommand(string.Format("Delete From productos where codigo={0}", pId), conexion);

retorno = comando.ExecuteNonQuery();

conexion.Close();

return retorno;

}

}

}

Clase 8:

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;

namespace CONBASESDED

{

public partial class frmBuscarProductos : Form

{

public frmBuscarProductos() {

InitializeComponent();

}

internal ClassProducto ProductoSeleccionado { get; set; }

private void btnBuscar_Click(object sender, EventArgs e)

{

double i = Convert.ToDouble(tbxCB.Text);

dtvRegistro.DataSource = ProductoDAL.Buscar(i);

}

private void btnAceptar_Click(object sender, EventArgs e)

{

if (dtvRegistro.SelectedRows.Count == 1)

{

double id = Convert.ToDouble(dtvRegistro.CurrentRow.Cells[0].Value);

ProductoSeleccionado = ProductoDAL.ObtenerProducto(id);

this.Close();

}

else

MessageBox.Show("Debe seleccionar una fila");

}

private void btnCancelar_Click(object sender, EventArgs e)

{

this.Close();

}

}

}

Clase 9:

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;

using MySql.Data.Types;

namespace CONBASESDED

{

public partial class FrmProducto : Form

{

internal ClassProducto ProductoActual { get; set; }

public FrmProducto()

{

InitializeComponent();

}

void limpiar()

{

tbxCodigob.Clear();

tbxProducto.Clear();

dtpFecha.ResetText();

}

void Habilitar()

{

tbxCodigob.Enabled = true;

tbxProducto.Enabled = true;

dtpFecha.Enabled = true;

btnGuardar.Enabled = true;

btnCancelar.Enabled = true;

}

void deshabilitar()

{

tbxCodigob.Enabled = false;

tbxProducto.Enabled = false;

dtpFecha.Enabled = false;

btnGuardar.Enabled = false;

btnEliminar.Enabled = false;

btnActualizar.Enabled = false;

btnCancelar.Enabled = false;

btnNuevo.Enabled = true;

}

private void btnGuardar_Click_1(object sender, EventArgs e)

{

if (string.IsNullOrWhiteSpace(tbxCodigob.Text) ||

string.IsNullOrWhiteSpace(tbxProducto.Text))

MessageBox.Show("Hay uno om mas campos vacios", "campos vacios",

MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

else

{

ClassProducto Producto = new ClassProducto();

Producto.CodigoBarra = Convert.ToDouble(tbxCodigob.Text.Trim());

Producto.NombreProducto = tbxProducto.Text.Trim();

Producto.FechaCad = dtpFecha.Value.Year + "/" +

dtpFecha.Value.Month + "/" + dtpFecha.Value.Day;

double resultado = ProductoDAL.Agregar(Producto);

if (resultado > 0)

{

MessageBox.Show("Producto Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo guardar el producto", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

}

private void btnNuevo_Click_1(object sender, EventArgs e)

{

limpiar();

Habilitar();

tbxCodigob.Focus();

}

private void btnActualizar_Click_1(object sender, EventArgs e)

{

if (string.IsNullOrWhiteSpace(tbxCodigob.Text) ||

string.IsNullOrWhiteSpace(tbxProducto.Text))

MessageBox.Show("Hay Uno o mas Campos Vacios", "Campos Vacios", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

else

{

ClassProducto Producto = new ClassProducto();

Producto.CodigoBarra = Convert.ToDouble(tbxCodigob.Text.Trim());

Producto.NombreProducto = tbxProducto.Text.Trim();

Producto.FechaCad = dtpFecha.Value.Year + "/" +

dtpFecha.Value.Month + "/" + dtpFecha.Value.Day;

if (ProductoDAL.Actualizar(Producto) > 0)

{

MessageBox.Show("Los datos del producto se actualizaron", "Datos Actualizados", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo actualizar", "Error al Actualizar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

}

private void btnEliminar_Click_1(object sender, EventArgs e)

{

if (MessageBox.Show("Esta Seguro que desea eliminar el Producto Actual", "Estas Seguro??", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

{

if (ProductoDAL.Eliminar(ProductoActual.CodigoBarra) > 0)

{

MessageBox.Show("Producto Eliminado Correctamente!", "Producto Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information);

limpiar();

deshabilitar();

}

else

{

MessageBox.Show("No se pudo eliminar el Producto", "Producto No Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

}

else

MessageBox.Show("Se cancelo la eliminacion", "Eliminacion Cancelada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

private void btnBuscar_Click_1(object sender, EventArgs e)

{

frmBuscarProductos buscar = new frmBuscarProductos();

buscar.ShowDialog();

if (buscar.ProductoSeleccionado != null)

{

ProductoActual = buscar.ProductoSeleccionado;

tbxCodigob.Text = Convert.ToString(buscar.ProductoSeleccionado.CodigoBarra);

tbxProducto.Text = buscar.ProductoSeleccionado.NombreProducto;

dtpFecha.Text = buscar.ProductoSeleccionado.FechaCad;

btnActualizar.Enabled = true;

btnEliminar.Enabled = true;

Habilitar();

btnGuardar.Enabled = false;

}

}

private void btnCancelar_Click_1(object sender, EventArgs e)

{

limpiar();

deshabilitar();

}

private void FrmProducto_Load_1(object sender, EventArgs e)

{

deshabilitar();

}

}

}

Clase 10:

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;

namespace CONBASESDED

{

public partial class FrmPaginaPrincipal : Form

{

public FrmPaginaPrincipal()

{

InitializeComponent();

}

private void salirToolStripMenuItem_Click(object sender, EventArgs e)

{

DialogResult opcion;

opcion = MessageBox.Show("Archivo", "Desea salir....!!!?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

if (opcion == DialogResult.Yes)

{

Close();

}

else if (opcion == DialogResult.No)

{

MessageBox.Show("Has pulsado -No-");

}

else

{

MessageBox.Show("Has pulsado Cancel");

}

}

private void clientesToolStripMenuItem_Click(object sender, EventArgs e)

{

frmPrincipal enai = new frmPrincipal();

enai.ShowDialog();

}

private void salirToolStripMenuItem_MouseEnter(object sender, EventArgs e)

{

ToolStripMenuItem obj = (ToolStripMenuItem)sender;

if (obj == salirToolStripMenuItem)

{

tspMensaje.Text = "salir Ventana... ";

}

}

private void salirToolStripMenuItem_MouseLeave(object sender, EventArgs e)

{

tspMensaje.Text = "Listo";

}

private void clientesToolStripMenuItem_MouseEnter(object sender, EventArgs e)

{

ToolStripMenuItem obj = (ToolStripMenuItem)sender;

if (obj == tspClientes)

{

tspMensaje.Text = "ventana Cliente... ";

}

}

private void tspClientes_MouseLeave(object sender, EventArgs e)

{

tspMensaje.Text = "Listo";

}

private void productosToolStripMenuItem_MouseEnter(object sender, EventArgs e)

{

ToolStripMenuItem obj = (ToolStripMenuItem)sender;

if (obj == tspProductos)

{

tspMensaje.Text = "ventana Producto... ";

}

}

private void tspProductos_MouseLeave(object sender, EventArgs e)

{

tspMensaje.Text = "Listo";

}

private void tspProductos_Click(object sender, EventArgs e)

{

FrmProducto productos = new FrmProducto();

productos.ShowDialog();

}

private void generarReportesToolStripMenuItem_Click(object sender, EventArgs e)

{

FrmReportes reportes = new FrmReportes();

reportes.ShowDialog();

reportes.MdiParent = this;

}

}

}

3.4 PRINTSCREEN DE EJECUCIN DEL PROGRAMA.

CONCLUSIN.

La prctica de esta unidad que fue elaborar una aplicacin que se conectara con mysql y que realizara las consultas bsicas, despus de conocer esta nueva herramienta que son las operaciones de consultas.

El tema de los componentes y libreras es muy relevante porque nos permite visualizar cosas que estn atrs de objetos, el funcionamiento de manera interna de cada componente de un Windows Form. Componentes es un tema de importancia que sirve para aprender nuevas tcnicas de solucin de problemas en la programacin, as como una herramienta de trabajo ms eficiente y eficaz.

A manera de concluir es necesario recalcar que los componentes y libreras tienen mucha relevancia a la hora de hablar de programacin, es decir, es indispensable para que nuestra forma de programar sea la correcta a la hora de desarrollar cualquier tipo de software.

BIBLIOGRAFIA

John Sharp. (2012). Microsoft Visual C# 2012.Mc Graw Hill. Mexico.pags. 1027

(2)