You are on page 1of 12

CodigoFelizLombriz Imports System.Data.SqlClient Module ModulePerfil Public Perfil As String nd Module Imports System.Data.SqlClient Module Module!suario Public !

suario As String nd Module Imports System.Data.SqlClient Public Class Login Dim intento As Integer Pri"ate Sub Login#Load$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles My%ase.Load Me.Center,oScreen$* Call Limpiar$* nd Sub Pri"ate Sub Limpiar$* ,e-t%o-!suario.Clear$* ,e-t%o-Pass.ord.Clear$* ,e-t%o-!suario.Focus$* nd Sub Pri"ate Sub %utton ntrar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton ntrar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1Select nom#usuario) pass.ord)tipo from !suarios .8ere nom#usuario2 91 : ,e-t%o-!suario.,e-t.,rim : 19 and pass.ord2 91 : ,e-t%o-Pass.ord.,e-t.,rim : 191) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dsdatos As 0e. DataSet ,ry cone-ion.'pen$* adaptador.Fill$dsdatos) 1!suarios1* If dsdatos.,ables$1!suarios1*.6o.s.Count ; < ,8en Dim tipodeusuario As String 2 dsdatos.,ables$1!suarios1*.6o.s$<*$1tipo1* If tipodeusuario 2 1administrador1 ,8en !suario 2 ,e-t%o-!suario.,e-t Perfil 2 1administrador1 Me.+ide$* Dim menu As 0e. MenuPrincipal menu.S8o.$*

nd If If tipodeusuario 2 1operario1 ,8en !suario 2 ,e-t%o-!suario.,e-t Perfil 2 1operario1 Me.+ide$* Dim menu As 0e. MenuPrincipal menu.S8o.$* nd If If tipodeusuario 2 1mecanico1 ,8en !suario 2 ,e-t%o-!suario.,e-t Perfil 2 1mecanico1 Me.+ide$* Dim menu As 0e. MenuPrincipal menu.S8o.$* nd If lse intento 2 intento = > If intento ?2 @ ,8en Message%o-.S8o.$1!suario yAo pass.ord incorrectos) solo B intentos 1 : intento : 1 intento1* Call Limpiar$* nd If If intento 2 B ,8en Message%o-.S8o.$10o 8ay mas intentos 1 : intento : 1 %C 1* Me.Close$* nd If nd If Catc8 e- As -ception Message%o-.S8o.$1 66'6 L'DI0E 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* nd Sub nd Class

Imports System.Data.SqlClient Public Class MenuPrincipal Pri"ate Sub MenuPrincipal#Load$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles My%ase.Load Me.Center,oScreen$* Label!suario.,e-t 2 !suario If Perfil 2 1mecanico1 ,8en Clientes,oolStripMenuItem. nabled 2 False mpleados,oolStripMenuItem. nabled 2 False Clientes,oolStripMenuItem>. nabled 2 False mpleados,oolStripMenuItem>. nabled 2 False

&e8iculos,oolStripMenuItem>. nabled 2 False 6eporteClientes,oolStripMenuItem@. nabled 2 False 6eporte mpleados,oolStripMenuItem@. nabled 2 False Factura,oolStripMenuItem. nabled 2 False nd If If Perfil 2 1operario1 ,8en Clientes,oolStripMenuItem. nabled 2 False mpleados,oolStripMenuItem. nabled 2 False Clientes,oolStripMenuItem>. nabled 2 False mpleados,oolStripMenuItem>. nabled 2 False 6eporteClientes,oolStripMenuItem@. nabled 2 False 6eporte mpleados,oolStripMenuItem@. nabled 2 False Factura,oolStripMenuItem. nabled 2 False nd If nd Sub Pri"ate Sub SalirDelSistema,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles SalirDelSistema,oolStripMenuItem.Clic/ Me.Close$* nd Sub Pri"ate Sub Clientes,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Clientes,oolStripMenuItem.Clic/ Me.+ide$* Dim consulta#clientes As 0e. ConsultaClientes consulta#clientes.S8o.$* nd Sub Pri"ate Sub mpleados,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles mpleados,oolStripMenuItem.Clic/ Me.+ide$* Dim consulta#empleados As 0e. Consulta mpleados consulta#empleados.S8o.$* nd Sub Pri"ate Sub &e8iculos,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles &e8iculos,oolStripMenuItem.Clic/ Me.+ide$* Dim consulta#"e8iculo As 0e. Consulta&e8iculos consulta#"e8iculo.S8o.$* nd Sub Pri"ate Sub Clientes,oolStripMenuItem>#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Clientes,oolStripMenuItem>.Clic/ Me.+ide$* Dim mantenimiento#clientes As 0e. MantenimientoClientes mantenimiento#clientes.S8o.$*

