Sei sulla pagina 1di 41

“AÑO DEL BUEN SERVICIO AL CIUDADANO”

INSTITUTO DE EDUCACION SUPERIOR


PRIVADO
INFOTRONIC

“SISTEMA DE CONTROL DE ALQUILERES DE PRENDAS PARA


LA SASTRERIA MORALES”

PRESENTADO POR:
Nino Morales Castillo

PARA OBTENER EL TITULO PROFESIONAL EN TECNICO DE


COMPUTACION E INFORMATICA

HUARAZ - ANCASH

1
DEDICO:

A mis profesores, a mis padres y a Dios


por esta oportunidad que me dan de
presentar este proyecto de sistemas para
poder obtener mi título profesional

2
INTRODUCCION

El presente proyecto se trata sobre un sistema


de control de alquileres de prendas de vestir para la
Sastrería Morales con lo cual se optimizará la rapidez y
atención a los clientes.
Este proyecto beneficiará a la Sastrería Morales, la cual
es una pequeña empresa que se dedica a la confección,
venta y alquiler de prendas de vestir; en este caso este
sistema se centrará en la optimización de los alquileres
y su respectivo registro. En la actualidad los
trabajadores de la sastrería utilizan métodos arcaicos
para registrar los alquileres, anotan todo en cuadernos y
libretas que son inseguros porque podrían perderse o
modificarse fácilmente, por lo cual se ve la necesidad de
crear un sistema que sea seguro y sencillo para evitar los
problemas ya mencionados
Para la realización de este proyecto se adaptará la base
de datos “dbventas”, realizada en el programa Sql
Server y el programa Visual Basic para realizar la
interfaz de usuario que permitirá manejar el sistema a
todos los trabajadores.

3
INDICE

Introducción Pag. 3
Indice Pag .4
1. DIAGNOSTICO Y JUSTIFICACION Pag. 5
1.1 Diagnóstico Pag. 5
1.2 Justificación Pag. 5
2. OBJETIVOS Pag. 5
2.1 Objetivo general Pag. 6
2.2 Objetivo específico Pag. 6
3. DESCRIPCION DEL PROYECTO Pag. 6
3.1 Modelo de datos Pag. 6
3.2 Diseño de datos Pag. 6
3.3 Formularios Pag. 7
3.3.1 Login Pag. 7
3.3.2 Formulario Inicio Pag. 8
3.3.3 Formulario Categorías Pag. 11
3.3.4 Formulario Prendas Pag. 15
3.3.5 Formulario Clientes Pag. 22
3.3.6 Formulario Alquileres Pag. 28
3.3.7 Formulario Detalle de Alquiler Pag. 33
3.3.8 Formulario Recibo Pag. 39
3.3.9 Formulario Reporte de Prendas Pag. 40
4. UBICACION Pag. 41
5. ORGANO O INSTITUCION RESPONSABLE Pag. 41
6. BENEFICIARIOS Pag. 41
6.1 Beneficiario Directo Pag. 41
6.2 Beneficiarion Indirecto Pag. 41
7. Metas y Resultados Pag. 41
8. Efectos esperados Pag. 41

4
1. DIAGNOSTICO Y JUSTIFICACION

1.1. DIAGNOSTICO
La Sastrería “Morales” en estos momentos se encuentra desactualizada
en lo que son los modernos sistemas de atención al cliente, fue creada
en los años 70 y hasta el momento se siguen usando los mismos
métodos de aquél tiempo. Al momento de alquilar una prenda el sastre
utiliza cuadernos y libretas para anotar los datos del cliente, además
de las características de la prenda y las fechas de alquiler y devolución;
estos registros estan susceptibles a perderse o modificarse fácilmente,
por lo que es urgente desechar estos métodos antiguos e implementar
un moderno sistema de registro automatizado para optimizar el
proceso de alquiler y devolución de la prenda.

1.2. JUSTIFICACION:
Como integrante de la familia propietaria de esta Sastrería, durante
toda mi vida he visto como se han realizado los procesos de alquileres
en el establecimiento, por lo que estoy bastante familiarizado con esto
y me doy cuenta de la necesidad que existe ahora de tener un mejor
método de registro. Siempre ha habido problemas a la hora de alquilar
las prendas, algunas veces las personas querían tal prenda pero el
trabajador no estaba seguro si es que la tenían y se perdía tiempo en
la búsqueda, en otras ocasiones las personas devolvían una prenda
después de mucho tiempo y se hacía tedioso buscar el registro del
momento en que se le alquiló, otro problema es que la letra del
trabajador que anotaba el alquiler no se entendía y se le tenía que
consultar a él mismo sobre que había puesto. Para evitar estos y otros
problemas es que realizo este sistema.

5
2. OBJETIVOS:
2.1. Objetivo General

Optimizar el control y registro de alquileres en la Sastrería “Morales”.

2.2. OBJETIVOS ESPECIFICOS:

Mejorar la rapidez en la atención a los clientes.

3. DESCRIPCION DEL PROYECTO


3.1 Modelo de datos
El modelo de datos utilizado es entidad – relación

CATEGORIAS CLIENTE
(1, n) (1, n)

(1, 1)
(1, 1)
(1, n) (1, 1)
(1, 1) (n, 1)
DETALLE_ALQUILER ALQUILER
PRENDAS

3.2 Diseño de datos


El diseño hecho con el programa Erwin

Cliente
Categorías IdCliente
IdCategoria DNI
Nombres
Nombre_Categoría
Apellidos
Dirección
Teléfono

Prendas
IdPrenda
IdCategoria (FK) Detalle_Alquiler Alquiler

Nombre_Prenda IdDetalle_Alquiler IdAlquiler


Talla_Prenda IdPrenda (FK) IdCliente (FK)
Tela IdAlquiler (FK)
IdCliente (FK) Fecha_Alquiler
Color Fecha_devolucion
Precio IdCategoria (FK)
Num_recibo
Num_Usos Precio_total
Stock Cantidad

