You are on page 1of 18

SEGUNDO LABORATORIO

Implemente una página utilizando controles lista  Haz un programa que lea los siguientes datos de una persona: Nombre, sueldo mensual, edad y sexo. A continuación, el programa deberá clasificar a la persona en alguna de las siguientes categorías: a) Hombre pobre. Aquellos hombres cuyo sueldo sea inferior a 500 soles/mes. b) Mujer rica. Las mujeres cuyo sueldo supere los 6000 soles/mes. c) Joven Mujer de clase media. Mujer cuya edad esté comprendida entre los 20 y los 30 años y cuyo sueldo esté entre 1200 y 2000 soles/mes.

Es posible que una persona no entre dentro de ninguna de estas categorías. En tal caso imprime un mensaje que lo indique

Solución

Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAcepatr.Click Dim sueldo As Double Dim edad As Integer edad = txtedad.Text sueldo = txtsueldo.Text Select Case ddlSexo.Text Case "Masculino" If sueldo <= 500 Then lblresul.Text = "Hombre Pobre" Else

UI.Text = "Clase no Existe" End If Case "Femenino" Select Case sueldo Case Is >= 6000 lblresul.lblresul.Text num2 = txtN2.Text = resu .Web. ByVal e As System. resu As Decimal num1 = txtN1.Load End Sub Protected Sub btnSuma_Click(ByVal sender As Object.Text = "Clase no Existe" End If Case Else lblresul. ByVal e As EventArgs) Handles btnSuma.EventArgs) Handles Me.Text = "Clase no Existe" End Select End Select End Sub End Class  Implemente más páginas y realice diferentes acciones con manejo de controles Partial Public Class _Default Inherits System.Text = "Mujer Rica" Case 1200 To 2000 If edad > 20 And edad < 30 Then lblresul.Page Protected Sub Page_Load(ByVal sender As Object.Text resu = num1 + num2 lblresul.Click Dim num1.Text = "Joven Mujer Clase Media" Else lblresul. num2.

Text resu = num1 .Click Dim num1.Click Dim num1.Text = resu End Sub End Class .Text = resu End Sub Protected Sub btnMul_Click(ByVal sender As Object.Text resu = num1 * num2 lblresul. ByVal e As EventArgs) Handles btnMul. resu As Decimal num1 = txtN1. num2. resu As Decimal num1 = txtN1.Text num2 = txtN2.Click Dim num1.num2 lblresul. ByVal e As EventArgs) Handles btndiv.Text num2 = txtN2.Text num2 = txtN2.Text resu = num1 / num2 lblresul. num2. ByVal e As EventArgs) Handles btnRest.Text = resu End Sub Protected Sub btndiv_Click(ByVal sender As Object.End Sub Protected Sub btnRest_Click(ByVal sender As Object. num2. resu As Decimal num1 = txtN1.

TERCER LABORATORIO Respaldo INICIO Module Inicio Public Aempleado As New ArrayList End Module .

ENTIDAD EMPLEADO Public Class Entidad_Empleado Private Private Private Private Private Private _cod As Integer _datos As String _estado As String _email As String _logn As String _password As String Public Property cod() As Integer Get Return _cod End Get Set(ByVal value As Integer) _cod = value End Set End Property Public Property datos() As String Get Return _datos End Get Set(ByVal value As String) _datos = value End Set End Property Public Property estado() As String Get Return _estado End Get Set(ByVal value As String) _estado = value End Set End Property Public Property email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Property login() As String Get Return _logn End Get Set(ByVal value As String) _logn = value End Set End Property Public Property password() As String Get Return _password End Get Set(ByVal value As String) _password = value End Set End Property End Class .

ByVal e As EventArgs) Handles Button1.Count + 1 Eempleado.DataSource = Aempleado Me.Write(ex.Text If rbESTADO.UI.Text Eempleado.Text & " " .Message) End Try End Sub Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object.Load End Sub Protected Sub btnRegistrar_Click(ByVal sender As Object.login = txtLogin.Click Try Eempleado.Click Try Dim wFile As System.cod = Aempleado.GetBytes("Cod" & ":" & Aempleado.Message) End Try End Sub Protected Sub Page_Load(ByVal sender As Object.Add(Eempleado) llenarGV() Catch ex As Exception Response.SelectedIndexChanged End Sub Protected Sub Button1_Click(ByVal sender As Object.datos = txtNombre.estado = "Casado" End If Aempleado.DataBind() Catch ex As Exception Response.FileStream Dim byteData() As Byte byteData = Encoding.Write(ex.estado = "Soltero" Else Eempleado.IO.SelectedValue = "Soltero" Then Eempleado.ASCII.EventArgs) Handles Me.GridView1.password = txtPassword. ByVal e As EventArgs) Handles btnRegistrar. ByVal e As EventArgs) Handles GridView1. ByVal e As System.Web.GridView1.email = txtEmail.IO Partial Public Class _Default Inherits System.Count & "Apellido y Nombres " & ": " & txtNombre.Text Eempleado.Page Dim Eempleado As New Entidad_Empleado Sub llenarGV() Try Me.Text Eempleado.WEB FORM Imports System.

Text) wFile = New FileStream("Respaldo.Write(byteData.ToString) End Try End Sub Protected Sub btnEliminar_Click(ByVal sender As Object. 0. FileMode. ByVal e As EventArgs) Handles btnEliminar.txt".1) llenarGV() Catch ex As Exception Response. byteData.ToInt32(txtCod." & "Estado" & ": " & rbESTADO.Close() Catch ex As IOException MsgBox(ex.Click Dim FILA As Integer Try FILA = Convert.Write(ex.RemoveAt(FILA .Append) wFile.& " .Text) Aempleado.Text & " " & "Email" & ": " & txtEmail.Message) End Try End Sub End Class .Length) wFile.

