You are on page 1of 30

Publicacin aplicaciones web en la nube

PUBLICACIN DE APLICACIONES WEB EN LA NUBE


1. En el explorador web (Google, Internet Explores, etc) acceder a la direccin electrnica

www.myasp.net.com

2. Ingresar su nombre de cuenta y password.

Ing. Javier Alberto Manrique Quionez


1

Publicacin aplicaciones web en la nube

3. Hacer clic en en (v) para desplegar las opciones de My Websites y visualizar la configuracin
de la cuenta. Luego, vuelva a enrrollar las opciones de My Websites.

4. Hacer clic en la opcin Database Manager.

Ing. Javier Alberto Manrique Quionez


2

Publicacin aplicaciones web en la nube

5. Hacer clic en el botn de comando +Add Database (Agregar Base de datos).

6. Verificar que se presente el siguiente Formulario Web del MSSQL Manager.

Ing. Javier Alberto Manrique Quionez


3

Publicacin aplicaciones web en la nube

7. Seleccionar Type Database (tipo de base de datos), Database Name (nombre de la


base de datos), Database Password (Password de la base de datos) y Database Disk
Quota (Tamao de la base de datos).

8. Verificar que el Database Manager se visualice como en la siguiente figura. Se ha creado la


base de datos DB..Evento en el servidor SQL5008.myASP.NET.

Ing. Javier Alberto Manrique Quionez


4

Publicacin aplicaciones web en la nube

9. Hacer botn en el hipervnculo Connection String.

9. Verificar la cadena de conexin. Esta cadena se utilizar en el desarrollo del archivo


de configuracin de la Aplicacin Web con ASP.net.
Ing. Javier Alberto Manrique Quionez
5

Publicacin aplicaciones web en la nube

10.

Hacer clic en el vnculo Webconnect.

11. Ingresar el Password para conectarse con la base de datos y luego hacer clic en el
botn de comando Connect.
Ing. Javier Alberto Manrique Quionez
6

Publicacin aplicaciones web en la nube

12.

Verificar que se ha realizado la conexin.

13.

Hacer clic en la opcin Run Query (Ejecutar consulta).

Ing. Javier Alberto Manrique Quionez


7

Publicacin aplicaciones web en la nube

14. En el Formulario Run Query digitar el script SQL para crear las tablas de base de
datos.

Ing. Javier Alberto Manrique Quionez


8

Publicacin aplicaciones web en la nube

15. Hacer clic en el botn de comando Submit y verificar que los comandos se hayan
ejecutado satisfactoriamente..

Nota: Hasta aqu ya se ha creado la base de datos DB_9CB63E_Evento, la tabla Evento y la


clave primaria PK_Evento.

16. Verificar que la tabla Evento se haya creado. Haga doble clic en la tabla Evento para
verificar la creacin de su estructura.

Ing. Javier Alberto Manrique Quionez


9

Publicacin aplicaciones web en la nube

17. Verificar que la tabla Evento presente la estructura segn el Script ejecutado. Cierre los
Formularios Web abiertos y termine la Sesin en el MyASP.net. Finalmente cerrar la
Pestaa https://mssql.myasp.net/default.asp del Explotrador Windows.

18. Hacer clic en My Websites y site1 para verificar la configuracin de la cuenta


en MyASP.NET. Finalmente termine la Sesin en el MyASP.NET.

Ing. Javier Alberto Manrique Quionez


10

Publicacin aplicaciones web en la nube

16. Crear un proyecto en el VS 2013.

Ing. Javier Alberto Manrique Quionez


11

Publicacin aplicaciones web en la nube

17.

Seleccionar Visual C# - Web - Visual Studio 2012 y luego dentro de las


platillas seleccionar Aplicacin web vaca de ASP.NET Visual C#. Dar como
nombre

18.

SolucinGestinDeEventos.

Verificar verificarla creacin del proyecto.

Ing. Javier Alberto Manrique Quionez


12

Publicacin aplicaciones web en la nube

19.

20.

Agregar una clase.

Asignar como nombre de clase AdministradorDeConexin.cs.

Ing. Javier Alberto Manrique Quionez


13

Publicacin aplicaciones web en la nube

21.

Digitar el cdigo siguiente.


using System.Configuration;
using System.Data.SqlClient;
namespace WebApplicationServicioWeb
{ public class AdministradorDeConexion
{ public static SqlConnection getConexion()
{ SqlConnection conexion =

new
SqlConnection(ConfigurationManager.ConnectionStrings["DbEventoConnectionString"].ConnectionString);

try
{ return conexion;
}
catch (SqlException e)
{ return null;
}
}
}
}

22.

