AP7-AA4-Ev2-Desarrollo de aplicaciones WEB con ASP NET y C# ...

September 17, 2017 | Author: Anonymous | Category: ASP, C#
Share Embed


Short Description

AP7-AA4-Ev2-Desarrollo de aplicaciones WEB con ASP NET y C# usando visual studio . net. Jorge Armando Guerrero Torres. S...

Description

AP7-AA4-Ev2-Desarrollo de aplicaciones WEB con ASP NET y C# usando visual studio .net

Jorge Armando Guerrero Torres

Servicio Nacional de Aprendizaje SENA Centro de Teleinformática y Producción Industrial Bogotá D.C Análisis y Desarrollo de Sistemas de Información 2017

Realizar la práctica expuesta en el laboratorio 16. “Desarrollo de aplicaciones WEB con ASP .NET y C# en Visual Studio .NET”, donde se plantea la construcción de una aplicación para una biblioteca municipal. La plantilla HTML que se utilizó para el desarrollo de esta web fue descargada del siguiente enlace: http://www.free-css.com/free-css-templates/page1/plusbusiness#shout CLASE PARA LA CONEXIÓN using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; /// /// Descripción breve de ClsConexion /// public class ClsConexion { protected SqlDataReader reader; protected SqlDataAdapter AdaptadorDatos; protected DataSet data; protected SqlConnection oconecccion = new SqlConnection(); public ClsConexion() { // // TODO: Agregar aquí la lógica del constructor // } public void conectar(string tabla) { string strConeccion = ConfigurationManager.ConnectionStrings["BibliotecaConnectionString1"].ConnectionStrin g; oconecccion.ConnectionString = strConeccion; oconecccion.Open(); AdaptadorDatos = new SqlDataAdapter("select * from " + tabla, oconecccion); SqlCommandBuilder ejecutacomandos = new SqlCommandBuilder(AdaptadorDatos); Data = new DataSet(); AdaptadorDatos.Fill(Data, tabla);

oconecccion.Close(); } public DataSet Data { set { data = value; } get { return data; } } public SqlDataReader Datareader { set { reader = value; } get { return reader; } } }

AREA LIBROS Codigo de la Clase Areas using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; ///

/// Descripción breve de ClsAreas /// public class ClsAreas : ClsConexion { string tabla = "Areas"; protected string nombre; protected int codigo, tiempo; public ClsAreas(int codigo, string nombre, int tiempo) { this.codigo = codigo; this.nombre = nombre; this.tiempo = tiempo; } public int Codigo { set { codigo = value; } get { return codigo; } } public string Nombre { set { nombre = value; } get { return nombre; } } public int Tiempo { set { tiempo = value; } get { return tiempo; } } public void agregar() { conectar(tabla); DataRow fila; fila = Data.Tables[tabla].NewRow(); fila["areCodigo"] = codigo; fila["areNombre"] = Nombre; fila["areTiempo"] = tiempo; Data.Tables[tabla].Rows.Add(fila); AdaptadorDatos.Update(Data, tabla); } public bool eliminar(int valor) { conectar(tabla);

DataRow fila; int x = Data.Tables[tabla].Rows.Count - 1; for (int i = 0; i

         

CODIGO PARA MODIFICAR LIBROS            & nbsp;           &nbs p;                         &n

bsp;             ;            & nbsp;           &nbs p;            MODIFICAR LIBRO



CODIGO PARA ELIMINAR LIBRO using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class pageEliminarLibro : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { ClsLibros are = new ClsLibros(0, "", 1, "", "", 2); if (are.eliminar(int.Parse(DropDownList1.Text))) { LblEstado.Text = "El Registro se Elimino con Exito"; } else { LblEstado.Text = "El Registro No Se Elimino"; } } }

CLASE PRESTAMOS using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; /// /// Descripción breve de ClsAreas /// public class ClsPrestamo : ClsConexion { string tabla = "Prestamos"; protected string fecha; protected int codigo, usuario; public ClsPrestamo(int codigo, string fecha, int usuario) { this.codigo = codigo; this.fecha = fecha; this.usuario = usuario; } public int Codigo { set { codigo = value; } get { return codigo; } } public string Fecha { set { fecha = value; } get { return fecha; } } public int Usuario { set { usuario = value; } get { return usuario; } } public void agregar() { conectar(tabla); DataRow fila; fila = Data.Tables[tabla].NewRow(); fila["preCodigo"] = codigo; fila["preFecha"] = Fecha; fila["preUsuario"] = Usuario;