.cs) cmd. ByVal parametro As String) Dim resultado As String Dim cnn As New Acceso cmd = New SqlCommand(cadena. SqlDbType.Data. cnn.2.ExecuteScalar) Then .conectar() If IsDBNull(cmd. Acceso Imports System. datos As String Dim cmd As SqlCommand Dim dr As SqlDataReader 'crear funcion para evaluar resultados Public Function validar(ByVal cadena As String. initial catalog=EXAM.VarChar).Add("@para1".Data.SqlClient Public Class acceso Private conexion As New SqlConnection("data source=.Parameters.SqlClient Module Procedimiento Public codusuario.Value = parametro cnn. integrated security=true") Public Function cs() As SqlConnection Return conexion End Function Sub conectar() conexion.Open() End Sub Sub desconectar() conexion.Close() End Sub End Class Procedimiento Imports System.

Text = "" txtUsuario.Web.Text = "" txtContraseña. sentencia As String usuario = txtUsuario. ByVal e As System.UI.Text 'creo la sentencia para evaluar si existe el usuario sentencia = "select loigin from usuario where nombre =@para1 " 'llamando la funcion validar para evaluar el usuario passwordbd = validar(sentencia. usuario) Server.State = ConnectionState.aspx") Else MsgBox("password incorrecto") txtUsuario.Text = ("Error en las 3 orportunidades") txtUsuario.Text = "" txtUsuario.Text = ("Error en las 3 orportunidades para loguearse" & vbLf & "El sistema se cerrará") End If End Sub End Class .Load End Sub Dim cont As Integer Protected Sub btnAceptar_Click(ByVal sender As Object.Click Dim usuario.Focus() cont = cont + 1 End If If cont = 3 Then lblre.Text password = txtContraseña.Focus() cont = cont + 1 End If Else lblre.ExecuteScalar End If If cnn. passwordbd.Open Then cnn.Transfer("Producto.resultado = 0 Else resultado = cmd.desconectar() End If Return resultado End Function End Module Web Form Partial Public Class _Default Inherits System. usuario) 'si devuelve resultado el usuario existe If passwordbd <> "" Then 'si existe el usuario/validar el password If password = passwordbd Then 'obtener los datos del empleado codusuario = validar("select loigin from usuario where nombre = @para1".Focus() txtContraseña. ByVal e As EventArgs) Handles btnAceptar.EventArgs) Handles Me.cs. password.Page Protected Sub Page_Load(ByVal sender As Object.