nd Sub Pri"ate Sub mpleados,oolStripMenuItem>#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles mpleados,oolStripMenuItem>.Clic/ Me.+ide$* Dim mantenimiento#empleados As 0e. Mantenimiento mpleados mantenimiento#empleados.S8o.$* nd Sub Pri"ate Sub &e8iculos,oolStripMenuItem>#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles &e8iculos,oolStripMenuItem>.Clic/ Me.+ide$* Dim mantenimiento#"e8iculos As 0e. Mantenimiento&e8iculos mantenimiento#"e8iculos.S8o.$* nd Sub Pri"ate Sub CambioDeContraseFa,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles CambioDeContraseFa,oolStripMenuItem.Clic/ Me.+ide$* Dim cambio#contraseFa As 0e. CambioContraseFa cambio#contraseFa.S8o.$* nd Sub Pri"ate Sub %loc/De0otas,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %loc/De0otas,oolStripMenuItem.Clic/ System.Diagnostics.Process.Start$1notepad.e-e1* nd Sub Pri"ate Sub Calculadora,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Calculadora,oolStripMenuItem.Clic/ System.Diagnostics.Process.Start$1calc.e-e1* nd Sub Pri"ate Sub Correo,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Correo,oolStripMenuItem.Clic/ System.Diagnostics.Process.Start$1msimn.e-e1* nd Sub Pri"ate Sub MS0,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles MS0,oolStripMenuItem.Clic/ System.Diagnostics.Process.Start$1msnmsgr.e-e1* nd Sub Pri"ate Sub 6eporteClientes,oolStripMenuItem@#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles 6eporteClientes,oolStripMenuItem@.Clic/ Me.+ide$*

Dim reporte#clientes As 0e. 6eporteClientes reporte#clientes.S8o.$* nd Sub Pri"ate Sub 6eporte mpleados,oolStripMenuItem@#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles 6eporte mpleados,oolStripMenuItem@.Clic/ Me.+ide$* Dim reporte#empleados As 0e. 6eporte mpleados reporte#empleados.S8o.$* nd Sub Pri"ate Sub 6eporte&e8Gculos,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles 6eporte&e8Gculos,oolStripMenuItem.Clic/ Me.+ide$* Dim reporte#"e8iculos As 0e. 6eporte&e8iculos reporte#"e8iculos.S8o.$* nd Sub Pri"ate Sub ContenidoDelSistema,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles ContenidoDelSistema,oolStripMenuItem.Clic/ nd Sub Pri"ate Sub AcercaDe,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles AcercaDe,oolStripMenuItem.Clic/ nd Sub Pri"ate Sub Factura,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Factura,oolStripMenuItem.Clic/ Me.+ide$* Dim transaccion#factura As 0e. ,ransaccionFactura transaccion#factura.S8o.$* nd Sub Pri"ate Sub Aticulos,oolStripMenuItem#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles Aticulos,oolStripMenuItem.Clic/ Me.+ide$* Dim consulta#articulos As 0e. ConsultaArticulos consulta#articulos.S8o.$* nd Sub nd Class

Imports System.Data Imports System.Data.SqlClient Public Class MantenimientoClientes Pri"ate Sub %utton&ol"er#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton&ol"er.Clic/ Me.+ide$* Dim menu As 0e. MenuPrincipal menu.S8o.$* nd Sub Pri"ate Sub MantenimientoClientes#Load$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles My%ase.Load Me.Center,oScreen$* Label!suario.,e-t 2 usuario Call Limpiar$* Call CargarDatos0a"egador$* Call CargarDatosDataDrid$* nd Sub Pri"ate Sub Limpiar$* ,e-t%o-6ut.Clear$* ,e-t%o-0ombre.Clear$* ,e-t%o- mail.Clear$* ,e-t%o-Pais.Clear$* ,e-t%o-,elefono.Clear$* ,e-t%o- mail.Clear$* ,e-t%o-Ciudad.Clear$* ,e-t%o-Se-o.Clear$* ,e-t%o-6ut.Focus$* nd Sub Pri"ate Sub CargarDatos0a"egador$* Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1Select H from Clientes1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry cone-ion.'pen$* adaptador.Fill$dset) 1Clientes1* %indingSource>.DataSource 2 dset 9datasourceE obtiene o establece el origen de lo datos con q enlazar el conector %indingSource>.DataMember 2 dset.,ables$<*.,oString 9obtiene o establece 9 la lista concreta del origen de los datos con la q esta enlazada en este 9momento %inding0a"igator>.%indingSource 2 %indingSource> 1rut#cli1* ,e-t%o-6ut.Data%indings.Add$1,e-t1) %indingSource>)

