Visual Studio 2008
Visual Studio 2008
Imports System.Data.OleDb Public Class login Private Sub btn__Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_.Click Try '' para ver si hay errores Dim oConn As New OleDbConnection '' libreria Dim oComm As New OleDbCommand '' oComm = lee Dim oData As OleDbDataReader '' leer oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = " SELECT * FROM usuario WHERE USUARIO='" + Txtusuario.Text + "' AND contrasea='" + Txtpassword.Text + "'" oComm.Connection = oConn oData = oComm.ExecuteReader() '' aperturar los datos para luego leerlos Do While oData.Read() usuarios.codigo = oData.Item("codigou") usuarios.nombre = oData.Item("nombres") usuarios.apellidos = oData.Item("Apellidos") usuarios.condicion = oData.Item("nivel") Loop If (oData.HasRows) Then ProgressBar1.Value = 0 Timer1.Enabled = True 'Txtusuario.Clear() 'Txtpassword.Clear() Txtusuario.Focus() Else If Txtusuario.Text.Trim = "" Then MessageBox.Show("****** Ingrese Usuario ******", "POR FAVOR FALTA DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error) Txtusuario.Enabled = True Txtusuario.Focus()
Exit Sub End If If Txtpassword.Text.Trim = "" Then MessageBox.Show("****** Ingrese Password ******", "POR FAVOR FALTA DATOS", MessageBoxButtons.OK, MessageBoxIcon.Error) Txtpassword.Focus() Exit Sub End If MessageBox.Show("****** DATOS INCORRECTOS ******", "----DATOS NO VALIDOS -----", MessageBoxButtons.OK, MessageBoxIcon.Error) Txtusuario.Enabled = True Txtusuario.Clear() Txtpassword.Clear() Txtusuario.Focus() End If Catch EX As Exception MsgBox(EX.Message.ToString()) End Try End Sub Private Sub login_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated Timer1.Enabled = False Timer2.Enabled = False ProgressBar1.Value = 0 Txtusuario.Enabled = True Txtusuario.Text = "" Txtpassword.Text = "" Txtusuario.Focus() End Sub Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.CenterToScreen() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If ProgressBar1.Value < 100 Then ProgressBar1.Value = ProgressBar1.Value + 5 If ProgressBar1.Value < 25 Then Label3.Text = "******* Validando Datos *******" ElseIf ProgressBar1.Value < 75 Then Label3.Text = " ******* Ingresando al Sistema *******" ElseIf ProgressBar1.Value < 100 Then Label3.Text = " ====== Bienvenido al Sistema ======" End If Else If ProgressBar1.Value = 100 Then Timer1.Enabled = False Me.Hide() principal.Show() principal.WindowState = 2 End If End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If ProgressBar1.Value > 0 Then ProgressBar1.Value = ProgressBar1.Value - 5 If ProgressBar1.Value < 100 Then Label3.Text = "Cancelando el ingreso al Sistema" ElseIf ProgressBar1.Value < 75 Then Label3.Text = "Abandonando el Sistema" End If ElseIf ProgressBar1.Value = 0 Then Timer2.Enabled = False Dim a As Integer a = MsgBox("Desea salir de Login", 36, "Cuidado") If a = 6 Then End Txtusuario.Focus() End If End Sub Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click If Timer1.Enabled = True Then Timer1.Enabled = False Dim a As Integer a = MsgBox("Desea cancelar el ingrerso al Sistema", 36, "cuidado") If a = 6 Then Timer2.Enabled = True Else Timer1.Enabled = True End If Exit Sub End If If Timer2.Enabled = True Then Timer2.Enabled = False Dim b As Integer b = MsgBox("Desea retomar el ingreso al Sistema", 36, "Cuidado") If b = 6 Then Timer1.Enabled = True Else Timer2.Enabled = True End If Exit Sub End If If Timer1.Enabled = False And Timer2.Enabled = False Then Dim a As Integer a = MsgBox("Desea salir del login", 36, "Cuidado") If a = 6 Then End End If End Sub Private Sub btn_salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_salir.Click Dim x As String x = MessageBox.Show("Esta seguro de salir", "==== CERRAR LOGIN ====", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) If x = MessageBoxButtons.OKCancel Then End Exit Sub End If End Sub
Private Sub Txtusuario_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Txtusuario.KeyPress Txtusuario.BackColor = Color.YellowGreen End Sub Private Sub Txtpassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Txtpassword.KeyPress Txtusuario.Enabled = False Txtpassword.BackColor = Color.YellowGreen End Sub End Class
Public Class principal Private Sub principal_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated Timer1.Enabled = False TS_ProgressBar1.Value = 0 label4.Text = "***** MENU PRINCIPAL *****" End Sub Private Sub principal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = usuarios.nombre Label2.Text = usuarios.apellidos If usuarios.condicion = 1 Then Label3.Text = "***** BIENVENIDO ADMINISTRADOR *****"
PictureBox1.Visible = True PictureBox2.Visible = False Else Label3.Text = "***** USTED ES USUARIO *****" mnuNuevo.Enabled = False PictureBox2.Visible = True PictureBox1.Visible = False End If End Sub Private Sub mnuListar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuListar.Click Me.Enabled = False LISTAR_USUARIO.Show() End Sub Private Sub mnuUsuarios_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuUsuarios.Click Timer1.Enabled = True Me.Enabled = False USUARIO.Show() End Sub Private Sub mnuCambiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCambiar.Click usuarios.nombre = 0 usuarios.condicion = Val(0) Me.Close() login.Show() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If TS_ProgressBar1.Value < 100 Then TS_ProgressBar1.Value = TS_ProgressBar1.Value + 5 If TS_ProgressBar1.Value < 25 Then label4.Text = "******* Ingresando al menu *******" ElseIf TS_ProgressBar1.Value < 75 Then label4.Text = " ******* ................ *******" ElseIf TS_ProgressBar1.Value < 100 Then label4.Text = " ====== Bienvenido al menu de usuarios ======" End If Else If TS_ProgressBar1.Value = 100 Then Timer1.Enabled = False Me.Enabled = False USUARIO.Show() End If End If End Sub Private Sub mnu_salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_salir.Click Dim x As String x = MessageBox.Show("ESTA SEGURO DE SALIR DEL PROGRAMA", "CUIDADO", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) If x = MessageBoxButtons.OKCancel Then End
Exit Sub End If End Sub Private Sub mnuNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNuevo.Click Me.Enabled = False USUARIO.Show() End Sub Private Sub mnu_nivel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_nivel.Click Me.Enabled = False NIVEL.Show() End Sub Private Sub mnu_producto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_producto.Click Me.Enabled = False PRODUCTO.Show() End Sub Private Sub mnu_medida_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_medida.Click Me.Enabled = False Medida.Show() End Sub Private Sub mnu_propietario_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_propietario.Click MessageBox.Show(" -------- PAUL YURY SALAZAR TAPIA -------- Email : [email protected] - cel 954729867 - PROPIETARIO ", " ****** PROPIETARIO ******", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub Private Sub mnu_report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_report.Click End Sub End Class
Imports System.Data.OleDb Public Class NIVEL Public Sub cargarcodigo() Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from NIVEL" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("NIVELC") + 1 Loop oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub Bloquear() TextBox1.Enabled = False TextBox2.Enabled = False BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnGuardar.Enabled = False BtnBuscar.Enabled = True BtnNuevo.Enabled = True BtnSalir.Enabled = True BtnBuscar.Enabled = True End Sub Public Sub Habilitar() TextBox1.Enabled = False TextBox2.Enabled = True
TextBox2.Focus() BtnGuardar.Enabled = True BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnNuevo.Enabled = True BtnActualizar.Enabled = False BtnBuscar.Enabled = True BtnSalir.Enabled = True BtnOk.Visible = False End Sub Public Sub BUSCAR() TextBox1.Enabled = False TextBox2.Enabled = True TextBox2.Focus() BtnOk.Visible = True BtnGuardar.Enabled = False BtnEliminar.Enabled = True BtnActualizar.Enabled = True BtnBuscar.Enabled = True BtnSalir.Enabled = True End Sub Public Sub listar() Try Dim Consulta As String Consulta = "SELECT * FROM NIVEL" Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub Medida_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load listar() TextBox1.Enabled = False Me.CenterToScreen() End Sub Private Sub BtnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "INSERT INTO NIVEL(NIVEL)VALUES('" & TextBox2.Text & "')" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open()
oData.ExecuteNonQuery() MessageBox.Show("SUS DATOS FUERON GUARDADO CORRECTAMENTE") oConn.Close() listar() Bloquear() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnActualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnActualizar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "UPDATE NIVEL SET NIVEL='" & TextBox2.Text & "' WHERE CODIGON=" & TextBox1.Text & " " Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("DATOS ACTUALIZADOS CORRECTAMENTE") oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEliminar.Click Try Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() Dim Eliminar As String = "DELETE FROM NIVEL WHERE NIVELC = " & TextBox1.Text & " " Dim comando As New OleDbCommand(Eliminar, oConn) comando.CommandType = CommandType.Text comando.ExecuteNonQuery() MessageBox.Show("LOS DATOS FUERON ELIMINADOS CON EXITO", "ELIMINANDO DATOS") oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click TextBox2.Enabled = True BtnOk.Enabled = True
BtnOk.Visible = True BUSCAR() End Sub Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "SELECT * FROM NIVEL WHERE NIVELC = " & Val(TextBox2.Text) & " OR NIVEL LIKE '%" & TextBox2.Text & "%' " oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGON") TextBox2.Text = oData.Item("NIVEL") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNuevo.Click Habilitar() cargarcodigo() End Sub Private Sub BtnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSalir.Click Me.Close() PRODUCTO.Enabled = True End Sub Private Sub btn_atras_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_atras.Click Me.Close() principal.Enabled = True End Sub End Class
Imports System.Data.OleDb Public Class PRODUCTO Public Sub cargarcodigo() Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from producto" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOP") + 1 Loop oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub Bloquear() TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False TextBox4.Enabled = False ComboBox1.Enabled = False
BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnGuardar.Enabled = False BtnBuscar.Enabled = True BtnNuevo.Enabled = True BtnSalir.Enabled = True BtnBuscar.Enabled = True End Sub Public Sub Habilitar() TextBox1.Enabled = False TextBox2.Enabled = True TextBox3.Enabled = True TextBox4.Enabled = True ComboBox1.Enabled = True TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" ComboBox1.Text = "MEDIDA" TextBox2.Focus() BtnGuardar.Enabled = True BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnNuevo.Enabled = True BtnActualizar.Enabled = False BtnBuscar.Enabled = True BtnSalir.Enabled = True BtnOk.Visible = False End Sub Public Sub BUSCAR() TextBox1.Enabled = False TextBox2.Enabled = True TextBox3.Enabled = False TextBox4.Enabled = False ComboBox1.Enabled = False TextBox2.Focus() BtnOk.Visible = True BtnGuardar.Enabled = False BtnEliminar.Enabled = True BtnActualizar.Enabled = True BtnBuscar.Enabled = True BtnSalir.Enabled = True End Sub Public Sub listar() Try Dim Consulta As String Consulta = "SELECT PRODUCTO.CODIGOP,PRODUCTO.PRODUCTO,PRODUCTO.CANTIDAD,MEDIDA.MEDIDAS FROM PRODUCTO INNER JOIN MEDIDA ON PRODUCTO.MEDIDA=MEDIDA.CODIGOM" Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close()
Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub cargarMedida() Try ComboBox1.Items.Clear() Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim comando As New OleDbCommand() comando.CommandText = "SELECT * FROM MEDIDA" comando.Connection = oConn oConn.Open() Dim oData As OleDbDataReader = comando.ExecuteReader() If oData.HasRows Then While oData.Read() ComboBox1.Items.Add(oData("medidaS").ToString()) End While End If oData.Close() Catch RED As Exception MessageBox.Show(RED.Message.ToString()) End Try End Sub Private Sub PRODUCTOS_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated listar() cargarMedida() End Sub Private Sub PRODUCTOS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load listar() cargarMedida() Bloquear() End Sub Private Sub BtnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "Insert Into producto(producto,cantidad,MEDIDA)values('" & TextBox2.Text & "'," & Val(TextBox3.Text) & ",'" & TextBox4.Text & "')" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("los datos fueron guardados correctamente") oConn.Close() listar() Bloquear() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try
End Sub Private Sub BtnActualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnActualizar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "update producto set producto='" + TextBox2.Text + "',cantidad=" & Val(TextBox3.Text) & ",medida=" + TextBox4.Text + " where CODIGOP=" & TextBox1.Text & "" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("los datos fueron Actualizados correctamente") oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEliminar.Click Try Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() Dim Eliminar As String = "Delete From medida where id_medida = '" & TextBox1.Text & "'" Dim comando As New OleDbCommand(Eliminar, oConn) comando.CommandType = CommandType.Text comando.ExecuteNonQuery() MessageBox.Show("Los Datos fueron Eliminados con exito", "Datos Eliminados...") oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select producto.CODIGOP,producto.producto,producto.cantidad,producto.medida,medida.M EDIDAS from producto inner join medida on producto.medida = medida.CODIGOM Where CODIGOP=" & Val(TextBox2.Text) & " OR PRODUCTO LIKE '%" & TextBox2.Text & "%'" oComm.Connection = oConn
oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOP") TextBox2.Text = oData.Item("producto") TextBox3.Text = oData.Item("cantidad") TextBox4.Text = oData.Item("medida") ComboBox1.Text = oData.Item("medidaS") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from medida Where medidaS='" & ComboBox1.Text & "'" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox4.Text = oData.Item("CODIGOM") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNuevo.Click Habilitar() cargarcodigo() End Sub Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click Me.Enabled = False Medida.Show() End Sub Private Sub BtnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click BUSCAR() End Sub
Private Sub DataGridView1_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDoubleClick Try 'TextBox1.Text = DataGridView1.SelectedCells(0).Value.ToString() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick End Sub Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress 'listar() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click principal.Enabled = True Me.Close() End Sub End Class
Imports System.Data.OleDb Public Class Medida Public Sub cargarcodigo() Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from MEDIDA" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOM") + 1 Loop oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub Bloquear() TextBox1.Enabled = False TextBox2.Enabled = False BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnGuardar.Enabled = False BtnBuscar.Enabled = True BtnNuevo.Enabled = True BtnSalir.Enabled = True BtnBuscar.Enabled = True End Sub Public Sub Habilitar() TextBox1.Enabled = False
TextBox2.Enabled = True TextBox2.Focus() BtnGuardar.Enabled = True BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnNuevo.Enabled = True BtnActualizar.Enabled = False BtnBuscar.Enabled = True BtnSalir.Enabled = True BtnOk.Visible = False End Sub Public Sub BUSCAR() TextBox1.Enabled = False TextBox2.Enabled = True TextBox2.Focus() BtnOk.Visible = True BtnGuardar.Enabled = False BtnEliminar.Enabled = True BtnActualizar.Enabled = True BtnBuscar.Enabled = True BtnSalir.Enabled = True End Sub Public Sub listar() Try Dim Consulta As String Consulta = "SELECT * FROM MEDIDA" Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub Medida_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load listar() TextBox1.Enabled = False Me.CenterToScreen() End Sub Private Sub BtnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "INSERT INTO MEDIDA(MEDIDAS)VALUES('" & TextBox2.Text & "')" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text
oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("SUS DATOS FUERON GUARDADO CORRECTAMENTE") oConn.Close() listar() Bloquear() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnActualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnActualizar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "UPDATE MEDIDA SET MEDIDAS='" & TextBox2.Text & "' WHERE CODIGOM=" & TextBox1.Text & " " Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("DATOS ACTUALIZADOS CORRECTAMENTE") oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEliminar.Click Try Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() Dim Eliminar As String = "DELETE FROM MEDIDA WHERE CODIGOM = " & TextBox1.Text & " " Dim comando As New OleDbCommand(Eliminar, oConn) comando.CommandType = CommandType.Text comando.ExecuteNonQuery() MessageBox.Show("LOS DATOS FUERON ELIMINADOS CON EXITO", "ELIMINANDO DATOS") oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click TextBox2.Enabled = True
BtnOk.Enabled = True BtnOk.Visible = True BUSCAR() End Sub Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "SELECT * FROM MEDIDA WHERE CODIGOM = " & Val(TextBox2.Text) & " OR MEDIDAS LIKE '%" & TextBox2.Text & "%' " 'Consulta = " Select * from contactos where id = " & Val(txtbuscar.Text) & " or Nombre like '%" & txtbuscar.Text & "%'" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOM") TextBox2.Text = oData.Item("MEDIDAS") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() listar() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNuevo.Click Habilitar() cargarcodigo() End Sub Private Sub BtnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSalir.Click Me.Close() PRODUCTO.Enabled = True End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PRODUCTO.Enabled = True Me.Close() End Sub End Class
Imports System.Data.OleDb Public Class USUARIO Public Sub cargarcodigo() Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from usuario" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOU") + 1 Loop oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub Bloquear() TextBox1.Enabled = False TextBox2.Enabled = False TextBox3.Enabled = False TextBox4.Enabled = False
TextBox5.Enabled = False TextBox6.Enabled = False TextBox7.Enabled = False ComboBox1.Enabled = False BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnGuardar.Enabled = False BtnBuscar.Enabled = True BtnNuevo.Enabled = True BtnSalir.Enabled = True BtnBuscar.Enabled = True End Sub Public Sub Habilitar() TextBox1.Enabled = False TextBox2.Enabled = True TextBox3.Enabled = True TextBox4.Enabled = True TextBox5.Enabled = True TextBox6.Enabled = True TextBox7.Enabled = True ComboBox1.Enabled = True TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" ComboBox1.Text = "NIVEL" TextBox2.Focus() BtnGuardar.Enabled = True BtnEliminar.Enabled = False BtnActualizar.Enabled = False BtnNuevo.Enabled = True BtnActualizar.Enabled = False BtnBuscar.Enabled = True BtnSalir.Enabled = True BtnOk.Visible = False End Sub Public Sub BUSCAR() TextBox1.Enabled = False TextBox2.Enabled = True TextBox3.Enabled = False TextBox4.Enabled = False TextBox5.Enabled = False TextBox6.Enabled = False TextBox7.Enabled = False ComboBox1.Enabled = False TextBox2.Focus() BtnOk.Visible = True BtnGuardar.Enabled = False BtnEliminar.Enabled = True BtnActualizar.Enabled = True BtnBuscar.Enabled = True BtnSalir.Enabled = True End Sub Public Sub listar() Try Dim Consulta As String Consulta = "SELECT * FROM USUARIO"
Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub listarUsuario() Try Dim Consulta As String Consulta = "SELECT usuario.codigou,usuario.nombres,usuario.apellidos,usuario.email,usuario.usuar io,usuario.contrasea,nivel.nivels from usuario INNER JOIN nivel ON usuario.nivel=nivel.nivelc where codigou=" & Val(TextBox1.Text) & "" Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Public Sub cargarNivel() Try ComboBox1.Items.Clear() Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim comando As New OleDbCommand() comando.CommandText = "SELECT * FROM NIVEL" comando.Connection = oConn oConn.Open() Dim oData As OleDbDataReader = comando.ExecuteReader() If oData.HasRows Then While oData.Read() ComboBox1.Items.Add(oData("NIVELS").ToString()) End While End If oData.Close() Catch RED As Exception
MessageBox.Show(RED.Message.ToString()) End Try End Sub Private Sub USUARIO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If usuarios.condicion = 1 Then listar() cargarNivel() Else TextBox1.Text = usuarios.codigo Bloquear() cargarNivel() BUSCAR() listarUsuario() lista() End If End Sub Private Sub BtnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "Insert Into usuario(nombres,apellidos,email,usuario,contrasea,nivel)values('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "'," & Val(TextBox7.Text) & ")" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("Los datos fueron guardados correctamente") oConn.Close() listar() Bloquear() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnActualizar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnActualizar.Click Try Dim oConn As New OleDbConnection oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim Guardar As String = "update usuario set nombres='" + TextBox2.Text + "',apellidos='" + TextBox3.Text + "',email='" + TextBox4.Text + "',usuario='" + TextBox5.Text + "',contrasea='" + TextBox6.Text + "',nivel=" & Val(TextBox7.Text) & " where CODIGOU=" & Val(TextBox1.Text) & "" Dim oData As New OleDbCommand(Guardar, oConn) oData.CommandType = CommandType.Text oConn.Open() oData.ExecuteNonQuery() MessageBox.Show("Los datos fueron Actualizados correctamente")
oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEliminar.Click Try Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() Dim Eliminar As String = "Delete From usuario where nombres = '" & TextBox2.Text & "'" Dim comando As New OleDbCommand(Eliminar, oConn) comando.CommandType = CommandType.Text comando.ExecuteNonQuery() MessageBox.Show("Los Datos fueron Eliminados con exito", "Datos Eliminados...") oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOK.Click Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select usuario.CODIGOU,usuario.nombres,usuario.apellidos,usuario.email,usuario.contr asea,usuario.nivel,nivel.nivelc from usuario inner join nivel on usuario.nivel = nivel.nivelc Where CODIGOU=" & Val(TextBox2.Text) & " OR NOMBRES LIKE '%" & TextBox2.Text & "%'" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOU") TextBox2.Text = oData.Item("NOMBRES") TextBox3.Text = oData.Item("APELLIDOS") TextBox4.Text = oData.Item("EMAIL") TextBox5.Text = oData.Item("USUARIO") TextBox6.Text = oData.Item("CONTRASEA") TextBox6.Text = oData.Item("NIVEL") ComboBox1.Text = oData.Item("NIVELS") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString())
End Try End Sub Private Sub lista() Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select usuario.CODIGOU,usuario.nombres,usuario.apellidos,usuario.email,usuario.usuar io,usuario.contrasea,usuario.nivel,nivel.nivels from usuario inner join nivel on usuario.nivel = nivel.nivelc Where CODIGOU=" & Val(TextBox1.Text) & "" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox1.Text = oData.Item("CODIGOU") TextBox2.Text = oData.Item("NOMBRES") TextBox3.Text = oData.Item("APELLIDOS") TextBox4.Text = oData.Item("EMAIL") TextBox5.Text = oData.Item("USUARIO") TextBox6.Text = oData.Item("CONTRASEA") TextBox6.Text = oData.Item("NIVEL") ComboBox1.Text = oData.Item("NIVELS") Loop TextBox1.Visible = True Label1.Visible = True oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Try Dim oConn As New OleDbConnection Dim oComm As New OleDbCommand Dim oData As OleDbDataReader oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" oConn.Open() oComm.CommandText = "Select * from NIVEL Where NIVELS='" & ComboBox1.Text & "'" oComm.Connection = oConn oData = oComm.ExecuteReader() Do While oData.Read() TextBox7.Text = oData.Item("NIVELC") Loop TextBox1.Visible = True Label1.Visible = True
oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNuevo.Click Habilitar() cargarcodigo() End Sub Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click Me.Enabled = False Medida.Show() End Sub Private Sub BtnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuscar.Click BUSCAR() End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick Try 'TextBox1.Text = DataGridView1.SelectedCells(0).Value.ToString() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub BtnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSalir.Click Dim X As String X = MessageBox.Show("DESEA SALIR DEL PROGRAMA", "CUIDADO ==== CERRAR ====", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) If X = MessageBoxButtons.OKCancel Then End Exit Sub End If End Sub Private Sub btn_atras_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_atras.Click principal.Enabled = True Me.Close() End Sub End Class
Imports System.Data.OleDb Public Class LISTAR_USUARIO Public Sub listar() Try Dim Consulta As String Consulta = "SELECT usuario.codigou,usuario.nombres,usuario.apellidos,usuario.email,usuario.usuar io,nivel.nivels from usuario INNER JOIN nivel ON usuario.nivel=nivel.nivelc" Dim oConn As New OleDbConnection() oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\facturacion.accdb;Persist Security Info=False;" Dim ObjDataSet As New DataSet() Dim Cargar As New DataTable() Dim objAdap As New OleDbDataAdapter(Consulta, oConn) oConn.Open() objAdap.Fill(Cargar) Me.DataGridView1.DataSource = Cargar oConn.Close() Catch ex As Exception MsgBox(ex.Message.ToString()) End Try End Sub Private Sub LISTAR_USUARIO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load listar() End Sub
Private Sub btn_atras_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_atras.Click principal.Enabled = True Me.Close() End Sub End Class