Documentos de Académico
Documentos de Profesional
Documentos de Cultura
net
ADSI 1181648
SENA
2017
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;
/// </summary>
public ClsConexion()
//
string strConeccion =
ConfigurationManager.ConnectionStrings["BibliotecaConnectionString1"].ConnectionStrin
g;
oconecccion.ConnectionString = strConeccion;
oconecccion.Open();
AdaptadorDatos.Fill(Data, tabla);
oconecccion.Close();
AREA LIBROS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// </summary>
this.codigo = codigo;
this.nombre = nombre;
this.tiempo = tiempo;
conectar(tabla);
DataRow fila;
fila["areNombre"] = Nombre;
fila["areTiempo"] = tiempo;
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
conectar(tabla);
DataRow fila;
int x = Data.Tables[tabla].Rows.Count - 1;
for (int i = 0; i <= x; i++)
fila = Data.Tables[tabla].Rows[i];
if (int.Parse(fila["areCodigo"].ToString()) == valor)
fila = Data.Tables[tabla].Rows[i];
fila.Delete();
DataTable tablaborrados;
tablaborrados = Data.Tables[tabla].GetChanges(DataRowState.Deleted);
AdaptadorDatos.Update(tablaborrados);
Data.Tables[tabla].AcceptChanges();
return true;
return false;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class pageConsultarAreas : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void SqlDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
}
protected void ObjectDataSource1_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
{
}
}
CLASE LIBROS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Descripción breve de ClsLibros
/// </summary>
public class ClsLibros : ClsConexion
{
string tabla = "Libros";
protected string nombre, autor, editorial;
protected int codigo, numpag, area;
public ClsLibros (int codigo, string nombre, int numpag, string autor, string editorial, int
area)
{
this.codigo = codigo;
this.nombre = nombre;
this.numpag = numpag;
this.autor = autor;
this.editorial = editorial;
this.area = area;
}
public int Codigo
{
set { codigo = value; }
get { return codigo; }
}
public string Nombre
{
set { nombre = value; }
get { return nombre; }
}public int NumPag
{
set { numpag = value; }
get { return numpag; }
}
public string Autor
{
set { autor = value; }
get { return autor; }
}
{public string Editorial
set { editorial = value; }
get { return editorial; }
}
public int Area
{
set { area = value; }
get { return area; }
}
{public void Agregar()
conectar(tabla);
DataRow fila;
fila = Data.Tables[tabla].NewRow();
fila["libCodigo"] = codigo;
fila["libNombre"] = nombre;
fila["libNumPag"] = numpag;
fila["libAutor"] = autor;
fila["libEditorial"] = editorial;
fila["libArea"] = area;
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
}
public bool eliminar(int valor)
{
conectar(tabla);
iDnat txa R=o Dwa ftail.aT;ables[tabla].Rows.Count - 1;
for (int i = 0; i <= x; i++)
{
fila = Data.Tables[tabla].Rows[i];
if (int.Parse(fila["libCodigo"].ToString()) == valor)
{
fila = Data.Tables[tabla].Rows[i];
fila.Delete();
DataTable tablaborrados;
tablaborrados = Data.Tables[tabla].GetChanges(DataRowState.Deleted);
ADadtaap.TtaadbolreDs[attaobsl.aU].pAdcactee(pttaCbhlaabnogrersa(d)o; s);
return true;
}
}
return false;
}
}
CODIGO PARA INGRESO DE LIBROS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class pageIngresarNuevoLibro : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
try
{ ClsLibros lib = new ClsLibros(0, "", 1, "", "", 2);
lib.Codigo = int.Parse(TxtCodigoLb.Text);
lib.Nombre = TxtNombreLb.Text;
lib.NumPag = int.Parse(TxtNumPagLb.Text);
lib.Autor = TxtAutorLb.Text;
lib.Editorial = TxtEditorialLb.Text;
lib.Area = int.Parse(DropDownList1.Text);
lib.Agregar();
LblEstadoLb.Text = "Registro Agregado Exitosamente";
TxtCodigoLb.Text = "";
TxtNombreLb.TxtNumPagLb.TTeexxtt == """";;
TxtAutorLb.Text = "";
TxtEditorialLb.Text = "";
}
catch
{
LblEstadoLb.Text = "El Registro ya Existe";
}
}
}
CLASE PRESTAMOS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Descripción breve de ClsAreas
/// </summary>
public class ClsPrestamo : ClsConexion
{
string tabla = "Prestamos";
protected string fecha;
protected int codigo, usuario;
public ClsPrestamo(int codigo, string fecha, int usuario)
{
this.this.fceocdhiag o= = f eccohdai;go;
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;
/// <summary>
/// Descripción breve de ClsAreas
/// </summary>
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.this.lpirbersot a=m loib =ro p; restamo;
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 dtp.agregar(); = TxtFechaDev.Text;
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;
/// <summary>
/// Descripción breve de ClsUsuario
/// </summary>
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;
ffiillaa[[""uussuuTCeolrerfeoon"o] "=] =co trerleeof;ono;
fila["usuEstado"] = estado;
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
}
public bool eliminar(int valor)
{
conectar(tabla);
iDnat txa R=o Dwa ftail.aT;ables[tabla].Rows.Count - 1;
for (int i = 0; i <= x; i++)
{
fila = Data.Tables[tabla].Rows[i];
if (int.Parse(fila["usuDocumento"].ToString()) == valor)
{
fila = Data.Tables[tabla].Rows[i];
fila.Delete();
DataTable tablaborrados;
tablaborrados = Data.Tables[tabla].GetChanges(DataRowState.Deleted);
AdaptadorDatos.Update(tablaborrados);
Data.Tables[tabla].AcceptChanges();
return true;
}
}
return false;
}
}