,e-t%o-0ombre.Data%indings.Add$1,e-t1) %indingSource>) 1nom#cli1* ,e-t%o-Ciudad.Data%indings.Add$1,e-t1) %indingSource>) 1ciudad#cli1* ,e-t%o-,elefono.Data%indings.Add$1,e-t1) %indingSource>) 1tel#cli1* ,e-t%o-Se-o.Data%indings.Add$1,e-t1) %indingSource>) 1se-o#cli1* ,e-t%o-Pais.Data%indings.Add$1,e-t1) %indingSource>) 1pais#cli1* ,e-t%o- mail.Data%indings.Add$1,e-t1) %indingSource>) 1email#cli1* Catc8 e- As -ception Message%o-.S8o.$1 66'6 CA6DA6 0A& DAD'6E 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* nd Sub Pri"ate Sub CargarDatosDataDrid$* Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1Select H from Clientes1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry cone-ion.'pen$* adaptador.Fill$dset) 1Clientes1* DataDrid&ie.>.DataSource 2 dset DataDrid&ie.>.DataMember 2 dset.,ables$<*.,oString Catc8 e- As -ception Message%o-.S8o.$1 66'6 CA6DA6 D6ID &I IE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* nd Sub Pri"ate Sub %uttonIngresar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %uttonIngresar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1insert into Clientes "alues$91 : ,e-t%o-6ut.,e-t.,rim : 19)91 : ,e-t%o-0ombre.,e-t.,rim : 19) 91 : ,e-t%o-Ciudad.,e-t.,rim : 19)91 : Integer.Parse$,e-t%o-,elefono.,e-t.,rim* : 19)91 : ,e-t%o-Se-o.,e-t.,rim : 19) 91 : ,e-t%o- mail.,e-t.,rim : 19)91 : ,e-t%o-Pais.,e-t.,rim : 19* 1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry

cone-ion.'pen$* If comando. -ecute0on4uery ; < ,8en Message%o-.S8o.$1Ingreso -itoso1* lse Message%o-.S8o.$1 rror al Ingresar1* nd If Catc8 e- As -ception Message%o-.S8o.$1 66'6 I0D6 SA6 CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* Call CargarDatos0a"egador$* Call CargarDatosDataDrid$* Call Limpiar$* nd Sub Pri"ate Sub %utton%uscar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton%uscar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1select H from Clientes .8ere rut#cli 2 91 : ,e-t%o-6ut.,e-t.,rim : 19 1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet Dim dreader As SqlData6eader 9para traba(ar de forma conectada con la bd. recibe los registros ,ry cone-ion.'pen$* dreader 2 comando. -ecute6eader 9se guardan los datos en el dr If dreader.6ead 2 ,rue ,8en ,e-t%o-0ombre.,e-t 2 dreader$1nom#cli1* ,e-t%o-Ciudad.,e-t 2 dreader$1ciudad#cli1* ,e-t%o-,elefono.,e-t 2 dreader$1tel#cli1* ,e-t%o-Se-o.,e-t 2 dreader$1se-o#cli1* ,e-t%o- mail.,e-t 2 dreader$1email#cli1* ,e-t%o-Pais.,e-t 2 dreader$1pais#cli1* lse Message%o-.S8o.$1Problemas al %uscar1* nd If Catc8 e- As -ception Message%o-.S8o.$1 66'6 %!S4! DA CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* Call CargarDatos0a"egador$* Call CargarDatosDataDrid$* Call Limpiar$*

nd Sub Pri"ate Sub %uttonLimpiar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %uttonLimpiar.Clic/ Call Limpiar$* nd Sub Pri"ate Sub %utton liminar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton liminar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1delete from Clientes .8ere rut#cli291 : ,e-t%o-6ut.,e-t.,rim : 19 1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry cone-ion.'pen$* If comando. -ecute0on4uery ; < ,8en Message%o-.S8o.$1 liminacion -itosa1* lse Message%o-.S8o.$1 rror al liminar1* nd If Catc8 e- As -ception Message%o-.S8o.$1 66'6 LIMI0A6 CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* Call CargarDatos0a"egador$* Call CargarDatosDataDrid$* Call Limpiar$* nd Sub Pri"ate Sub %uttonActualizar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %uttonActualizar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1update Clientes set nom#cli291 : ,e-t%o-0ombre.,e-t.,rim : 19) ciudad#cli291 : ,e-t%o-Ciudad.,e-t.,rim : 19)tel#cli291 : Integer.Parse$,e-t%o-,elefono.,e-t.,rim* : 19)se-o#cli291 : ,e-t%o-Se-o.,e-t.,rim : 19) email#cli291 : ,e-t%o- mail.,e-t.,rim : 19)pais#cli291 : ,e-t%o-Pais.,e-t.,rim : 19 .8ere rut#cli2 91 : ,e-t%o-6ut.,e-t.,rim : 19 1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry cone-ion.'pen$* If comando. -ecute0on4uery ; < ,8en Message%o-.S8o.$1Actualizacion -itosa1* lse Message%o-.S8o.$1 rror al Actualizar1* nd If