Crear una clase denominada Evento.cs y agregar el siguiente cdigo.

Ing. Javier Alberto Manrique Quionez


14

Publicacin aplicaciones web en la nube

23.
Crear una clase denominada EventoDAO.cs y digitar el siguiente cdigo del mtodo
esttico insertarRegistro.
Ing. Javier Alberto Manrique Quionez
15

Publicacin aplicaciones web en la nube

24.

Completar el cdigo de la clase EventoDAO.cs tal como se presenta a continuacin.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace WebApplicationGestionDeEventos
{public class EventoDAO
{ public static Boolean insertarRegistro(Evento oEvento)
{ SqlConnection oSqlConnection = new SqlConnection();
try
{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
String sentencia = "INSERT INTO Evento(idEvento, nombreDelEvento,fechaDelEvento) VALUES("
+
oEvento.idEvento + ",'" +
oEvento.nombreDelEvento + "'," +
oEvento.fechaDelEvento + ")";
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
oSqlCommand.ExecuteNonQuery();
oSqlConnection.Close();
return true;
}
catch (System.Exception e)
{ oSqlConnection.Close();
return false;
}
}
public static Boolean eliminarRegistro(Evento oEvento)
{ SqlConnection oSqlConnection = new SqlConnection();
try

Ing. Javier Alberto Manrique Quionez


16

Publicacin aplicaciones web en la nube

{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
string sentencia = "DELETE FROM Evento WHERE idEvento =" + oEvento.idEvento;
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
oSqlCommand.ExecuteNonQuery();
oSqlConnection.Close();
return true;
}
catch (System.Exception e)
{
oSqlConnection.Close();
return false;
}

public static Evento consultarRegistro(Evento oEvento)


{ SqlConnection oSqlConnection = new SqlConnection();
try
{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
string sentencia = "SELECT * FROM Evento WHERE idEvento =" + oEvento.idEvento;
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
SqlDataReader oSqlDataReader = oSqlCommand.ExecuteReader();
if (oSqlDataReader.Read())
{ Evento oEventoTemporal = new Evento();
oEvento.idEvento
= ((int) oSqlDataReader["idEvento"]);
oEvento.nombreDelEvento = (string) (oSqlDataReader["nombreDelEvento"].ToString());
oEvento.fechaDelEvento =
oSqlDataReader["fechaDelEvento"].ToString();
oSqlDataReader.Close();
return oEventoTemporal;
}
else
{
return null;
}

}
catch (System.Exception e)
{ oSqlConnection.Close();
return null;
}
}
public static Boolean modificarRegistro(Evento oEvento)
{ SqlConnection oSqlConnection = new SqlConnection();
try
{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
string sentencia = "UPDATE Evento SET nombreDelEvento
='"+oEvento.nombreDelEvento.Trim() + "'," +
"fechaDelEvento ='"+oEvento.fechaDelEvento.Trim() +
" WHERE idEvento =" + oEvento.idEvento;
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
oSqlCommand.ExecuteNonQuery();
oSqlConnection.Close();
return true;
}
catch (System.Exception e)
{ oSqlConnection.Close();
return false;
}
}

Ing. Javier Alberto Manrique Quionez


17

Publicacin aplicaciones web en la nube


public static int buscarRegistro(Evento oEvento)
{ SqlConnection oSqlConnection = new SqlConnection();
Evento oEventoTemporal = new Evento();
try
{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
String sentencia = "SELECT * FROM Evento WHERE idEvento=" + oEvento.idEvento;
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
SqlDataReader oSqlDataReader = oSqlCommand.ExecuteReader();
if (oSqlDataReader.Read())
{ oEvento.idEvento
= ((int) oSqlDataReader["idEvento"]);
oEvento.nombreDelEvento = ((String) oSqlDataReader["nombreDelEvento"]);
oEvento.fechaDelEvento
= ((String) oSqlDataReader["fechaDeEvento"]);
oSqlDataReader.Close();
oSqlConnection.Close();
return oEventoTemporal.idEvento;
}
return -99;

}
catch (System.Exception e)
{ oSqlConnection.Close();
return -99;
}

public static List<Evento> obtenerDatosEnList()


{ SqlConnection oSqlConnection = new SqlConnection();
List<Evento> oListEvento = new List<Evento>();
try
{ oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
String sentencia = "SELECT * FROM Evento ";
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
SqlDataReader oSqlDataReader = oSqlCommand.ExecuteReader();
Evento oEvento;
while (oSqlDataReader.Read())
{ oEvento = new Evento();
oEvento.idEvento
= ((int) oSqlDataReader["idEvento"]);
oEvento.nombreDelEvento = ((String) oSqlDataReader["nombreDelEvento"]);
oEvento.fechaDelEvento
= ((String) oSqlDataReader["fechaDelEvento"]);
oListEvento.Add(oEvento);
}
oSqlDataReader.Close();
oSqlConnection.Close();
return oListEvento;
}
catch (System.Exception e)
{ oSqlConnection.Close();
return null;
}
}
public static DataTable GetEvento()
{ SqlConnection oSqlConnection = AdministradorDeConexion.getConexion();
oSqlConnection.Open();
string sentencia = "SELECT * FROM Evento";
SqlCommand oSqlCommand = new SqlCommand(sentencia, oSqlConnection);
SqlDataAdapter oSqlDataAdapter = new SqlDataAdapter(oSqlCommand);
DataTable oDataTable = new DataTable();
oSqlDataAdapter.Fill(oDataTable);

Ing. Javier Alberto Manrique Quionez


18

Publicacin aplicaciones web en la nube


oSqlConnection.Close();
return oDataTable;
}

}
25.

Agregar un formulario Web Form.

26.

Especificar el nombre para el elemento: WebFormEventoABCM.aspx

27.

Verificar que el Explorador de soluciones presente el Formulario Web creado.

Ing. Javier Alberto Manrique Quionez


19

Publicacin aplicaciones web en la nube

28.

Agregar el siguiente cdigo en WebFormEventoABCM.aspx

29.

Completar el cdigo en WebFormEventoABCM.aspx.

Ing. Javier Alberto Manrique Quionez


20

Publicacin aplicaciones web en la nube


<%@ Page Language="C#"
AutoEventWireup="true"
CodeBehind="WebFormEventoABCM.aspx.cs"
Inherits="WebApplicationGestionDeEventos.WebFormABCM" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Evento
</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="LabelTitulo" runat="server" Text="Insertar Evento"></asp:Label>
<br />
<asp:Label ID="LabelIdEvento" runat="server" Text="idEvento : "></asp:Label>
<asp:TextBox ID="TextBoxIdEvento" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LabelNombreDelEvento" runat="server" Text="nombreDelEvento :
"></asp:Label>
<asp:TextBox ID="TextBoxNombreDelEvento" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LabelFechaDelEvento" runat="server" Text="fechaDelEvento : "></asp:Label>
<asp:TextBox ID="TextBoxFechaDelEvento" runat="server"></asp:TextBox>
<br />
<asp:Button
ID
="ButtonInsertarRegistro" runat="server" Text="InsertarRegistro"
OnClick="ButtonInsertarRegistro_Click" />
<br/>
<br/>
<table>
<tr>
<td>
<asp:GridView
ID="GridViewEvento"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="idEvento"
OnRowEditing="GridViewEvento_RowEditing"
OnRowCancelingEdit="GridViewEvento_RowCancelingEdit"
OnRowUpdating="GridViewEvento_RowUpdating"
OnRowDeleting="GridViewEvento_RowDeleting">
<Columns>
<asp:TemplateField HeaderText="idEvento">
<EditItemTemplate>
<asp:TextBox ID="TextBoxIdEvento"
runat="server" ReadOnly="true"
Text='<%#Bind("idEvento")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelIdEvento"
runat="server"
Text='<%#Bind("idEvento")%>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="nombreDelEvento">
<EditItemTemplate>
<asp:TextBox ID="TextBoxNombreDelEvento"
runat="server"
Text='<%#Bind("nombreDelEvento")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID
="LabelNombreDelEvento" runat="server"
Text ='<%#Bind("nombreDelEvento")%>'></asp:Label>

Ing. Javier Alberto Manrique Quionez


21

Publicacin aplicaciones web en la nube


</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="fechaDelEvento">
<EditItemTemplate>
<asp:TextBox ID ="TextBoxFechaDelEvento" runat="server"
Text='<%#Bind("fechaDelEvento")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelfechaDelEvento" runat="server" Text='<
%#Bind("fechaDelEvento")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</form>
</body>
</html>
30.

Hacer clic en la pestaa Diseo para visualizar el diseo del Formulario Web.

31.

Pulsar las teclas Function + F7 para ingresar el cdigo de la pgina web.

Ing. Javier Alberto Manrique Quionez


22

Publicacin aplicaciones web en la nube

32.

Digitar el siguiente cdigo para completar

using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplicationGestionDeEventos
{ public partial class WebFormABCM : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{ if (!Page.IsPostBack)
{ LLenar_Grilla();
}
}
public void LLenar_Grilla()
{ DataTable oDataTable = new DataTable();
oDataTable = EventoDAO.GetEvento();
GridViewEvento.DataSource = oDataTable;
GridViewEvento.DataBind();
}
protected void GridViewEvento_RowEditing(object sender, GridViewEditEventArgs e)
{ try
{ GridViewEvento.EditIndex = e.NewEditIndex;
LLenar_Grilla();
}
catch (Exception)
{ throw;
}
}
protected void GridViewEvento_RowCancelingEdit(object sender,
GridViewCancelEditEventArgs e)
{ try
Ing. Javier Alberto Manrique Quionez
23

Publicacin aplicaciones web en la nube

{ GridViewEvento.EditIndex = -1;
LLenar_Grilla();
}
catch (Exception)
{
throw;
}
}
protected void GridViewEvento_RowUpdating(object sender, GridViewUpdateEventArgs
e)
{ try
{ Evento oEvento = new Evento();
TextBox oTextBox = new TextBox();
oTextBox =
(TextBox)GridViewEvento.Rows[e.RowIndex].FindControl("TextBoxIdEvento");
oEvento.idEvento = Convert.ToInt32(oTextBox.Text);
oTextBox =
(TextBox)GridViewEvento.Rows[e.RowIndex].FindControl("TextBoxNombreDelEvento");
oEvento.nombreDelEvento = oTextBox.Text;
oTextBox =
(TextBox)GridViewEvento.Rows[e.RowIndex].FindControl("TextBoxFechaDelEvento");
oEvento.fechaDelEvento = oTextBox.Text.Substring(0, 10);
bool resultado = EventoDAO.modificarRegistro(oEvento);
GridViewEvento.EditIndex = -1;
LLenar_Grilla();
}
catch (Exception)
{ throw;
}
}
protected void GridViewEvento_RowDeleting(object sender, GridViewDeleteEventArgs e)
{ Evento oEvento = new Evento();
oEvento.idEvento =
Convert.ToInt32(GridViewEvento.DataKeys[e.RowIndex].Values["idEvento"].ToString());
bool resultado = EventoDAO.eliminarRegistro(oEvento);
GridViewEvento.EditIndex = -1;
LLenar_Grilla();
}
protected void ButtonInsertarRegistro_Click(object sender, EventArgs e)
{
Evento oEvento = new Evento();
oEvento.idEvento = Int32.Parse(TextBoxIdEvento.Text);
oEvento.nombreDelEvento = TextBoxNombreDelEvento.Text;
oEvento.fechaDelEvento = TextBoxFechaDelEvento.Text;
bool resultado = EventoDAO.insertarRegistro(oEvento);
LLenar_Grilla();
}
}
}
Ing. Javier Alberto Manrique Quionez
24

Publicacin aplicaciones web en la nube

33.

Hacer doble clic en el objeto Web.config para modificar la configuracin.

34.

Modificar el cdigo del objeto Web.config como se presenta a continuacin.

<?xml version="1.0"?>
<!-Para obtener ms informacin sobre cmo configurar la aplicacin de ASP.NET, visite
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name
= "DbEventoConnectionString"
connectionString = "Data Source
= SQL5016.myASP.NET;
Initial Catalog = DB_9CB63E_Evento;
User Id
= DB_9CB63E_Primera_admin;
Password
= jamq12345;"
providerName
= "System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>

Ing. Javier Alberto Manrique Quionez


25

Publicacin aplicaciones web en la nube


</configuration>

35. Hacer clic derecho en WebApplicationGestinDeEventos y seleccionar Publicar.

Ing. Javier Alberto Manrique Quionez


26

Publicacin aplicaciones web en la nube

36. En Publicacin Web, seleccione Personalizado.

37. En Perfil personalizado nuevo escriba


PerfilPublicacinEnLaNubeConBaseDeDatos.

Ing. Javier Alberto Manrique Quionez


27

Publicacin aplicaciones web en la nube

38.

39.

Hacer clic derecho en WebApplicationGestinDeEventos y seleccionar


Publicar. Ingresar los datos solicitados. Los datos solicitados tienen que estar
sincronizados con la cuenta en el Hosting myASP.NET. Luego hacer clic en el
botn de comando Siguiente.

Configurar la publicacin. Luego hacer clic en el botn de comando Siguiente.

Ing. Javier Alberto Manrique Quionez


28

Publicacin aplicaciones web en la nube

40.

En el Formulario Vista Previa hacer cli en el botn Publicar.

41. Verifivcar en la ventana Actividad de publicacin web que el sitio se ha


publicado correctamente.

42.

Ejecutar el el Explorador web la pgina creada:


http://jmanriqueq02-001-site1.myasp.net/WebFormEventoABCM.aspx

Ing. Javier Alberto Manrique Quionez


29

Publicacin aplicaciones web en la nube

Ing. Javier Alberto Manrique Quionez


30

You might also like