6
3.3. Formularios
Para elaborar este sistema se hizo uso de varios formularios en
Visual Basic para poder realizar las operaciones como registro de
prendas, datos del cliente, elección de prendas a alquilar, etc.

3.3.1 Login: Con este formulario se da seguridad al sistema


con un usuario y contraseña.

Public Class frmlogin

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
lblhora.Text = TimeOfDay
End Sub

Private Sub frmlogin_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
lblhora.Text = TimeOfDay
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
End
End Sub

Private Sub btningresar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btningresar.Click
Try
Dim dts As New vusuario
Dim func As New fusuario

dts.glogin = txtlogin.Text
dts.gpassword = txtpassword.Text

If func.validar_usuario(dts) = True Then


frminicio.Show()
Me.Hide()
Else
7
MsgBox("Ingrese nuevamente sus datos correctos",
MsgBoxStyle.Information, "Accesos denegado al sistema")
txtpassword.Clear()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class

3.3.2 Formulario Inicio: Aquí se puede observar todas las


entradas disponibles en el sistema, como son el registro
de clientes y de prendas, listado de alquileres, etc.

En la pestaña Ingresos están los formularios de categoría de prendas


y registro de prendas.

El código es el siguiente:

Imports System.Windows.Forms

8
Public Class frminicio

Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles


NewToolStripButton.Click, NewWindowToolStripMenuItem.Click
Dim ChildForm As New System.Windows.Forms.Form
ChildForm.MdiParent = Me

m_ChildFormNumber += 1
ChildForm.Text = "Ventana " & m_ChildFormNumber

ChildForm.Show()
End Sub

Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles


OpenToolStripButton.Click
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Archivos de texto (*.txt)|*.txt|Todos los
archivos (*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK)
Then
Dim FileName As String = OpenFileDialog.FileName
End If
End Sub

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs)
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Archivos de texto (*.txt)|*.txt|Todos los
archivos (*.*)|*.*"

If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK)
Then
Dim FileName As String = SaveFileDialog.FileName
End If
End Sub

Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs)
Me.Close()
End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs)
End Sub

Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs)
End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs)
End Sub

Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs) Handles ToolBarToolStripMenuItem.Click
Me.ToolStrip.Visible = Me.ToolBarToolStripMenuItem.Checked
End Sub

9
Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e
As EventArgs) Handles StatusBarToolStripMenuItem.Click
Me.StatusStrip.Visible = Me.StatusBarToolStripMenuItem.Checked
End Sub

Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As


EventArgs) Handles CascadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub

Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal


e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub

Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object,


ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub

Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal


e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub

Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e


As EventArgs) Handles CloseAllToolStripMenuItem.Click
For Each ChildForm As Form In Me.MdiChildren
ChildForm.Close()
Next
End Sub

Private m_ChildFormNumber As Integer

Private Sub CategoriaToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles CategoriaToolStripMenuItem.Click
frmcategorias.MdiParent = Me
frmcategorias.Show()

End Sub

Private Sub PrendasToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles PrendasToolStripMenuItem.Click
frmprendas.MdiParent = Me
frmprendas.Show()

End Sub

Private Sub RegistroDeVentasToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
RegistroDeVentasToolStripMenuItem.Click
frmalquiler.MdiParent = Me
frmalquiler.Show()
End Sub
Private Sub ClientesToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ClientesToolStripMenuItem.Click
frmcliente.MdiParent = Me
frmcliente.Show()
End Sub

Private Sub ReporteDeProductoToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ReporteDeProductoToolStripMenuItem.Click
frmreporteprendas.MdiParent = Me
10
frmreporteprendas.Show()
End Sub
End Class

3.3.3 Formulario Categorías: Se realiza el registro de


categorías de las diversas prendas que se alquilan y
estos se usan después al registrar las prendas.

Public Class frmcategorias


Private dt As New DataTable

Private Sub frmcategoria_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
mostrar()
End Sub

Public Sub limpiar()


btnguardar.Visible = True
btneditar.Visible = False
txtnombre.Text = ""
txtidcategoría.Text = ""
End Sub

Private Sub mostrar()


Try
Dim func As New fcategoria
dt = func.mostrar
datalistado.Columns.Item("Eliminar").Visible = False

If dt.Rows.Count <> 0 Then


datalistado.DataSource = dt
txtbuscar.Enabled = True
datalistado.ColumnHeadersVisible = True
inexistente.Visible = False
Else
datalistado.DataSource = Nothing

11
txtbuscar.Enabled = False
datalistado.ColumnHeadersVisible = False
inexistente.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try
btnnuevo.Visible = True
btneditar.Visible = False

buscar()
End Sub

Private Sub buscar()


Try
Dim ds As New DataSet
ds.Tables.Add(dt.Copy)
Dim dv As New DataView(ds.Tables(0))

dv.RowFilter = cbocampo.Text & " like '" & txtbuscar.Text & "%'"

If dv.Count <> 0 Then


inexistente.Visible = False
datalistado.DataSource = dv
ocultar_columnas()

Else
inexistente.Visible = True
datalistado.DataSource = Nothing
End If

Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub

Private Sub ocultar_columnas()


datalistado.Columns(1).Visible = False
End Sub

Private Sub txtnombre_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtnombre.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese el nombre de la categoría
porfavor, este datos es obligatorio")
End If
End Sub

Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnnuevo.Click
limpiar()
mostrar()

End Sub

Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnguardar.Click
12
If Me.ValidateChildren = True And txtnombre.Text <> "" Then
Try
Dim dts As New vcategoria
Dim func As New fcategoria

dts.gnombre_categoria = txtnombre.Text

