Está en la página 1de 23

Carrera: Ing. En Sistemas y Computacin Materia: Programacin II. Tema: Desarrollo de aplicaciones WEB en ASP.NET Docente: Ing.

Ren Castro Estudiantes: Ana Elsy Villalobos Orellana. Ricardo Ernesto Esperanza Bonilla. Csar Roberto Escalante. [ 2931342012 ] [ 2932272011 ] [ 2951422006 ]

San Salvador 24 de abril de 2013

Tabla de contenido
Introduccin ......................................................................................................................................................................2 Objetivos ............................................................................................................................................................................ 3 Desarrollo ejercicio....................................................................................................................................................... 4 Conclusin ...................................................................................................................................................................... 12 Bibliografa...................................................................................................................................................................... 13

Introduccin
El presente documento se muestra el proceso de desarrollo y ejecucin de una aplicacin que permite la venta de vehculos en lnea ya que es una aplicacin WEB diseada en la plataforma de Visual Studio 2010, en la que se utilizan ASP.

Objetivos
General.
Desarrollar u n a a p l i c a c i n en ASP.NET, a fin de que contenga controles y acceso a una base de datos, reporte de forma bsica en crystal report y de esa forma aplicar los conocimientos adquiridos en las sesiones tutoreadas por medio de la plataforma virtual del Universidad tecnolgica

Especficos.
Disear una aplicacin en ASP.NET, respetando lineamientos de programacin mostrados en clases. Elaborar una aplicacin ASP.NET que simule la venta de vehculos adems que permita estar conectada a una base de datos Demostrar el funcionamiento de las aplicacin.

Enunciado
Se requiere desarrollar una aplicacin WEB basada en ASP.NET, que contenga controles y adems que se encuentre conectada a una base de datos.

Cdigo de la Solucin
Cdigo HTML en archivo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Description: Version : Released : Open Tools A two-column, fixed-width design with dark color scheme. 1.0 20130803

--> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="menu_assets/styles.css" rel="stylesheet" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Archivo +Narrow:400,700" rel="stylesheet" type="text/css"> <link href="default.css" rel="stylesheet" type="text/css" media="all" /> <!--[if IE 6]> <link href="default_ie6.css" rel="stylesheet" type="text/css" /> <![endif]--> </head> <body> <div id="header" class="container"> <div id="logo"> <h1><a href="#">tienda en linea</a></h1> </div> <div id="menu"> <ul> <li class="active"><a href="#" accesskey="1" title="">INICIO</a></li> <li><a href="#" accesskey="2" title="">OTROS</a></li> <li><a href="#" accesskey="3" title="">ACERCA DE</a></li> <li><a href="#" accesskey="4" title="">ContactO</a></li> </ul> </div>
4

</div> <div id="page" class="container"> <div id="content"> <div id="onecolumn"> <p><img src="images/20229_23212642199.jpg" alt="" width="578" height="300" /></p> <h2>BIENVENIDO A NUESTRO SITIO</h2> <p>&nbsp;</p> </div> <div id="two-column"> <div class="box-content"></div> <div class="box-content"></div> </div> </div> <div id="sidebar"> <div id="sbox1"> <h2>Menu Principal</h2> <div id='cssmenu'> <ul> <li class='active '><a href='#'><span>Productos</span></a></li> <li><a href='#'><span>Modelos</span></a></li> <li><a href='#'><span>Marcas</span></a><a href='#'>Ofertas<span></a><a href='#'>Registrarse<span></a></li> </ul> </div>

</ul> </div> <div id="sbox2"> <h2>&nbsp;</h2> <p>&nbsp;</p> <div class="author">IMAGEN<span class="name">Juan Dela Cruz</span><span class="position">Company CEO</span><span>MyCompany, LLC</span></div> </div> <div id="sbox3"> <h2>&nbsp;</h2> </div> </div> </div> <div id="footer" class="container"> <div id="fbox1"></div> <div id="fbox2"> <h2>&nbsp;</h2> </div> <div id="fbox3"> <h2>&nbsp;</h2> <ul class="style2"> <li><a href="#"><img src="images/social03.png" width="32" height="32" alt="" /></a></li> <li><a href="#"><img src="images/social01.png" width="32" height="32" alt="" /></a></li> <li><a href="#"><img src="images/social04.png" width="32" height="32" alt="" /></a></li>
5