Data.Tables[tabla].Rows.Add(fila); AdaptadorDatos.Update(Data, tabla); }

}

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; /// /// Descripción breve de ClsAreas /// public class ClsDtpPrestamos : ClsConexion { string tabla = "DetallePrestamos"; protected string fechafin, fechadev; protected int prestamo, libro, cantidad; public ClsDtpPrestamos(int prestamo, int libro, int cantidad, string fechafin, string fechadev) { this.prestamo = prestamo; this.libro = libro; this.cantidad = cantidad; this.fechafin = fechafin; this.fechadev = fechadev; } public int Prestamo { set { prestamo = value; } get { return prestamo; } } public int Libro { set { libro = value; }

get { return libro; } } public int Cantidad { set { cantidad = value; } get { return cantidad; } } public string Fechafin { set { fechafin = value; } get { return fechafin; } } public string Fechadev { set { fechadev = value; } get { return fechadev; } } public void agregar() { conectar(tabla); DataRow fila; fila = Data.Tables[tabla].NewRow(); fila["dtpCodigo"] = prestamo; fila["dtpLibro"] = libro; fila["dtpCantidad"] = cantidad; fila["dtpFechaFin"] = fechafin; fila["dtpFechadev"] = fechadev; Data.Tables[tabla].Rows.Add(fila); AdaptadorDatos.Update(Data, tabla); } }

CODIGO PRESTAMOS using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class pageRealizarPrestamo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { } protected void BtnAgregarPre_Click(object sender, EventArgs e) { try { ClsPrestamo pre = new ClsPrestamo(0, "", 1); pre.Codigo = int.Parse(TxtCodigoPre.Text); pre.Fecha = TxtFechaPre.Text; pre.Usuario = int.Parse(DropDownList1.Text); pre.agregar(); LblEstadoPre.Text = "Registro Agregado Exitosamente"; TxtCodigoPre.Text = ""; TxtFechaPre.Text = ""; } catch { LblEstadoPre.Text = "El Registro ya Existe"; } }

protected void BtnAgregarLb_Click(object sender, EventArgs e) {

try { ClsDtpPrestamos dtp= new ClsDtpPrestamos(0, 1, 2, "", ""); dtp.Prestamo = int.Parse(DropDownList3.Text); dtp.Libro = int.Parse(DropDownList2.Text); dtp.Cantidad = int.Parse(TxtcantidadDtp.Text); dtp.Fechafin = TxtLimiteDtp.Text; dtp.Fechadev = TxtFechaDev.Text; dtp.agregar(); LblEstadoDtp.Text = "Registro Agregado Exitosamente"; TxtcantidadDtp.Text = ""; TxtLimiteDtp.Text = ""; TxtFechaDev.Text = ""; } catch { LblEstadoDtp.Text = "El Registro ya Existe"; } } }

CLASE USUARIO using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; /// /// Descripción breve de ClsUsuario /// public class ClsUsuario : ClsConexion { string tabla = "Usuarios"; protected string nombre, direccion, telefono, correo, estado; protected int documento; public ClsUsuario(int documento, string nombre, string direccion, string telefono, string correo, string estado) { this.documento = documento; this.nombre = nombre; this.direccion = direccion; this.telefono = telefono; this.correo = correo; this.estado = estado; } public int Documento { set { documento = value; } get { return documento; } } public string Nombre { set { nombre = value; } get { return nombre; } } public string Direccion { set { direccion = value; } get { return direccion; } } public string Telefono { set { telefono = value; }

get { return telefono; } } public string Correo { set { correo = value; } get { return correo; } } public string Estado { set { estado = value; } get { return estado; } } public void agregar() { conectar(tabla); DataRow fila; fila = Data.Tables[tabla].NewRow(); fila["usuDocumento"] = documento; fila["usuNombre"] = nombre; fila["usuDireccion"] = direccion; fila["usuTelefono"] = telefono; fila["usuCorreo"] = correo; fila["usuEstado"] = estado; Data.Tables[tabla].Rows.Add(fila); AdaptadorDatos.Update(Data, tabla); } public bool eliminar(int valor) { conectar(tabla); DataRow fila; int x = Data.Tables[tabla].Rows.Count - 1; for (int i = 0; i  

         

CODIGO PARA MODIFICAR USUARIOS            &nbs p;                         &n bsp;             ;            & nbsp;           &nbs p;                          MODIFICAR USUARIOS





CODIGO PARA ELI MINAR USUARIOS using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class pageEliminarUsuario : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { ClsUsuario usu = new ClsUsuario(0, "", "", "", "", ""); if (usu.eliminar(int.Parse(DropDownList1.Text))) {

LblEstado.Text = "El Registro se Elimino con Exito"; } else { LblEstado.Text = "El Registro No Se Elimino"; } } }

View more...

Comments

Copyright © 2017 DATENPDF Inc.