Catc8 e- As -ception Message%o-.S8o.$1 66'6 AC,!ALIJA6 CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* Call CargarDatos0a"egador$* Call CargarDatosDataDrid$* Call Limpiar$* nd Sub nd Class Imports System.Data.SqlClient Public Class ConsultaClientes Dim campo As String Dim nombreCampo As String Pri"ate Sub ConsultaClientes#Load$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles My%ase.Load Me.Center,oScreen$* Call limpiar$* nd Sub Pri"ate Sub Limpiar$* ,e-t%o-@.Clear$* ,e-t%o-@.Focus$* nd Sub Pri"ate Sub ConsultaClientes#MouseMo"e$%y&al sender As 'b(ect) %y&al e As System.Iindo.s.Forms.Mouse "entArgs* +andles Me.MouseMo"e If radiobutton6ut.C8ec/ed 2 ,rue ,8en campo 2 1rut#cli1 nombreCampo 2 1rut1 nd If If 6adiobutton0ombre.C8ec/ed 2 ,rue ,8en campo 2 1nom#cli1 nombreCampo 2 1nombre1 nd If If 6adiobuttonCiudad.C8ec/ed 2 ,rue ,8en campo 2 1ciudad#cli1 nombreCampo 2 1ciudad1 nd If If 6adiobuttonPais.C8ec/ed 2 ,rue ,8en campo 2 1pais#cli1 nombreCampo 2 1pais1 nd If Label>.,e-t 2 1Ingrese 1 : nombreCampo : 1 a buscarE1 nd Sub

Pri"ate Sub %utton&ol"er#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton&ol"er.Clic/ Me.+ide$* Dim menu As 0e. MenuPrincipal menu.S8o.$* nd Sub

Pri"ate Sub %utton%uscar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton%uscar.Clic/ Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1Select H from Clientes .8ere 1 : campo.,rim : 1 li/e 91 : ,e-t%o-@.,e-t.,rim : 1K91) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* 9representa un con(. de comandos de datos y una cone-ion a %d para poder llenar un dataset Dim dset As 0e. DataSet 9 representa una tabla "irtual ,ry If ,e-t%o-@.,e-t 2 11 ,8en Label>.,e-t 2 1Ingrese 1 : nombreCampo : 1 a buscarE1 ,e-t%o-@.Focus$* lse cone-ion.'pen$* adaptador.Fill$dset) 1Clientes1* DataDrid>.DataSource 2 dset DataDrid>.DataMember 2 dset.,ables$<*.,oString nd If Catc8 e- As -ception Message%o-.S8o.$1 66'6 CA6DA6 D6ID C'0S!L,A6 CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* nd Sub Pri"ate Sub %uttonLimpiar#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %uttonLimpiar.Clic/ Call Limpiar$* nd Sub nd Class Imports System.Data.SqlClient Public Class 6eporteClientes Pri"ate Sub %utton6eporte#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton6eporte.Clic/

Dim cone-ion As 0e. SqlConnection$1Data Source2$local*3S4L 5P6 SS7Initial Catalog2Safito7Integrated Security2,rue1* Dim comando As 0e. SqlCommand$1select H from Clientes1) cone-ion* Dim adaptador As 0e. SqlDataAdapter$comando* Dim dset As 0e. DataSet ,ry cone-ion.'pen$* adaptador.Fill$dset) 1Clientes1* Dim reporte As 0e. 6eportClientes 9nombre del .rpt reporte.SetDataSource$dset.,ables$1Clientes1** Crystal6eport&ie.er>.6eportSource 2 reporte Catc8 e- As -ception Message%o-.S8o.$1 66'6 6 P'6, CLI 0, SE 1 : e-.Message* nd ,ry cone-ion.Close$* comando.Dispose$* cone-ion.Dispose$* nd Sub Pri"ate Sub 6eporteClientes#Load$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles My%ase.Load Me.Center,oScreen$* Label!suario.,e-t 2 !suario nd Sub Pri"ate Sub %utton&ol"er#Clic/$%y&al sender As System.'b(ect) %y&al e As System. "entArgs* +andles %utton&ol"er.Clic/ Dim menu As 0e. MenuPrincipal Me.+ide$* menu.S8o.$* nd Sub nd Class

Related Interests