<li><a href="#"><img src="images/social02.png" width="32" height="32" alt="" /></a></li> </ul> </div> </div> <div id="copyright" class="container"> <p>Copyright (c) 2013 </p> </div> </body> </html>

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="inicio.master.cs" Inherits="inicio" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <link href="styles.css" rel= "Stylesheet" type="text/css" /> <link href="default.css" rel="stylesheet" type="text/css" media="all" /> <title>TIENDA EN LINEA</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder> </head> <body> <div id="header" class="container"> <div id="logo"> <h1><a href="#">tienda en linea</a></h1> </div> <div id="menu"> <ul> <li class="active"><a href="InicioCargar.aspx" accesskey="1" title="">INICIO</a></li> <li><a href="#" accesskey="2" title="">OTROS</a></li> <li><a href="#" accesskey="3" title="">ACERCA DE</a></li> <li><a href="#" accesskey="4" title="">ContactO</a></li> </ul> </div> </div> <div id="page" class="container"> <form id="form1" runat="server"> <div id="content"> <div id="onecolumn"> <br /> <div> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </div> </div> <div id='cssmenu'> <ul> <li class='active '><a href='AgreAuto.aspx'><span style="text-align: left">Productos</span></a></li> <li><a href='AgreModelos.aspx'><span>Modelos</span></a></li> <li><a href='AgreMarcas.aspx'><span>Marcas</span></a> <a href='Comprar.aspx'>Comprar</a><span><a href='Clientes.aspx'>Clientes</a> </li> </ul> </div>
7

</form>

</div>

<div id="sbox2"> <h2>&nbsp;</h2> </div> <div id="sbox3"> <h2>&nbsp;</h2> </div> </div> </div> <div id="footer" class="container"> <div id="fbox3"> <ul class="style2"> <li><a href="#"><img src="images/social03.png" /></a></li> <li><a href="#"><img src="images/social01.png" /></a></li> <li><a href="#"><img src="images/social04.png" /></a></li> <li><a href="#"><img src="images/social02.png" /></a></li> </ul> </div> </div> <div id="copyright" class="container"> <p>Copyright (c) 2013 </p> </div> </body> </html>

width="32" height="32" alt="" width="32" height="32" alt="" width="32" height="32" alt="" width="32" height="32" alt=""