Web.Click Dim A As Integer A = txtAño.Text = "el año " + Trim(A) + " No es bisiesto" End If End Sub End Class 5.EventArgs) Handles Me.EventArgs) Handles Me.Page Protected Sub Page_Load(ByVal sender As Object.Page Protected Sub Page_Load(ByVal sender As Object.Web.Load End Sub Protected Sub btnCalcular_Click(ByVal sender As Object.4.Click Dim texto As String . ByVal e As System. Partial Public Class _Default Inherits System. ByVal e As EventArgs) Handles btnCalcular.Text = "el año " + Trim(A) + " Si es bisiesto" Else lblres.Load End Sub Protected Sub Button1_Click(ByVal sender As Object. ByVal e As EventArgs) Handles btnMostrar.UI. Public Partial Class año_bisiesto Inherits System.UI.Text If (A Mod 4 = 0 And A Mod 100 <> 0 Or A Mod 400 = 0) Then lblres. ByVal e As System.

Page Protected Sub Page_Load(ByVal sender As Object.Text = "" If TextBox1. ByVal e As EventArgs) Handles btnMostrar. I.Text = "la cadena es MAYUSCULA" End If End Sub End Class 6.Web.Text = "hola" Then Label1.Text = "Total de Caracteres: " & caracteres & " " End Sub End Class . Partial Public Class _Default Inherits System.texto = TextBox1.UI. ByVal e As System.Text) If IsNumeric(Mid(TextBox1.EventArgs) Handles Me.Text = "la cadena es minuscula" Else Label1.Load End Sub Protected Sub Button1_Click(ByVal sender As Object.Text. 1)) Then Else caracteres = caracteres + 1 End If Next Label1.Click Dim I As Integer Dim caracteres As Long For I = 1 To Len(TextBox1.

Partial Public Class _Default Inherits System.1) X = X * N Else X = 1 End If Return X End Function Protected Sub Button1_Click(ByVal sender As Object.Load End Sub Public Function factorial(ByVal X As Integer. ByVal N As Integer) If (N > 0) Then X = factorial(X.Text = Trim(X) End Sub End Class . ByVal e As System.UI.EventArgs) Handles Me.Text X = factorial(X. N) Label1. N .Click Dim X As Integer Dim N As Integer N = TextBox1.Page Protected Sub Page_Load(ByVal sender As Object.7. ByVal e As EventArgs) Handles btnMostrar.Web.

CUARTO LABORATORIO INICIO Module Inicio Public Aempleado As New ArrayList End Module .

ENTIDAD EMPLEADO Public Class Entidad_Empleado Private Private Private Private Private Private _cod As Integer _datos As String _estado As String _email As String _logn As String _password As String Public Property cod() As Integer Get Return _cod End Get Set(ByVal value As Integer) _cod = value End Set End Property Public Property datos() As String Get Return _datos End Get Set(ByVal value As String) _datos = value End Set End Property Public Property estado() As String Get Return _estado End Get Set(ByVal value As String) _estado = value End Set End Property Public Property email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Property login() As String Get Return _logn End Get Set(ByVal value As String) _logn = value End Set End Property Public Property password() As String Get Return _password End Get Set(ByVal value As String) _password = value End Set End Property End Class .

ByVal e As EventArgs) Handles btnEliminar.password = txtPassword.datos = txtNombre.Text Eempleado.cod = Aempleado.estado = "Soltero" Else Eempleado.estado = "Casado" End If Aempleado. ByVal e As EventArgs) Handles btnRegistrar.Count + 1 Eempleado.Click Dim FILA As Integer Try FILA = Convert.Add(Eempleado) llenarGV() Catch ex As Exception Response.login = txtLogin.Write(ex.IO Partial Public Class _Default Inherits System.EventArgs) Handles Me.Message) End Try End Sub Protected Sub Page_Load(ByVal sender As Object.WEB FORM Imports System. ByVal e As System.1) llenarGV() Catch ex As Exception Response. ByVal e As EventArgs) Handles GridView1.Click Try Eempleado.Text Eempleado.Web.GridView1.DataBind() Catch ex As Exception Response.Text) Aempleado.Text If rbESTADO.DataSource = Aempleado Me.Write(ex.GridView1.Message) End Try End Sub Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object.SelectedValue = "Soltero" Then Eempleado.Write(ex.Message) End Try End Sub End Class CUARTO LABORATORIO .Page Dim Eempleado As New Entidad_Empleado Sub llenarGV() Try Me.UI.SelectedIndexChanged End Sub Protected Sub btnEliminar_Click(ByVal sender As Object.ToInt32(txtCod.email = txtEmail.Load End Sub Protected Sub btnRegistrar_Click(ByVal sender As Object.Text Eempleado.RemoveAt(FILA .

QUINTO LABORATORIO 1. .

Text = reader("ProductName") txtstock.Text = ex.Integrated Security=True") conectar.ToUpper & "' where ProductID='" & txtcodigo.Text.Text.Open() Dim buscar As New String("select*from products where ProductID='" & txtcodigo.EventArgs) Handles Me.Imports System.ExecuteReader While reader.Text = "" End While reader.Page Protected Sub Page_Load(ByVal sender As Object. "Mensaje") lbl1.Close() Catch ex As Exception lbl1.Web.Enabled = True txtdescripcion.Enabled = False txtpreciou.Data.ToUpper & "'.Message End Try End Sub Protected Sub btnmodificar_Click(ByVal sender As Object.Enabled = True txtpreciou.ToUpper & "'") Dim comando As New SqlCommand(buscar.Enabled = True txtstock.Click Try Dim conectar As New SqlConnection("Data Source=ARROYOPC\SQLEXPRESS.UnitsInStock='" & txtstock.Read txtcodigo.Enabled = False txtdescripcion.Text.Enabled = True End Sub Public Sub deshabilitar() txtcodigo.ToUpper & "'") . conectar) Dim reader As SqlDataReader reader = comando.Load End Sub Public Sub habilitar() txtcodigo.Text.Enabled = False txtstock.Integrated Security=True") conectar.Text = reader("UnitPrice") habilitar() MsgBox("Busqueda satisfactoria".Enabled = False End Sub Protected Sub btnbuscar_Click(ByVal sender As Object. vbInformation. ByVal e As EventArgs) Handles btnbuscar.Initial Catalog=NORTHWND.Close() conectar.ToUpper & "'.Initial Catalog=NORTHWND.Click Try Dim conectar As New SqlConnection("Data Source=ARROYOPC\SQLEXPRESS. ByVal e As EventArgs) Handles btnmodificar.SqlClient Partial Public Class Modificar Inherits System.Open() Dim modificar As New String("update products set ProductName='" & txtdescripcion.UI.Text = reader("ProductID") txtdescripcion. ByVal e As System.Text = reader("UnitsInStock") txtpreciou.Text.UnitPrice='" & txtpreciou.

Dim comando As New SqlCommand(modificar.Text = ex. .ExecuteNonQuery() lbl2.Close() Catch ex As Exception lbl1.Message End Try End Sub End Class 2.Text = "El producto ha sido modificado correctamente" deshabilitar() conectar. conectar) comando.