Programa 1 y 2
Unidad 2
Alan Moreno Jiménez
Programa que solicita datos a un usuario y los almacena en una base de
datos, utilizando diferentes herramientas para su funcionamiento.
La segunda parte del programa nos ayuda a utilizar botones como Actualizar,
Limpiar, Borrar y Buscar asi como la utilización de teclas para sus comandos
Código Fuente:
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Inividual
{
public class ClientesDAL
{
public static int Agregar(Cliente pCliente)
{
int retorno = 0;
MySqlCommand comando=new MySqlCommand([Link]("Insert into
Biblioteca (Num_Control, Nombre_Alumno, Foto) values ('{0}','{1}','{2}')",
[Link], [Link], [Link]),
[Link]());
retorno = [Link]();
return retorno;
}
public static List<Cliente> Buscar(string pNombre)
{
List<Cliente> _lista = new List<Cliente>();
MySqlCommand _comando = new MySqlCommand([Link](
"SELECT Num_Control, Nombre_Alumno, Imagen FROM Biblioteca where Nombre
='{0}' or Sinopsis='{1}'", pNombre), [Link]());
MySqlDataReader _reader = _comando.ExecuteReader();
while (_reader.Read())
{
Cliente pCliente = new Cliente();
[Link] = _reader.GetString(0);
[Link]= _reader.GetString(1);
[Link]= _reader.GetString(2);
_lista.Add(pCliente);
}
return _lista;
}
public static Cliente ObtenerCliente(int pId)
{
Cliente pCliente = new Cliente();
MySqlConnection conexion = [Link]();
MySqlCommand _comando = new MySqlCommand([Link]("SELECT
Num_Control, Nombre, Imagen FROM Biblioteca where Num_Control={0}", pId), conexion);
MySqlDataReader _reader = _comando.ExecuteReader();
while (_reader.Read())
{
[Link] = _reader.GetString(0);
[Link] = _reader.GetString(1);
[Link] = _reader.GetString(2);
[Link]();
return pCliente;
}
}
}
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace Inividual
{
public class Cliente
{ public string Control { get; set; }
public string Nombre { get; set; }
public string Imagen { get; set; }
public Cliente() { }
public Cliente( string pNombre, string pControl, string pImagen)
[Link] = pControl;
[Link] = pNombre;
[Link] = pImagen;
}
}
}
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Inividual
{
public class BDcomun
{
public static MySqlConnection ObtenerConexion()
{
MySqlConnection conectar = new MySqlConnection("server=[Link];
database=Tema; Uid=root; pwd=;");
[Link]();
return conectar;
}
}
}
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Inividual
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
private void B_Cargar_Click(object sender, EventArgs e)
{
[Link] = "Open Picture";
[Link] = ".jpg";
[Link] = "All Files |*.*";
[Link]();
[Link] = [Link]([Link]);
//Do Nothing End Try End Try
}
private void B_Inicio_Click(object sender, EventArgs e)
{
[Link]();
[Link]("CONECTADO");
}
private void B_Guardar_Click(object sender, EventArgs e)
{
Cliente pCliente = new Cliente();
[Link]= Tb_Nombre.[Link]();
[Link]= Tb_Sinopsis.[Link]();
[Link] = [Link]();
int resultado = [Link](pCliente);
if (resultado > 0)
{
[Link]("Alumno Guardado Con Exito!!", "Guardado",
[Link], [Link]);
}
else
{
[Link]("No se pudo guardar el Alumno", "Fallo!!",
[Link], [Link]);
}
}
private void B_Buscar_Click(object sender, EventArgs e)
{
private void Main_Load(object sender, EventArgs e)
{
private void Tb_Sinopsis_TextChanged(object sender, EventArgs e)
{
private void C_Musica_CheckedChanged(object sender, EventArgs e)
{
private void Com_Letras_SelectedIndexChanged(object sender, EventArgs e)
{
private void button1_Click(object sender, EventArgs e)
{
[Link]();
}
}
}