*MENU*

*CLAVE*

PUBLIC c AS Integer
PUBLIC n AS String
PUBLIC SUB TextBox1_Change()

TextBox2.Enabled = TRUE
END
PUBLIC SUB TextBox2_KeyPress()
IF Key।Code = 65293 THEN

IF TextBox1।Text = "" THEN

Message.Info("Ingrese Clave de Usuario...")
TextBox1.SetFocus
ELSE
Button1.Enabled = TRUE
Button2.Enabled = TRUE
Button1.SetFocus
ENDIF
ENDIF
END
PUBLIC SUB Form_Open()
ME.Center
modulo.conectar
modulo.rs = modulo.cn.Exec("select * from claves")
n = "Administrador"
END
PUBLIC SUB Button1_Click()
DIM ban AS Integer
DO WHILE modulo.rs.Available
n = modulo.rs["usuario"]
IF modulo.rs["usuario"] = Trim(TextBox1.Text) AND modulo.rs["contrasena"] = Trim(TextBox2.Text) थें

modulo.rs = modulo.cn.Exec("select * from claves where usuario = '" & Trim(TextBox1.Text) & "'")
Message.Info("Bienvenido al sistema Sr. " & n, "Aceptar")
ME.Hi

menuprincipal.Show

ban = 1
ENDIF
modulo.rs.MoveNext()
LOOP
IF ban = 0 THEN
c = c + 1
IF c = 3 THEN
Message.Warning("Lo sentimos, El sistema se cerrar por seguridad.")
ME.Close
ELSE
limpiar()
TextBox1.SetFocus
Message.Error("Usuario desconocido, intente nuevamente...", "Aceptar")
ENDIF
END IF
END

PUBLIC SUB TextBox1_KeyPress()
IF Key.Code = 65293 THEN
IF TextBox1.Text = "" THEN
Message.Info("Ingrese Nombre de Usuario...")
TextBox1.SetFocus
ELSE
TextBox2.SetFocus
ENDIF
ENDIF
END
PUBLIC SUB limpiar()
Button1.Enabled = FALSE
Button2.Enabled = FALSE
TextBox1.Clear
TextBox2.Clear
TextBox2.Enabled = FALSE
TextBox1.SetFocus
END
PUBLIC SUB Button2_Click()
limpiar()
END
*INVENTARIO*
PUBLIC con AS Integer
PUBLIC fil AS Integer
PUBLIC col AS Integer
PUBLIC SUB Form_Open()
Modulo.conectar
Modulo.rs = modulo.cn.Exec("select * from Producto")
mostrar()
END
PUBLIC SUB Button5_Click()
ME.Close
END
PUBLIC SUB Button2_Click()
TRY Modulo.cn.Exec("insert into Producto values('" & Trim(UCase(TextBox1.Text)) & "','" & Trim(UCase(TextBox2.Text)) & "','" & (TextBox3.Text) & "','" & (ValueBox2.Text) & "');")
IF ERROR THEN
Message.Error("Imposible insertar el registro")
ELSE
Message.Info("Registro insertado")
END IF
Modulo.rs = Modulo.cn.Exec("Select * from Producto")
mostrar()
limpiar()
END

