SISTEMA PARA HOTEL EN VISUAL ESTUDIO 2008
Para comenzar diseñamos el formulario siguiente tal cual esta en la imagen
estos ejercicios se desarrollan en capaz, para eso uds deben crear proyectos dentro de la solucion, si no saben como agregar un proyecto. dentro de la solucion pues solo hagan clic en el menu archico y luego en agregar nuevo proyecto y eligen biblioteca de clases, le dan el nombre de Prj_Capa_Datos y asi van agregando el resto de las capas negocio y capa entidad.
no olviden relacionar las capas entre si. para hacer las referencias. le dan clic derecho en prj_capa_datos agregar referencias y en la pestaña proyectos seleccionan capa entidad y aceptar.
En la capa entidad
Public Class Cls_Alquiler
Private _Cliente As String
Private _Dni As String
Private _NroHab As String
Private _Tipo_Hab As Lista_Habitaciones
Enum Lista_Habitaciones As Byte
Simple = 0
Doble = 1
Matrimonial = 2
Imperial = 3
End Enum
'---- Creación de Vectores para las Habitaciones
Private Tipo_Simple() As String = {"0101", "0102", "0103", "0104", "0105"}
Private Tipo_Doble() As String = {"0201", "0202", "0203", "0204", "0205", "0206"}
Private Tipo_Matrimonial() As String = {"0301", "0302", "0303", "0304"}
Private Tipo_Imperial() As String = {"0305", "0401", "0402", "0403", "0404", "0405", "0406"}
'---------------------------------------------
Private _Precio As Integer
Private _Cantidad_Dias As Integer
Private _SubTotal As Double
Private Const _PorIgv As Double = 0.19
Private _Igv As Double
Private _Total As Double
'---- Creación de Propiedades
Public Property Cliente() As String
Get
Return _Cliente
End Get
Set(ByVal value As String)
_Cliente = value
End Set
End Property
Public Property Dni() As String
Get
Return _Dni
End Get
Set(ByVal value As String)
_Dni = value
End Set
End Property
Public Property NroHab() As String
Get
Return _NroHab
End Get
Set(ByVal value As String)
_NroHab = value
End Set
End Property
Public Property Cantidad() As Integer
Get
Return _Cantidad_Dias
End Get
Set(ByVal value As Integer)
_Cantidad_Dias = value
End Set
End Property
Public Property Tipo_Hab() As Lista_Habitaciones
Get
Return _Tipo_Hab
End Get
Set(ByVal value As Lista_Habitaciones)
_Tipo_Hab = value
End Set
End Property
Public ReadOnly Property Precio() As Integer
Get
Return _Precio
End Get
End Property
Public ReadOnly Property SubTotal() As Double
Get
Return _SubTotal
End Get
End Property
Public ReadOnly Property Igv() As Double
Get
Return _Igv
End Get
End Property
Public ReadOnly Property Total() As Double
Get
Return _Total
End Get
End Property
'---- Creación de Métodos de la Clase
Public Function Obt_Nro_Tipo_Hab(ByVal xTipo As _
Lista_Habitaciones) As Array
Dim xNr() As String = Tipo_Simple
Select Case xTipo
Case Lista_Habitaciones.Simple : xNr = Tipo_Simple
Case Lista_Habitaciones.Doble : xNr = Tipo_Doble
Case Lista_Habitaciones.Matrimonial : xNr = Tipo_Matrimonial
Case Lista_Habitaciones.Imperial : xNr = Tipo_Imperial
End Select
Return xNr
End Function
Public Function Obt_Precio(ByVal xTipo As Lista_Habitaciones) As Integer
Select Case xTipo
Case Lista_Habitaciones.Simple : _Precio = 15
Case Lista_Habitaciones.Doble : _Precio = 20
Case Lista_Habitaciones.Matrimonial : _Precio = 35
Case Lista_Habitaciones.Imperial : _Precio = 45
End Select
Return _Precio
End Function
Public Function Obt_SubTotal(ByVal xPrecio As Integer, _
ByVal xCant As Integer) As Double
_SubTotal = xPrecio * xCant
Return _SubTotal
End Function
Public Function Obt_Igv(ByVal xSubTotal As Double) As Double
_Igv = _SubTotal * _PorIgv
Return _Igv
End Function
Public Function Obt_TotalPago(ByVal xSubTotal As Double, _
ByVal xIgv As Double)
_Total = _SubTotal + _Igv
Return _Total
End Function
Public Sub Mostrar_Datos()
Dim Datitos As String = " ---- Factura Hostal ParaEso -----" & vbCrLf & _
" Cliente : " & _Cliente & vbCrLf & _
" Dni : " & _Dni & vbCrLf & _
" Tipo Hab : " & _Tipo_Hab.ToString & vbCrLf & _
" Nro Hab : " & _NroHab.ToString & vbCrLf & _
" Precio : " & _Precio & vbCrLf & _
" Cantidad Dias :" & _Cantidad_Dias & vbCrLf & _
" Sub Total : " & _SubTotal & vbCrLf & _
" Impuesto : " & _Igv & vbCrLf & _
" Total a Pagar : " & _Total
MsgBox(Datitos)
End Sub
End Class
En la capa cliente:
Imports Prj_Capa_Servidor
Imports Prj_Capa_Servidor.Cls_Alquiler
Public Class Frm_Alquiler
Dim xHostal As New Cls_Alquiler
Private Sub Llenar_Tipo_Habi()
Dim UnElementoEnumeracion As Cls_Alquiler.Lista_Habitaciones
For Each UnElementoEnumeracion In _
[Enum].GetValues(GetType(Cls_Alquiler.Lista_Habitaciones))
Me.Cbo_Tipo_Hab.Items.Add(UnElementoEnumeracion.ToString)
Next
End Sub
Private Sub Frm_Alquiler_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call Llenar_Tipo_Habi()
End Sub
Private Sub Cbo_Tipo_Hab_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cbo_Tipo_Hab.SelectedIndexChanged
If Cbo_Tipo_Hab.SelectedIndex = -1 Then Exit Sub
Lbl_Precio.Text = xHostal.Obt_Precio(Cbo_Tipo_Hab.SelectedIndex)
Call Llenar_Nro_Habi_Tipo(Cbo_Tipo_Hab)
End Sub
Private Sub Llenar_Nro_Habi_Tipo(ByVal cbo As ComboBox)
Cbo_Nro_Hab.Items.Clear()
Cbo_Nro_Hab.Text = ""
Cbo_Nro_Hab.Items.AddRange(xHostal.Obt_Nro_Tipo_Hab(cbo.SelectedIndex))
End Sub
Private Sub Btn_Calcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Calcular.Click
If Val(Txt_Cantidad.Text) > 0 And Cbo_Tipo_Hab.SelectedIndex > -1 Then
xHostal.Cliente = Txt_Cliente.Text
xHostal.Dni = Txt_Doc.Text
xHostal.Tipo_Hab = Cbo_Tipo_Hab.SelectedIndex
xHostal.NroHab = Cbo_Nro_Hab.Text
xHostal.Cantidad = Val(Txt_Cantidad.Text)
Lbl_SubTotal.Text = xHostal.Obt_SubTotal(xHostal.Precio, xHostal.Cantidad)
Lbl_Igv.Text = xHostal.Obt_Igv(xHostal.Obt_SubTotal(xHostal.Precio, xHostal.Cantidad))
Lbl_TotalPago.Text = xHostal.Obt_TotalPago(xHostal.Obt_SubTotal(xHostal.Precio, xHostal.Cantidad), xHostal.Obt_Igv(xHostal.Obt_SubTotal(xHostal.Precio, xHostal.Cantidad)))
End If
End Sub
Private Sub Btn_Nuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Nuevo.Click
Txt_Cliente.Text = ""
Txt_Doc.Text = ""
Txt_Cantidad.Text = ""
Cbo_Nro_Hab.SelectedIndex = -1
Cbo_Tipo_Hab.SelectedIndex = -1
Lbl_Precio.Text = ""
Lbl_Igv.Text = ""
Lbl_SubTotal.Text = ""
Lbl_TotalPago.Text = ""
End Sub
Private Sub Btn_Salida_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Salida.Click
End
End Sub
Private Sub Btn_Factura_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Factura.Click
If Val(Lbl_TotalPago.Text) > 0 Then
xHostal.Mostrar_Datos()
End If
End Sub
End Class
____________________________________________________-