If func.insertar(dts) Then
MessageBox.Show("categoría registrada correctamente",
"Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("categoría no fue registrada intente de
nuevo", "Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub datalistado_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles datalistado.CellClick
txtidcategoría.Text = datalistado.SelectedCells.Item(1).Value
txtnombre.Text = datalistado.SelectedCells.Item(2).Value
btneditar.Visible = True
btnguardar.Visible = False
End Sub

Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellContentClick
If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
Dim chkcell As DataGridViewCheckBoxCell =
Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
chkcell.Value = Not chkcell.Value
End If
End Sub

Private Sub btneditar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneditar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea editar los datos de la


categoría?", "Modificando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then

If Me.ValidateChildren = True And txtnombre.Text <> "" And


txtidcategoría.Text <> "" Then
Try
Dim dts As New vcategoria
Dim func As New fcategoria

dts.gidcategoria = txtidcategoría.Text
13
dts.gnombre_categoria = txtnombre.Text

If func.editar(dts) Then
MessageBox.Show("Categoría Modificada correctamente",
"Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("Categoría no fue modifcada intente de
nuevo", "Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Modificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub

Private Sub cbeliminar_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cbeliminar.CheckedChanged
If cbeliminar.CheckState = CheckState.Checked Then
datalistado.Columns.Item("Eliminar").Visible = True
Else
datalistado.Columns.Item("Eliminar").Visible = False
End If
End Sub
Private Sub btneliminar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btneliminar.Click
Dim result As DialogResult
result = MessageBox.Show("Realmente desea eliminar las categorías
seleccionadas?", "Eliminando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)
If result = DialogResult.OK Then
Try
For Each row As DataGridViewRow In datalistado.Rows
Dim marcado As Boolean =
Convert.ToBoolean(row.Cells("Eliminar").Value)
If marcado Then
Dim onekey As Integer =
Convert.ToInt32(row.Cells("idcategoría").Value)
Dim vdb As New vcategoria
Dim func As New fcategoria
vdb.gidcategoria = onekey

If func.eliminar(vdb) Then
Else
MessageBox.Show("Categoría no fue eliminada",
"Eliminando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
End If
End If
Next
Call mostrar()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Cancelando eliminación de registros", "Eliminando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
14
Call mostrar()
End If
Call limpiar()
End Sub
Private Sub datalistado_CellDoubleClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellDoubleClick
If txtflag.Text = "1" Then
frmprendas.txtidcategoria.Text =
datalistado.SelectedCells.Item(1).Value
frmprendas.txtnom_categoria.Text =
datalistado.SelectedCells.Item(2).Value
Me.Close()
End If
End Sub
Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtbuscar.TextChanged
buscar()
End Sub
End Class

3.3.4 Formulario Prendas: Aquí se hace el registro de las


prendas de acuerdo a sus categorías, a la vez se
almacenan los datos de la prenda, en este caso se
considera la talla, calidad de tela, color de prenda,
estado de prenda y stock disponible.

15
Public Class frmprendas
Private dt As New DataTable

Private Sub frmprendas_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
mostrar()
End Sub

Public Sub limpiar()


btnguardar.Visible = True
btneditar.Visible = False
txtnombre_prenda.Text = ""
cbxtalla.SelectedIndex = -1
cbxcalidad.SelectedIndex = -1
txtcolor.Text = ""
txtprecio.Text = "0"
txtnum_usos.Text = "0"
txtstock.Text = "0"
End Sub

Private Sub mostrar()


Try
Dim func As New fprenda
dt = func.mostrar
datalistado.Columns.Item("Eliminar").Visible = False

If dt.Rows.Count <> 0 Then


datalistado.DataSource = dt
txtbuscar.Enabled = True
datalistado.ColumnHeadersVisible = True
inexistente.Visible = False
Else
datalistado.DataSource = Nothing
txtbuscar.Enabled = False
datalistado.ColumnHeadersVisible = False
inexistente.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try
btnnuevo.Visible = True
btneditar.Visible = False

buscar()
End Sub

Private Sub buscar()


Try
Dim ds As New DataSet
ds.Tables.Add(dt.Copy)
Dim dv As New DataView(ds.Tables(0))

dv.RowFilter = cbocampo.Text & " like '" & txtbuscar.Text & "%'"

If dv.Count <> 0 Then


inexistente.Visible = False
datalistado.DataSource = dv
ocultar_columnas()

Else
inexistente.Visible = True
datalistado.DataSource = Nothing
End If
16
Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub

Private Sub ocultar_columnas()


datalistado.Columns(1).Visible = False
datalistado.Columns(2).Visible = False
End Sub

Private Sub txtnombre_prenda_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtnombre_prenda.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese el nombre de la prenda por
favor, este datos es obligatorio")
End If
End Sub

Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnnuevo.Click
limpiar()
mostrar()

End Sub

Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnguardar.Click
If Me.ValidateChildren = True And txtnombre_prenda.Text <> "" And
txtcolor.Text <> "" And txtprecio.Text <> "" And txtstock.Text <> "" And
txtestado.Text <> "" Then
Try
Dim dts As New vprenda
Dim func As New fprenda

dts.gnombre_prenda = txtnombre_prenda.Text
dts.gidcategoria = txtidcategoria.Text
dts.gtalla_prenda = cbxtalla.Text
dts.gtela = cbxcalidad.Text
dts.gcolor = txtcolor.Text
dts.gprecio = txtprecio.Text
dts.gnum_usos = txtnum_usos.Text
dts.gstock = txtstock.Text
dts.gestado = txtestado.Text

If func.insertar(dts) Then
MessageBox.Show("Prenda registrada correctamente", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("La prenda no se pudo registrar intente de
nuevo", "Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
17
Else
MessageBox.Show("Falta ingresar algunos datos", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub datalistado_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles datalistado.CellClick
txtidprenda.Text = datalistado.SelectedCells.Item(1).Value
txtidcategoria.Text = datalistado.SelectedCells.Item(2).Value
txtnom_categoria.Text = datalistado.SelectedCells.Item(3).Value
txtnombre_prenda.Text = datalistado.SelectedCells.Item(4).Value
cbxtalla.Text = datalistado.SelectedCells.Item(5).Value
cbxcalidad.Text = datalistado.SelectedCells.Item(6).Value
txtcolor.Text = datalistado.SelectedCells.Item(7).Value
txtprecio.Text = datalistado.SelectedCells.Item(8).Value
txtnum_usos.Text = datalistado.SelectedCells.Item(9).Value
txtstock.Text = datalistado.SelectedCells.Item(10).Value
txtestado.Text = datalistado.SelectedCells.Item(11).Value

btneditar.Visible = True
btnguardar.Visible = False
End Sub

Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellContentClick
If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
Dim chkcell As DataGridViewCheckBoxCell =
Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
chkcell.Value = Not chkcell.Value
End If
End Sub

Private Sub btneditar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneditar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea editar los datos de la


prenda?", "Modificando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then

If Me.ValidateChildren = True And txtnombre_prenda.Text <> "" And


txtcolor.Text <> "" And txtprecio.Text <> "" And txtnum_usos.Text <> "" And
txtstock.Text <> "" And txtestado.Text <> "" Then
Try
Dim dts As New vprenda
Dim func As New fprenda

dts.gidprenda = txtidprenda.Text
dts.gidcategoria = txtidcategoria.Text
dts.gnombre_prenda = txtnombre_prenda.Text
dts.gtalla_prenda = cbxtalla.Text
dts.gtela = cbxcalidad.Text
dts.gcolor = txtcolor.Text
dts.gprecio = txtprecio.Text
dts.gnum_usos = txtnum_usos.Text
dts.gstock = txtstock.Text
dts.gestado = txtestado.Text

18
If func.editar(dts) Then
MessageBox.Show("Datos de la prenda modificados
correctamente", "Modificando registros", MessageBoxButtons.OK,
MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("La prenda no se pudo modificar",
"Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Modificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub

Private Sub cbeliminar_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cbeliminar.CheckedChanged
If cbeliminar.CheckState = CheckState.Checked Then
datalistado.Columns.Item("Eliminar").Visible = True
Else
datalistado.Columns.Item("Eliminar").Visible = False
End If
End Sub

Private Sub btneliminar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneliminar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea eliminar las prendas


seleccionadas?", "Eliminando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then


Try
For Each row As DataGridViewRow In datalistado.Rows
Dim marcado As Boolean =
Convert.ToBoolean(row.Cells("Eliminar").Value)

If marcado Then
Dim onekey As Integer =
Convert.ToInt32(row.Cells("idprenda").Value)
Dim vdb As New vprenda
Dim func As New fprenda
vdb.gidprenda = onekey

If func.eliminar(vdb) Then
Else
MessageBox.Show("La prenda no fue eliminada",
"Eliminando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If

Next
Call mostrar()

19
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Cancelando eliminación de registros", "Eliminando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
Call mostrar()
End If

Call limpiar()
End Sub

Private Sub btnbuscarcategoria_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnbuscarcategoria.Click
frmcategorias.txtflag.Text = "1"
frmcategorias.ShowDialog()
End Sub
Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtbuscar.TextChanged
buscar()
End Sub

Private Sub datalistado_CellDoubleClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellDoubleClick
If txtflag.Text = "1" Then
frm_detalle_alquiler.txtidprenda.Text =
datalistado.SelectedCells.Item(1).Value
frm_detalle_alquiler.txtnombre_prenda.Text =
datalistado.SelectedCells.Item(3).Value
frm_detalle_alquiler.txttalla.Text =
datalistado.SelectedCells.Item(5).Value
frm_detalle_alquiler.txtcalidad.Text =
datalistado.SelectedCells.Item(6).Value
frm_detalle_alquiler.txtcolor.Text =
datalistado.SelectedCells.Item(7).Value
frm_detalle_alquiler.txtstock.Text =
datalistado.SelectedCells.Item(10).Value
frm_detalle_alquiler.txtprecio_unitario.Text =
datalistado.SelectedCells.Item(8).Value
Me.Close()

End If
End Sub

Private Sub txtidcategoria_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtidcategoria.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Seleccione la categoría del producto,
este dato es obligatorio")
End If
End Sub

Private Sub txtstock_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtstock.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
20
Me.erroricono.SetError(sender, "Ingrese el stock del producto
porfavor, este datos es obligatorio")
End If
End Sub

Private Sub txtnom_categoria_TextChanged(sender As Object, e As EventArgs)


Handles txtnom_categoria.TextChanged
If txtnom_categoria.Text = "SACO_CABALLERO" Then
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxcalidad.Items.Add("Polystel")
cbxcalidad.Items.Add("Cardiff")
cbxcalidad.Items.Add("Fábrica")
cbxtalla.Items.Add("88-75")
cbxtalla.Items.Add("93-76")
cbxtalla.Items.Add("98-76")
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
ElseIf txtnom_categoria.Text = "SACO_DAMA" Then
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxcalidad.Items.Add("Polystel")
cbxcalidad.Items.Add("Cardiff")
cbxcalidad.Items.Add("Fábrica")
cbxtalla.Items.Add("86-72")
cbxtalla.Items.Add("88-73")
cbxtalla.Items.Add("93-74")
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
ElseIf txtnom_categoria.Text = "PANTALON_CABALL" Then
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxcalidad.Items.Add("Polystel")
cbxcalidad.Items.Add("Cardiff")
cbxcalidad.Items.Add("Fábrica")
cbxtalla.Items.Add("71-79")
cbxtalla.Items.Add("76-79")
cbxtalla.Items.Add("81-79")
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
ElseIf txtnom_categoria.Text = "PANTALON_DAMA" Then
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxtalla.Items.Add("66-74")
cbxtalla.Items.Add("71-74")
cbxtalla.Items.Add("76-74")
cbxcalidad.Items.Add("Polystel")
cbxcalidad.Items.Add("Cardiff")
cbxcalidad.Items.Add("Fábrica")
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
ElseIf txtnom_categoria.Text = "CAMISAS" Then
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxtalla.Items.Add("S")
cbxtalla.Items.Add("M")
cbxtalla.Items.Add("L")
cbxtalla.Items.Add("XL")
cbxcalidad.Text = "Clásico"
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
ElseIf txtnom_categoria.Text = "CORBATAS" Then
21
cbxtalla.Enabled = False
cbxcalidad.Enabled = False
txtnum_usos.Text = ""
Else
cbxtalla.Items.Clear()
cbxcalidad.Items.Clear()
cbxcalidad.SelectedIndex = -1
cbxtalla.SelectedIndex = -1
cbxtalla.Enabled = True
cbxcalidad.Enabled = True
End If

End Sub

End Class

3.3.5 Formulario Cliente: Se realiza el registro de clientes


con todos los datos que se piden.

Public Class frmcliente

Private dt As New DataTable


Private Sub frmcliente_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
mostrar()
End Sub

Public Sub limpiar()


btnguardar.Visible = True
btneditar.Visible = False
txtnombre.Text = ""
txtapellidos.Text = ""

22
txtdireccion.Text = ""
txttelefono.Text = ""
txtdni.Text = ""
txtidcliente.Text = ""
End Sub

Private Sub mostrar()


Try
Dim func As New fcliente
dt = func.mostrar
datalistado.Columns.Item("Eliminar").Visible = False

If dt.Rows.Count <> 0 Then


datalistado.DataSource = dt
txtbuscar.Enabled = True
datalistado.ColumnHeadersVisible = True
inexistente.Visible = False
Else
datalistado.DataSource = Nothing
txtbuscar.Enabled = False
datalistado.ColumnHeadersVisible = False
inexistente.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try
btnnuevo.Visible = True
btneditar.Visible = False

buscar()
End Sub

Private Sub buscar()


Try
Dim ds As New DataSet
ds.Tables.Add(dt.Copy)
Dim dv As New DataView(ds.Tables(0))

dv.RowFilter = cbocampo.Text & " like '" & txtbuscar.Text & "%'"

If dv.Count <> 0 Then


inexistente.Visible = False
datalistado.DataSource = dv
ocultar_columnas()

Else
inexistente.Visible = True
datalistado.DataSource = Nothing
End If

Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub

Private Sub ocultar_columnas()


datalistado.Columns(1).Visible = False
23
End Sub

Private Sub txtnombre_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtnombre.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese el nombre del cliente
porfavor, este datos es obligatorio")
End If
End Sub

Private Sub txtapellidos_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtapellidos.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese los apellidos del cliente
porfavor, este datos es obligatorio")
End If
End Sub

Private Sub txtdireccion_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs)
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese la direccion del cliente
porfavor, este datos es obligatorio")
End If
End Sub

Private Sub txtdni_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtdireccion.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese el dni del cliente porfavor,
este datos es obligatorio")
End If
End Sub

Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnnuevo.Click
limpiar()
mostrar()

End Sub

Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnguardar.Click
If Me.ValidateChildren = True And txtnombre.Text <> "" And
txtapellidos.Text <> "" And txtdireccion.Text <> "" And txttelefono.Text <> ""
And txtdni.Text <> "" Then
Try
Dim dts As New vcliente
Dim func As New fcliente

dts.gdni = txtdni.Text
dts.gnombres = txtnombre.Text
dts.gapellidos = txtapellidos.Text
dts.gdireccion = txtdireccion.Text
24
dts.gtelefono = txttelefono.Text

If func.insertar(dts) Then
MessageBox.Show("cliente registrado correctamente",
"Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("cliente no fue registrado intente de nuevo",
"Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub datalistado_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles datalistado.CellClick
txtidcliente.Text = datalistado.SelectedCells.Item(1).Value
txtdni.Text = datalistado.SelectedCells.Item(2).Value
txtnombre.Text = datalistado.SelectedCells.Item(3).Value
txtapellidos.Text = datalistado.SelectedCells.Item(4).Value
txtdireccion.Text = datalistado.SelectedCells.Item(5).Value
txttelefono.Text = datalistado.SelectedCells.Item(6).Value

btneditar.Visible = True
btnguardar.Visible = False
End Sub

Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellContentClick
If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
Dim chkcell As DataGridViewCheckBoxCell =
Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
chkcell.Value = Not chkcell.Value
End If
End Sub

Private Sub btneditar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneditar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea editar los datos del cliente?",


"MOdificando registros", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)

If result = DialogResult.OK Then

If Me.ValidateChildren = True And txtnombre.Text <> "" And


txtapellidos.Text <> "" And txtdireccion.Text <> "" And txttelefono.Text <> ""
And txtdni.Text <> "" And txtidcliente.Text <> "" Then
Try
Dim dts As New vcliente
Dim func As New fcliente

25
dts.gidcliente = txtidcliente.Text
dts.gdni = txtdireccion.Text
dts.gnombres = txtnombre.Text
dts.gapellidos = txtapellidos.Text
dts.gdireccion = txtdireccion.Text
dts.gtelefono = txttelefono.Text

If func.editar(dts) Then
MessageBox.Show("cliente MOdificado correctamente",
"MOdificando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("cliente no fue modifcado intente de
nuevo", "MOdificando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "MOdificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub

Private Sub cbeliminar_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cbeliminar.CheckedChanged
If cbeliminar.CheckState = CheckState.Checked Then
datalistado.Columns.Item("Eliminar").Visible = True
Else
datalistado.Columns.Item("Eliminar").Visible = False
End If
End Sub

Private Sub btneliminar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneliminar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea eliminar los clientes


seleccionados?", "Eliminando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then


Try
For Each row As DataGridViewRow In datalistado.Rows
Dim marcado As Boolean =
Convert.ToBoolean(row.Cells("Eliminar").Value)

If marcado Then
Dim onekey As Integer =
Convert.ToInt32(row.Cells("idcliente").Value)
Dim vdb As New vcliente
Dim func As New fcliente
vdb.gidcliente = onekey

If func.eliminar(vdb) Then
Else

26
MessageBox.Show("Cliente no fue eliminado",
"Eliminando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If

Next
Call mostrar()

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Cancelando eliminación de registros", "Eliminando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
Call mostrar()
End If

Call limpiar()
End Sub

Private Sub datalistado_CellDoubleClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellDoubleClick
If txtflag.Text = "1" Then
frmalquiler.txtidcliente.Text =
datalistado.SelectedCells.Item(1).Value
frmalquiler.txtnombre_cliente.Text =
datalistado.SelectedCells.Item(3).Value
Me.Close()

End If
End Sub

Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtbuscar.TextChanged
buscar()
End Sub
End Class

27
3.3.6 Formulario Registro de Alquileres: En este
formulario se almacena los datos del alquiler como son
los datos del cliente, fecha de alquiler y devolución,
número de recibo y la garantía que deja el cliente.

Al darle al botón Guardar se procede a la elección de


prendas para el alquiler en el siguiente formulario.

Public Class frmalquiler


Private dt As New DataTable

Private Sub frmalquiler_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
mostrar()

End Sub

Public Sub limpiar()


btnguardar.Visible = True
btneditar.Visible = False
txtidcliente.Text = ""
txtnombre_cliente.Text = ""
txtgarantia.Text = ""
txtnum_recibo.Text = ""
txtidalquiler.Text = ""
End Sub

Private Sub mostrar()


Try
Dim func As New falquiler
dt = func.mostrar
datalistado.Columns.Item("Eliminar").Visible = False

If dt.Rows.Count <> 0 Then


datalistado.DataSource = dt
txtbuscar.Enabled = True
28
datalistado.ColumnHeadersVisible = True
inexistente.Visible = False
Else
datalistado.DataSource = Nothing
txtbuscar.Enabled = False
datalistado.ColumnHeadersVisible = False
inexistente.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try
btnnuevo.Visible = True
btneditar.Visible = False

buscar()
End Sub

Private Sub buscar()


Try
Dim ds As New DataSet
ds.Tables.Add(dt.Copy)
Dim dv As New DataView(ds.Tables(0))

dv.RowFilter = cbocampo.Text & " like '" & txtbuscar.Text & "%'"

If dv.Count <> 0 Then


inexistente.Visible = False
datalistado.DataSource = dv
ocultar_columnas()
Else
inexistente.Visible = True
datalistado.DataSource = Nothing
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub ocultar_columnas()


datalistado.Columns(1).Visible = False
datalistado.Columns(2).Visible = False
End Sub

Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnnuevo.Click
limpiar()
mostrar()
End Sub

Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnguardar.Click
If Me.ValidateChildren = True And txtidcliente.Text <> "" And
txtnombre_cliente.Text <> "" And txtnum_recibo.Text <> "" Then
Try
Dim dts As New valquiler
Dim func As New falquiler

dts.gidcliente = txtidcliente.Text
dts.gfecha_alquiler = txtfecha_alquiler.Text
dts.gfecha_devolucion = txtfecha_devolucion.Text
dts.ggarantia = txtgarantia.Text
dts.gnum_recibo = txtnum_recibo.Text
29
If func.insertar(dts) Then
MessageBox.Show("Alquiler registrado correctamente, vamos a
añadir prendas", "Guardando registros", MessageBoxButtons.OK,
MessageBoxIcon.Information)
mostrar()
limpiar()
cargar_detalle()
Else
MessageBox.Show("Alquiler no fue registrado, intente de
nuevo", "Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub datalistado_CellClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles datalistado.CellClick
txtidalquiler.Text = datalistado.SelectedCells.Item(1).Value
txtidcliente.Text = datalistado.SelectedCells.Item(2).Value
txtnombre_cliente.Text = datalistado.SelectedCells.Item(3).Value
txtgarantia.Text = datalistado.SelectedCells.Item(6).Value
txtnum_recibo.Text = datalistado.SelectedCells.Item(7).Value
btneditar.Visible = True
btnguardar.Visible = False
End Sub

Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellContentClick
If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
Dim chkcell As DataGridViewCheckBoxCell =
Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
chkcell.Value = Not chkcell.Value
End If
End Sub

Private Sub btneditar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btneditar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea editar los datos de la venta?",


"Modificando registros", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)

If result = DialogResult.OK Then

If Me.ValidateChildren = True And txtidcliente.Text <> "" And


txtnum_recibo.Text <> "" And txtidalquiler.Text <> "" And txtgarantia.Text <> ""
Then
Try
Dim dts As New valquiler
Dim func As New falquiler

dts.gidalquiler = txtfecha_alquiler.Text
dts.gidcliente = txtidcliente.Text
dts.gfecha_alquiler = txtfecha_alquiler.Text
30
dts.gfecha_devolucion = txtfecha_devolucion.Text
dts.ggarantia = txtgarantia.Text
dts.gnum_recibo = txtnum_recibo.Text

If func.editar(dts) Then
MessageBox.Show("Alquiler modificado correctamente",
"Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("El alquiler no fue modificado",
"Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Modificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub

Private Sub cbeliminar_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cbeliminar.CheckedChanged
If cbeliminar.CheckState = CheckState.Checked Then
datalistado.Columns.Item("Eliminar").Visible = True
Else
datalistado.Columns.Item("Eliminar").Visible = False
End If
End Sub

Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtbuscar.TextChanged
buscar()
End Sub

Private Sub cargar_detalle()


frm_detalle_alquiler.txtidalquiler.Text =
datalistado.SelectedCells.Item(1).Value
frm_detalle_alquiler.txtidcliente.Text =
datalistado.SelectedCells.Item(2).Value
frm_detalle_alquiler.txtnombre_cliente.Text =
datalistado.SelectedCells.Item(3).Value
frm_detalle_alquiler.txtnum_recibo.Text =
datalistado.SelectedCells.Item(4).Value

frm_detalle_alquiler.ShowDialog()
End Sub

Private Sub datalistado_CellDoubleClick(ByVal sender As Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellDoubleClick
cargar_detalle()
End Sub

Private Sub btnbuscar_cliente_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnbuscar_cliente.Click
31
frmcliente.txtflag.Text = "1"
frmcliente.ShowDialog()
End Sub

Private Sub txtidcliente_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtidcliente.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Seleccione el cliente de la venta,
este dato es obligatorio")
End If
End Sub

Private Sub txtnum_documento_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtnum_recibo.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese el número de comprobante,
este dato es obligatorio")
End If
End Sub

Private Sub btneliminar_Click(sender As Object, e As EventArgs) Handles


btneliminar.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea eliminar el alquiler


seleccionado?", "Eliminando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then


Try
For Each row As DataGridViewRow In datalistado.Rows
Dim marcado As Boolean =
Convert.ToBoolean(row.Cells("Eliminar").Value)

If marcado Then
Dim onekey As Integer =
Convert.ToInt32(row.Cells("idalquiler").Value)
Dim vdb As New valquiler
Dim func As New falquiler
vdb.gidalquiler = onekey

If func.eliminar(vdb) Then
Else
MessageBox.Show("El alquiler no fue eliminado",
"Eliminando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If

Next
Call mostrar()

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else

32
MessageBox.Show("Cancelando eliminación de registros", "Eliminando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
Call mostrar()
End If

Call limpiar()
End Sub

End Class

3.3.7. Formulario Detalle de Alquiler: En este formulario se


realiza el registro de la prenda a alquilar además de la
cantidad y el precio de cada una de las prendas escogidas.
También contiene l botón DEVUELTO, al darle clic se procede
a la devolución de la prenda; además está el botón Imprimir
que nos lleva a generar el recibo de alquiler.

Public Class frm_detalle_alquiler

Private dt As New DataTable

Private Sub frmdetalle_alquiler_Load(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles MyBase.Load
mostrar()
End Sub

Public Sub limpiar()


btnguardar.Visible = True
txtnum_recibo.Text = ""
txtidprenda.Text = ""
txtnombre_prenda.Text = ""
33
txttalla.Text = ""
txtcalidad.Text = ""
txtcolor.Text = ""
txtprecio_unitario.Text = ""
txtcantidad.Value = 0
txtstock.Value = 100
End Sub

Private Sub mostrar()


Try
Dim func As New fdetalle_alquiler
dt = func.mostrar
datalistado.Columns.Item("Eliminar").Visible = False

If dt.Rows.Count <> 0 Then


datalistado.DataSource = dt
datalistado.ColumnHeadersVisible = True
inexistente.Visible = False
Else
datalistado.DataSource = Nothing
datalistado.ColumnHeadersVisible = False
inexistente.Visible = True
End If
Catch ex As Exception
MsgBox(ex.Message)

End Try
btnnuevo.Visible = True

buscar()
End Sub

Private Sub buscar()


Try
Dim ds As New DataSet
ds.Tables.Add(dt.Copy)
Dim dv As New DataView(ds.Tables(0))

dv.RowFilter = "idalquiler='" & txtidalquiler.Text & "'"

If dv.Count <> 0 Then


inexistente.Visible = False
datalistado.DataSource = dv
ocultar_columnas()

Else
inexistente.Visible = True
datalistado.DataSource = Nothing
End If

Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub

Private Sub ocultar_columnas()


datalistado.Columns(1).Visible = False
datalistado.Columns(2).Visible = False
datalistado.Columns(3).Visible = False
End Sub
34
Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
limpiar()
mostrar()

End Sub

Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs)
buscar()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim result As DialogResult

result = MessageBox.Show("Realmente desea quitar las prendas del


alquiler?", "Eliminando registros", MessageBoxButtons.OKCancel,
MessageBoxIcon.Question)

If result = DialogResult.OK Then


Try
For Each row As DataGridViewRow In datalistado.Rows
Dim marcado As Boolean =
Convert.ToBoolean(row.Cells("Eliminar").Value)

If marcado Then
Dim onekey As Integer =
Convert.ToInt32(row.Cells("iddetalle_alquiler").Value)
Dim vdb As New vdetalle_alquiler
Dim func As New fdetalle_alquiler
vdb.giddetalle_alquiler = onekey

vdb.gidprenda = datalistado.SelectedCells.Item(3).Value
vdb.gidalquiler = datalistado.SelectedCells.Item(2).Value
vdb.gcantidad = datalistado.SelectedCells.Item(8).Value

If func.eliminar(vdb) Then
If func.disminuir_usos(vdb) Then
If func.aumentar_stock(vdb) Then

End If

End If
Else
MessageBox.Show("Prenda fue quitada del alquiler",
"Eliminando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If

Next
Call mostrar()

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Cancelando eliminación de registros", "Eliminando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
35
Call mostrar()
End If

Call limpiar()
End Sub

Private Sub btnbuscar_prenda_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnbuscar_prenda.Click
frmprendas.txtflag.Text = "1"
frmprendas.ShowDialog()
End Sub

Private Sub txtcantidad_ValueChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles txtcantidad.ValueChanged
Dim cant As Double

cant = txtcantidad.Value

If txtcantidad.Value > txtstock.Value Then


MessageBox.Show("La cantidad que intenta alquilar supera stock",
"Error al alquilar la prenda", MessageBoxButtons.OK, MessageBoxIcon.Information)
btnguardar.Visible = 0
txtcantidad.Value = txtstock.Value

Else
btnguardar.Visible = 1
End If

If txtcantidad.Value = 0 Then
btnguardar.Visible = 0
Else
btnguardar.Visible = 1
End If

End Sub

Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnguardar.Click
If Me.ValidateChildren = True And txtidprenda.Text <> "" And
txtcantidad.Text <> "" And txtprecio_unitario.Text <> "" Then
Try
Dim dts As New vdetalle_alquiler
Dim func As New fdetalle_alquiler

dts.gidalquiler = txtidalquiler.Text
dts.gidprenda = txtidprenda.Text
dts.gcantidad = txtcantidad.Text
dts.gprecio_unitario = txtprecio_unitario.Text

If func.insertar(dts) Then
If func.disminuir_stock(dts) Then
If func.aumentar_usos(dts) Then
If func.alquilado(dts) Then

End If
End If
End If

36
MessageBox.Show("Prenda fue añadida correctamente al
alquiler", "Guardando registros", MessageBoxButtons.OK,
MessageBoxIcon.Information)
mostrar()
limpiar()

Else
MessageBox.Show("La prenda no se añadió, intente de nuevo",
"Guardando registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Guardando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub

Private Sub cbeliminar_CheckedChanged_1(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles cbeliminar.CheckedChanged
If cbeliminar.CheckState = CheckState.Checked Then
datalistado.Columns.Item("Eliminar").Visible = True
Else
datalistado.Columns.Item("Eliminar").Visible = False
End If
End Sub

Private Sub datalistado_CellClick(sender As Object, e As


DataGridViewCellEventArgs) Handles datalistado.CellClick
txtidprenda.Text = datalistado.SelectedCells.Item(3).Value
txtnombre_prenda.Text = datalistado.SelectedCells.Item(4).Value
txttalla.Text = datalistado.SelectedCells.Item(5).Value
txtcalidad.Text = datalistado.SelectedCells.Item(6).Value
txtcolor.Text = datalistado.SelectedCells.Item(7).Value
txtcantidad.Text = datalistado.SelectedCells.Item(8).Value
txtprecio_unitario.Text = datalistado.SelectedCells.Item(9).Value
End Sub

Private Sub datalistado_CellContentClick(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.DataGridViewCellEventArgs) Handles
datalistado.CellContentClick
If e.ColumnIndex = Me.datalistado.Columns.Item("Eliminar").Index Then
Dim chkcell As DataGridViewCheckBoxCell =
Me.datalistado.Rows(e.RowIndex).Cells("Eliminar")
chkcell.Value = Not chkcell.Value
End If
End Sub

Private Sub txtidprenda_Validating(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles txtidprenda.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Seleccione la prenda para añadir al
alquiler, este dato es obligatorio")
End If
End Sub
37
Private Sub txtprecio_unitario_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtprecio_unitario.Validating
If DirectCast(sender, TextBox).Text.Length > 0 Then
Me.erroricono.SetError(sender, "")
Else
Me.erroricono.SetError(sender, "Ingrese precio unitario al alquiler,
este dato es obligatorio")
End If
End Sub

Private Sub btndevuelto_Click(sender As Object, e As EventArgs) Handles


btndevuelto.Click
Dim result As DialogResult

result = MessageBox.Show("La prenda se devolvió?", "Modificando


registros", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)

If result = DialogResult.OK Then

If Me.ValidateChildren = True And txtidprenda.Text <> "" And


txtcantidad.Text <> "" And txtprecio_unitario.Text <> "" Then
Try
Dim dts As New vdetalle_alquiler
Dim func As New fdetalle_alquiler

dts.gidprenda = txtidprenda.Text

If func.devuelto(dts) Then
MessageBox.Show("La prenda se devolvió correctamente",
"Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
mostrar()
limpiar()
Else
MessageBox.Show("La prenda no se devolvió", "Modificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Error)
mostrar()
limpiar()
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MessageBox.Show("Falta ingresar algunos datos", "Modificando
registros", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
End Sub

Private Sub btnimprimir_Click(sender As Object, e As EventArgs) Handles


btnimprimir.Click
frmreporterecibo.txtidalquiler.Text = Me.txtidalquiler.Text
frmreporterecibo.ShowDialog()
End Sub
End Class

38
3.3.8. Formulario Recibo: En este se genera un recibo de acuerdo
a los datos del cliente y las prendas escogidas, aquí se realiza
el cálculo total de cuanto debe pagar el cliente y también se
añade las fechas de alquiler y devolución máxima.

Public Class frmreporterecibo

Private Sub frmreporterecibo_Load(sender As Object, e As EventArgs) Handles


MyBase.Load
ALQUILERDataSet2.EnforceConstraints = False
'TODO: esta línea de código carga datos en la tabla
'dbventasDataSet1.generar_comprobante' Puede moverla o quitarla según sea
necesario.

Me.generar_comprobanteTableAdapter.Fill(Me.ALQUILERDataSet2.generar_comprobante,
idalquiler:=txtidalquiler.Text)
Me.ReportViewer1.RefreshReport()
End Sub
End Class

39
3.3.9. Formulario Reporte de Prenda: Se puede tener una visión
más objetiva de las prendas y controlar el número de usos
que tienen y si ya fueron devueltos o no.

Public Class frmreporteprendas

Private Sub frmreporteprendas_Load(sender As Object, e As EventArgs) Handles


MyBase.Load
'TODO: esta línea de código carga datos en la tabla
'ALQUILERDataSet.Prendas' Puede moverla o quitarla según sea necesario.
Me.PrendasTableAdapter.Fill(Me.ALQUILERDataSet.Prendas)

Me.ReportViewer1.RefreshReport()
End Sub
End Class

40
4. UBICACIÓN

Jr. Dos de Mayo N° 308

La Unión, Dos de Mayo, Huánuco

5. ORGANO O INSTITUCION RESPONSABLE DEL PROYECTO

“Sastrería Morales”

6. BENEFICIARIOS

6.1. DIRECTOS

Trabajadores de la Sastrería “Morales”

6.2. INDIRECTO

Clientes

7. METAS RESULTADOS

 Ahorrar tiempo en la atención a los clientes.


 Dejar el uso de anotaciones manuales de alquileres.
 Mejorar la rapidez de obtención de ingresos.

8. EFECTOS ESPERADOS DEL PROYECTO

 Mayor reconocimiento de la Sastrería Morales frente a la


competencia.
 Aumento de clientes y alquileres.
 Disminuir el trabajo del sastre y empleados.

41

Potrebbero piacerti anche