Cdigo ASPX
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <style type="text/css"> .style2 { background-color: #003366; } .style4 { color: #FFFFFF; } .style5 { width: 141px; } .style6
8

{ color: #FFFFFF; } .style7 { width: 141px; color: #FFFFFF; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <p> <table style="width:100%;"> <tr> <td> &nbsp;</td> <td> ADMINISTRAR REGISTROS INGRESADOS</td> </tr> </table> <br /> <asp:FormView ID="FormView1" runat="server" AllowPaging="True" CellPadding="4" DataKeyNames="idauto" DataSourceID="SqlDataSource1" ForeColor="#333333" style="text-align: justify"> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#E3EAEB" /> <EditItemTemplate> <span class="style4">Codigo</span>: <asp:Label ID="idautoLabel1" runat="server" Text='<%# Eval("idauto") %>' style="color: #FFFFFF" /> <br /> <br /> <table style="width: 100%;"> <tr> <td class="style7"> Marca:</td> <td> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="nommarca" DataValueField="idmarca" SelectedValue='<%# bind("idmarca") %>'> </asp:DropDownList> </td> <td> &nbsp;</td> </tr> <tr> <td class="style7"> Modelo:</td> <td> <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3"
9

DataTextField="nomodelo" DataValueField="idmodelo" SelectedValue='<%# bind("idmodelo") %>'> </asp:DropDownList> </td> <td> &nbsp;</td> </tr> <tr> <td class="style7"> <span class="style4">Descripcin:</span></td> <td> <span class="style4"> <asp:TextBox ID="descripcionTextBox" runat="server" Height="39px" Text='<%# Bind("descripcion") %>' Width="218px" /> </span> </td> <td> &nbsp;</td> </tr> <tr> <td class="style6"> Existencias</td> <td> <span class="style4"> <asp:TextBox ID="existenciasTextBox" runat="server" Height="22px" Text='<%# Bind("existencias") %>' Width="67px" /> </span> </td> <td> &nbsp;</td> </tr> <tr> <td class="style6"> Ao:</td> <td> <span class="style4"> <asp:TextBox ID="aoTextBox" runat="server" Height="19px" Text='<%# Bind("ao") %>' Width="67px" /> </span> </td> <td> &nbsp;</td> </tr> <tr> <td class="style5"> <br class="style4" /> <span class="style4">Precio:</span></td> <td> <span class="style4"> <asp:TextBox ID="precioTextBox" runat="server" Text='<%# Bind("precio") %>' /> </span> </td>
1 0

<td> &nbsp;</td> </tr> <tr> <td class="style6"> Fecha de ingreso:</td> <td> <span class="style4"> <asp:TextBox ID="fechadeIngresoTextBox" runat="server" Text='<%# Bind("fechadeIngreso") %>' /> </span> </td> <td> &nbsp;</td> </tr> <tr> <td class="style6"> Imagen:</td> <td> <span class="style4"> <asp:TextBox ID="fotoTextBox" runat="server" Text='<%# Bind("foto") %>' /> <br /> </span> </td> <td> &nbsp;</td> </tr> <tr> <td class="style6" colspan="2"> <span class="style4"><span class="style4"> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Actualizar" /> </span><span class="style4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="style4"> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancelar" /> </span></span></span> </td> <td> &nbsp;</td> </tr> </table> &nbsp; </EditItemTemplate> <InsertItemTemplate> descripcion: <asp:TextBox ID="descripcionTextBox0" runat="server" Text='<%# Bind("descripcion") %>' /> <br /> idmarca: <asp:TextBox ID="idmarcaTextBox0" runat="server" Text='<%# Bind("idmarca") %>' /> <br /> idmodelo:
1 1

<asp:TextBox ID="idmodeloTextBox0" runat="server" Text='<%# Bind("idmodelo") %>' /> <br /> foto: <asp:TextBox ID="fotoTextBox0" runat="server" Text='<%# Bind("foto") %>' /> <br /> existencias: <asp:TextBox ID="existenciasTextBox0" runat="server" Text='<%# Bind("existencias") %>' /> <br /> fechadeIngreso: <asp:TextBox ID="fechadeIngresoTextBox0" runat="server" Text='<%# Bind("fechadeIngreso") %>' /> <br /> ao: <asp:TextBox ID="aoTextBox0" runat="server" Text='<%# Bind("ao") %>' /> <br /> precio: <asp:TextBox ID="precioTextBox0" runat="server" Text='<%# Bind("precio") %>' /> <br /> nommarca: <asp:TextBox ID="nommarcaTextBox0" runat="server" Text='<%# Bind("nommarca") %>' /> <br /> nomodelo: <asp:TextBox ID="nomodeloTextBox0" runat="server" Text='<%# Bind("nomodelo") %>' /> <br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insertar" /> &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancelar" /> </InsertItemTemplate> <ItemTemplate> &nbsp;Disponible desde:&nbsp;: <asp:Label ID="fechadeIngresoLabel" runat="server" Text='<%# Bind("fechadeIngreso") %>' /> <br /> <br /> <table style="width: 103%; height: 72px;"> <tr> <td class="style3"> <span class="style4">CODIGO:</span></td> <td class="style2"> <asp:Label ID="idautoLabel" runat="server" style="color: #FFFFFF" Text='<%# Eval("idauto") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td class="style1" rowspan="3"> <asp:Image ID="Image1" runat="server"
1 2

Height="74px" ImageUrl='<%# bind("foto") %>' Width="97px" /> </td> <td> <asp:Label ID="nommarcaLabel" runat="server" Text='<%# Bind("nommarca") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td> <asp:Label ID="nomodeloLabel" runat="server" Text='<%# Bind("nomodelo") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td> $ <asp:Label ID="precioLabel" runat="server" Text='<%# Bind("precio") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td class="style1"> Ao:</td> <td> <asp:Label ID="aoLabel" runat="server" Text='<%# Bind("ao") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td class="style1"> Descripcion:</td> <td> <asp:Label ID="descripcionLabel" runat="server" Text='<%# Bind("descripcion") %>' /> </td> <td> &nbsp;</td> </tr> <tr> <td class="style1"> total disponibles:</td> <td> <asp:Label ID="existenciasLabel" runat="server" Text='<%# Bind("existencias") %>' /> </td> <td> &nbsp;</td> </tr> </table>
1 3

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Editar" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Eliminar" /> </ItemTemplate> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> </asp:FormView> </p> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sistemaprograIIConnectionString %>" DeleteCommand="delete from autos where idauto=@idauto" SelectCommand="SELECT autos.idauto, autos.descripcion, autos.idmarca, autos.idmodelo, autos.foto, autos.existencias, autos.fechadeIngreso, autos.ao, autos.precio, marca.nommarca, modelo.nomodelo FROM autos INNER JOIN marca ON autos.idmarca = marca.idmarca INNER JOIN modelo ON autos.idmodelo = modelo.idmodelo" UpdateCommand="UPDATE autos SET descripcion = @descripcion, idmarca = @idmarca, idmodelo = @idmodelo, foto = @foto, existencias = @existencias, fechadeIngreso = @fechadeingreso, ao = @ao, precio = @precio where idauto=@idauto "> <DeleteParameters> <asp:Parameter Name="idauto" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="descripcion" /> <asp:Parameter Name="idmarca" /> <asp:Parameter Name="idmodelo" /> <asp:Parameter Name="foto" /> <asp:Parameter Name="existencias" /> <asp:Parameter Name="fechadeingreso" /> <asp:Parameter Name="ao" /> <asp:Parameter Name="precio" /> <asp:Parameter Name="idauto" /> </UpdateParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:sistemaprograIIConnectionString %>" SelectCommand="SELECT [idmarca], [nommarca] FROM [marca]"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:sistemaprograIIConnectionString %>" SelectCommand="SELECT [idmodelo], [nomodelo] FROM [modelo]"> </asp:SqlDataSource> <br /> </asp:Content>
1 4

Codigo C#

using using using using using using using using using using using using using

System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.IO;

public partial class Default2 : System.Web.UI.Page { conexion cn = new conexion(); DataTable tabla,tabla1; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { tabla = cn.consulta("select * from marca", "marca"); DropDownList1.DataSource = tabla; DropDownList1.DataValueField = tabla.Columns[0].ToString(); DropDownList1.DataTextField = tabla.Columns[1].ToString(); DropDownList1.DataBind();

} } protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e) { tabla1 = cn.consulta("select * from modelo where idmarca='" + DropDownList1.SelectedItem.Value + "'", "modelo"); DropDownList2.DataSource = tabla1; DropDownList2.DataValueField = tabla1.Columns[0].ToString(); DropDownList2.DataTextField = tabla1.Columns[1].ToString(); DropDownList2.DataBind(); } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { String marca, modelo, imagen,desc,fechaingreso,precio; int ao, existencias; marca = DropDownList1.SelectedItem.Value;
1 5

modelo = DropDownList2.SelectedItem.Value; imagen = "~/images/" + FileUpload1.FileName; desc = TextBox3.Text; ao = Convert.ToInt32(TextBox1.Text); existencias = Convert.ToInt32(TextBox2.Text); fechaingreso = TextBox4.Text; precio = TextBox5.Text; int i = cn.ejecutaSQL("insert into autos(descripcion,idmarca,idmodelo,foto,existencias,fechadeIngreso,ao,precio) values('" + desc + "','" + marca + "','" + modelo + "','" + imagen + "','" + existencias + "','" + fechaingreso + "','" + ao + "','" + precio + "')"); if(i>0) { Response.Write("<script languaje=javascript>alert('Registro Almacenado');</script>"); FileUpload1.SaveAs(Server.MapPath(imagen)); Response.Redirect("AgreAuto.aspx"); }

} protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { Response.Redirect("ActualizarEliminarautos.aspx"); } }

1 6

Comprobacin de funcionamiento de la Solucin.

20/05/2012

20/05/2012

Conclusin
Con el desarrollo de estos ejercicio se ha permitido re-afirmar los conocimientos adquiridos en la materia de Programacin 1, ya que se trabaj con C#; as como las puesta en prctica de las instrucciones provistas por el tutor de esta materia en el desarrollo de pginas web en ASP.NET, debido a que son nuevos conocimientos.

Bibliografa
Scott Mitchell. (2002). ASP.NET: Tips, Tutorials, and Code. Editorial: MMS (Segunda edicin) pg. 839. G. Andrew Duthie. Matthew MacDonald (2003). ASP.NET in a Nutshell: a desktop quick reference. Editorial: OREILLY (Segundaedicin) pg. 953. Matthew MacDonald. (2009). Beginning ASP.NET 4.5 in C#. Editorial: Apress (Primera edicin) pg 867.

http://msdn.microsoft.com/es-es/library/dd483479(v=vs.100).aspx

También podría gustarte