Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Lab 16 PDF
Lab 16 PDF
net
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
/// <summary>
/// Descripción breve de ClsConexion
/// </summary>
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();
}
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;
/// <summary>
/// Descripción breve de ClsAreas
/// </summary>
public class ClsAreas : ClsConexion
{
string tabla = "Areas";
protected string nombre;
protected int codigo, tiempo;
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
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;
{
try
{
ClsAreas are = new ClsAreas(0, "", 1);
are.Codigo = int.Parse(TxtCodigo.Text);
are.Nombre = TxtNombre.Text;
are.Tiempo = int.Parse(TxtTiempo.Text);
are.agregar();
LblEstado.Text = "Registro Agregado Exitosamente";
TxtCodigo.Text = "";
TxtNombre.Text = "";
TxtTiempo.Text = "";
}
catch
{
LblEstado.Text = "El Registro ya Existe";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
CODIGO PARA MODIFICAR AREAS
<%@ Page
}
else { LblEstado.Text = "El Registro No Se Elimino"; }
}
}
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; }
}
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
if (int.Parse(fila["libCodigo"].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;
}
}
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;
lib.Agregar();
LblEstadoLb.Text = "Registro Agregado Exitosamente";
TxtCodigoLb.Text = "";
TxtNombreLb.Text = "";
TxtNumPagLb.Text = "";
TxtAutorLb.Text = "";
TxtEditorialLb.Text = "";
}
catch
{
LblEstadoLb.Text = "El Registro ya Existe";
}
}
}
CODIGO PARA CONSULTA DE LIBROS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
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;
/// <summary>
/// Descripción breve de ClsAreas
/// </summary>
public class ClsPrestamo : ClsConexion
{
string tabla = "Prestamos";
protected string fecha;
protected int codigo, 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 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.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; }
}
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;
pre.agregar();
LblEstadoPre.Text = "Registro Agregado Exitosamente";
TxtCodigoPre.Text = "";
TxtFechaPre.Text = "";
}
catch
{
LblEstadoPre.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; }
}
Data.Tables[tabla].Rows.Add(fila);
AdaptadorDatos.Update(Data, tabla);
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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
usu.agregar();
LblEstadoUsu.Text = "Registro Agregado Exitosamente";
TxtDocumentoUsu.Text = "";
TxtNombreUsu.Text = "";
TxtDireccionUsu.Text = "";
TxtTelefonoUsu.Text = "";
TxtCorreoUsu.Text = "";
TxtEstadoUsu.Text = "";
}
catch
{
LblEstadoUsu.Text = "El Registro ya Existe";
}
}
}
CODIGO PARA CONSULTAR USUARIOS
<td> &nbs
p;
&n
bsp;  
; &
nbsp; &nbs
p;
MODIFICAR USUARIOS </td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="usuDocumento"
DataSourceID="ObjectDataSource1" ForeColor="#333333" GridLines="None"
PageSize="5">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:BoundField DataField="usuDocumento"
HeaderText="usuDocumento" ReadOnly="True" SortExpression="usuDocumento" />
<asp:BoundField DataField="usuNombre" HeaderText="usuNombre"
SortExpression="usuNombre" />
<asp:BoundField DataField="usuDireccion" HeaderText="usuDireccion"
SortExpression="usuDireccion" />
<asp:BoundField DataField="usuTelefono" HeaderText="usuTelefono"
SortExpression="usuTelefono" />
<asp:BoundField DataField="usuCorreo" HeaderText="usuCorreo"
SortExpression="usuCorreo" />
<asp:BoundField DataField="usuEstado" HeaderText="usuEstado"
SortExpression="usuEstado" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White"
/>
<HeaderStyle BackColor="#1C5E55" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="DataSetTableAdapters.UsuariosTableAdapter" UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_usuDocumento" Type="Decimal" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="usuDocumento" Type="Decimal" />
<asp:Parameter Name="usuNombre" Type="String" />
<asp:Parameter Name="usuDireccion" Type="String" />
<asp:Parameter Name="usuTelefono" Type="String" />
<asp:Parameter Name="usuCorreo" Type="String" />
<asp:Parameter Name="usuEstado" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="usuNombre" Type="String" />
<asp:Parameter Name="usuDireccion" Type="String" />
<asp:Parameter Name="usuTelefono" Type="String" />
<asp:Parameter Name="usuCorreo" Type="String" />
<asp:Parameter Name="usuEstado" Type="String" />
<asp:Parameter Name="Original_usuDocumento" Type="Decimal" />
</UpdateParameters>
</asp:ObjectDataSource>
<br />
</td>
</tr>
</table>
</form>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
else { LblEstado.Text = "El Registro No Se Elimino"; }
}
}