PUBLIC SUB Button3_Click()
SELECT Message.Question("Desea eliminar un Producto", "Si", "No")
CASE 1
TRY Modulo.cn.Exec("Delete from Producto where codigo='" & Trim(UCase(TextBox1.Text)) & "'")
IF ERROR THEN
Message.Error("Imposible borrar el registro")
ELSE
Modulo.rs = Modulo.cn.Exec("select * from Producto")
mostrar()
END IF
CASE 2
Message.Info("Registro no eliminado")
CASE 3
END SELECT
limpiar()
END
PUBLIC SUB Button4_Click()
DIM ban AS Integer
Modulo.rs = Modulo.cn.Exec("select * from Producto")
DO WHILE Modulo.rs.Available
IF modulo.rs["Codigo"] = Trim(UCase(TextBox1.Text)) THEN
Modulo.rs = Modulo.cn.Exec("select * from Producto where Codigo = '" & Trim(UCase(TextBox1.Text)) & "'")
TextBox2.Text = Modulo.rs["Nombre"]
TextBox3.Text = Modulo.rs["Precio"]
ValueBox2.Value = Modulo.rs["Cantidad"]
ban = 1
ENDIF
MODULO.rs.MoveNext()
LOOP
IF ban = 0 THEN
Message.Error("Registro Invalido")
limpiar()
END IF
END
PUBLIC SUB limpiar()
TextBox1.Clear
TextBox2.Clear
TextBox3.Clear
TextBox3.Text = 0
ValueBox2.Clear
END
PUBLIC SUB Grid1_DblClick()
IF Grid1.Current = NULL THEN RETURN
SELECT Message.Question("Desea eliminar un Producto", "Si", "No", "Ayuda")
CASE 1
TRY Modulo.cn.Exec("Delete from Producto where Codigo='" & Trim(UCase(Grid1.Current.Text)) & "'")
IF ERROR THEN
Message.Error("Imposible borrar el registro")
ELSE
Modulo.rs = Modulo.cn.Exec("select * from Producto")
mostrar()
END IF
CASE 2
Message.Info("Registro no eliminado")
CASE 3
END SELECT
Grid1.Columns.Width = 100
END
PUBLIC SUB Grid1_Click()
END
PUBLIC SUB Button6_Click()
TRY Modulo.cn.Exec("update Producto set Nombre='" & Trim(UCase(TextBox2.Text)) & "',Precio='" & Trim(UCase(TextBox3.Text)) & "',Cantidad='" & Trim(UCase(ValueBox2.Text)) & "' where codigo='" & Trim(TextBox1.Text) & "'")
IF ERROR THEN
Message.Error("Imposible actualizar el registro")
ELSE
Message.Info("Registro actualizado")
END IF
mostrar()
limpiar()
END
PUBLIC SUB Button1_Click()
limpiar
END
*PROVEEDOR*
PUBLIC SUB mostrar()
Modulo.rs.MoveFirst
IF Modulo.rs.Count > 0 THEN
Grid1.Columns.Count = 4
Grid1.Rows.Count = Modulo.rs.Count + 1
Grid1.Columns[1].Width = 30
Grid1.Columns[1].Width = 30
Grid1[0, 0].Text = "Codigo"
Grid1[0, 1].Text = "Nombre"
Grid1[0, 3].Text = "Precio Unitario"
Grid1[0, 2].Text = "Cantidad"
fil = 1
Modulo.rs.MoveFirst
'con = Modulo.rs.Count
DO WHILE Modulo.rs.Available
Grid1[fil, 0].Text = Modulo.rs["Codigo"]
Grid1[fil, 1].Text = Modulo.rs["Nombre"]
Grid1[fil, 2].Text = Modulo.rs["Cantidad"]
Grid1[fil, 3].Text = Modulo.rs["Precio"]
fil = fil + 1
Modulo.rs.MoveNext()
LOOP
ENDIF
END
*INGRESO DE USUARIO*
PUBLIC fil AS Integer
PUBLIC SUB TextBox1_Change()
TextBox2.Enabled = TRUE
END
PUBLIC SUB Button3_Click()
TRY modulo.cn.Exec("update into claves values('" & ("idclave") & "','" & Trim(TextBox1.Text) & "', '" & Trim(TextBox2.Text) & "' )")
IF ERROR THEN
Message.Error("Imposible actualizar el registro")
ELSE
Message.Info("Registro actualizado")
END IF
mostrar()
limpiar()
END
PUBLIC SUB limpiar()
TextBox1.Clear
TextBox2.Clear
END
PUBLIC SUB mostrar()
modulo.rs.MoveFirst
IF modulo.rs.Count > 0 THEN
GridView1.Columns.Count = 3
GridView1.Rows.Count = modulo.rs.Count + 1
GridView1.Columns[0].Width = 50
GridView1.Columns[1].Width = 250
GridView1.Columns[2].Width = 250
GridView1[0, 0].Text = "idclave"
GridView1[0, 1].Text = "usuario"
GridView1[0, 2].Text = "contrasena"
fil = 1
modulo.rs.MoveFirst
DO WHILE modulo.rs.Available
GridView1[fil, 0].Text = modulo.rs["idclave"]
GridView1[fil, 1].Text = modulo.rs["usuario"]
GridView1[fil, 2].Text = modulo.rs["contrasena"]
fil = fil + 1
modulo.rs.MoveNext()
LOOP
ENDIF
END
PUBLIC SUB Form_Open()
ME.Center
modulo.conectar
modulo.rs = modulo.cn.Exec("select * from claves")
mostrar()
desbotones()
END
PUBLIC SUB TextBox1_KeyPress()
IF Key.Code = 65293 THEN
IF TextBox1.Text = "" THEN
Message.Info("Ingrese Nombre de Usuario...")
TextBox1.SetFocus
ELSE
TextBox2.SetFocus
ENDIF
ENDIF
END
PUBLIC SUB TextBox2_KeyPress()
IF Key.Code = 65293 THEN
IF TextBox1.Text = "" THEN
Message.Info("Ingrese Clave de Usuario...")
TextBox1.SetFocus
ELSE
habotones()
Button3.SetFocus
ENDIF
ENDIF
END
PUBLIC SUB desbotones()
Button3.Enabled = FALSE
Button4.Enabled = FALSE
Button5.Enabled = FALSE
END
PUBLIC SUB habotones()
Button3.Enabled = TRUE
Button4.Enabled = TRUE
Button5.Enabled = TRUE
END
PUBLIC SUB Button6_Click()
menuprincipal.Show
ME.Hide
END
PUBLIC SUB Button2_Click()
TRY modulo.cn.Exec("insert into claves values('" & ("idclave") & "','" & Trim(TextBox1.Text) & "', '" & Trim(TextBox2.Text) & "' )")
IF ERROR THEN
Message.Error("Imposible Ingresar el usuario...")
ELSE
Message.Info("Usuario Ingresado...")
ENDIF
modulo.rs = modulo.cn.Exec("select * from claves")
mostrar()
limpiar()
END
PUBLIC SUB Button4_Click()
SELECT Message.Question("Desea eliminar una claves", "Si", "No")
CASE 1
TRY Modulo.cn.Exec("Delete from claves where usuario='" & Trim(UCase(TextBox1.Text)) & "'")
IF ERROR THEN
Message.Error("Imposible borrar el registro")
ELSE
Modulo.rs = Modulo.cn.Exec("select * from claves")
mostrar()
END IF
CASE 2
Message.Info("Registro no eliminado")
CASE 3
END SELECT
limpiar()
END
PUBLIC SUB Button5_Click()
DIM ban AS Integer
Modulo.rs = Modulo.cn.Exec("select * from claves")
DO WHILE Modulo.rs.Available
IF modulo.rs["usuario"] = Trim(UCase(TextBox1.Text)) THEN
Modulo.rs = Modulo.cn.Exec("select * from claves where usuario = '" & Trim(UCase(TextBox1.Text)) & "'")
TextBox1.Text = Modulo.rs["usuario"]
TextBox2.Text = Modulo.rs["contrasena"]
ban = 1
ENDIF
MODULO.rs.MoveNext()
LOOP
IF ban = 0 THEN
Message.Error("Registro Invalido")
limpiar()
END IF
END