Action
tLocalhost = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Localhost"), "trustno1withthispassword");
tUsuario = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Usuario"), "trustno1withthispassword");
tContrasena = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Contrasena"), "trustno1withthispassword");
tBasedatos = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Basedatos"), "trustno1withthispassword");
tPuerto = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Puerto"), "trustno1withthispassword");
if tLocalhost == "" or tUsuario == "" or tContrasena == "" or tBasedatos == "" or tPuerto == "" then
tLocalhost = ""
tUsuario = ""
tContrasena = ""
tBasedatos = ""
tPuerto = ""
if ( DialogEx.Show("Localhost", true, nil, nil) == IDOK) then
tLocalhost = Crypto.BlowfishEncryptString(tLocalhost, "trustno1withthispassword", 0);
INIFile.SetValue("Settings.ini", "Accesos", "Localhost", tLocalhost);
tUsuario = Crypto.BlowfishEncryptString(tUsuario, "trustno1withthispassword", 0);
INIFile.SetValue("Settings.ini", "Accesos", "Usuario", tUsuario);
tContrasena = Crypto.BlowfishEncryptString(tContrasena, "trustno1withthispassword", 0);
INIFile.SetValue("Settings.ini", "Accesos", "Contrasena", tContrasena);
tBasedatos = Crypto.BlowfishEncryptString(tBasedatos, "trustno1withthispassword", 0);
INIFile.SetValue("Settings.ini", "Accesos", "Basedatos", tBasedatos);
tPuerto = Crypto.BlowfishEncryptString(tPuerto, "trustno1withthispassword", 0);
INIFile.SetValue("Settings.ini", "Accesos", "Puerto", tPuerto);
tLocalhost = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Localhost"), "trustno1withthispassword");
tUsuario = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Usuario"), "trustno1withthispassword");
tContrasena = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Contrasena"), "trustno1withthispassword");
tBasedatos = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Basedatos"), "trustno1withthispassword");
tPuerto = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Puerto"), "trustno1withthispassword");
MySQLConnection = MySQL.Connect(tLocalhost, tUsuario, tContrasena, tBasedatos, tPuerto);
if (MySQLConnection ~= 0) then
error = Application.GetLastError();
Dialog.Message("Error",error.."\n\n El proceso de comunicación entre el sistema y el BD no es válido por este motivo La aplicación se cerrará");
INIFile.SetValue("Settings.ini", "Accesos", "Localhost", "");
INIFile.SetValue("Settings.ini", "Accesos", "Usuario", "");
INIFile.SetValue("Settings.ini", "Accesos", "Contrasena", "");
INIFile.SetValue("Settings.ini", "Accesos", "Basedatos", "");
INIFile.SetValue("Settings.ini", "Accesos", "Puerto", "");
Application.Exit(0);
end
sData = INIFile.GetValue(_SourceFolder .. "\\AutoPlay\\Docs\\Barra.dll", "Barra", "Arranque");
if sData == "No" then
Page.Jump("Conecte-se");
else
DialogEx.Show("Carga", true, nil, nil);
end
else
end
else
tLocalhost = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Localhost"), "trustno1withthispassword");
tUsuario = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Usuario"), "trustno1withthispassword");
tContrasena = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Contrasena"), "trustno1withthispassword");
tBasedatos = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Basedatos"), "trustno1withthispassword");
tPuerto = Crypto.BlowfishDecryptString(INIFile.GetValue("Settings.ini", "Accesos", "Puerto"), "trustno1withthispassword");
MySQLConnection = MySQL.Connect(tLocalhost, tUsuario, tContrasena, tBasedatos, tPuerto);
if (MySQLConnection ~= 0) then
error = Application.GetLastError();
Dialog.Message("Error",error.."\n\n El proceso de comunicación entre el sistema y el BD no es válido por este motivo La aplicación se cerrará");
INIFile.SetValue("Settings.ini", "Accesos", "Localhost", "");
INIFile.SetValue("Settings.ini", "Accesos", "Usuario", "");
INIFile.SetValue("Settings.ini", "Accesos", "Contrasena", "");
INIFile.SetValue("Settings.ini", "Accesos", "Basedatos", "");
INIFile.SetValue("Settings.ini", "Accesos", "Puerto", "");
Application.Exit(0);
end
sData = INIFile.GetValue(_SourceFolder .. "\\AutoPlay\\Docs\\Barra.dll", "Barra", "Arranque");
if sData == "No" then
Page.Jump("Conecte-se");
else
DialogEx.Show("Carga", true, nil, nil);
end
end
Boton Guardar
--RECOGE LO ESCRITO EN LOS OBJETOS
local tCodigo = Input.GetText("INP_CODIGO");
local tApellidosNombres = Input.GetText("INP_APELLIDOSNOMBRES");
local tUsuario = Input.GetText("INP_USUARIO");
local tContrasena = Input.GetText("INP_CONTRASENA");
local tTipocuenta = Input.GetText("INP_TIPOCUENTA");
local tDependencia = ComboBox.GetText("CBX_DEPENDENCIA");
local tSexo = Input.GetText("INP_SEXO");
local tEmail = Input.GetText("INP_EMAIL");
local tFecha = Input.GetText("INP_FECHA");
--CONDICION SI NO HAY NADA ESCRITO
if (tApellidosNombres == "" or tUsuario == "" or tContrasena == "" or tTipocuenta == "" or tDependencia == "" or tSexo == "" or tEmail == "" or tFecha == "") then
Dialog.TimedMessage("Error", "No has escrito algun campo del usuario", 2000, MB_ICONSTOP);
else
--CONDICION PARA GUARDAR SIN QUE SE REPITA
if (tNovoUsuario == true) then
tSelected = MySQL.QueryToTable("SELECT * FROM usuarios WHERE USUARIO LIKE '"..tUsuario.."%'");
if tSelected == nil then
if not rData then
MySQL.Query("INSERT INTO usuarios (ID, CODIGO, APELLIDOSNOMBRES, USUARIO, CONTRASENA, TIPOCUENTA, DEPENDENCIA, SEXO, EMAIL, FECHA) VALUES (NULL, '"
..tCodigo.."', '"
..tApellidosNombres.."', '"
..tUsuario.."', '"
..tContrasena.."','"
..tTipocuenta.."','"
..tDependencia.."','"
..tSexo.."', '"
..tEmail.."', '"
..tFecha.."')")
Dialog.TimedMessage("Registro completo", "El usuario ("..tUsuario..") fue registrado con exito", 2000, MB_ICONINFORMATION);
xButton.SetVisible("xButton1", true);
xButton.SetVisible("xButton3", true);
xButton.SetVisible("xButton2", false);
xButton.SetVisible("xButton4", false);
Page.ClickObject("xButton10");
tContePagina();
else
end
else
Dialog.TimedMessage("Sistema de Control de Personal", "("..tUsuario..") ya existe en el Sistema.", 3000, MB_ICONSTOP);
end
end
--CONDICION PARA MODIFICAR SIN QUE SE REPITA
if (tNovoUsuario == false) then
tSelected = MySQL.QueryToTable("SELECT * FROM usuarios WHERE USUARIO LIKE '"..tUsuario.."%'");
if tSelected == nil then
if not rData then
MySQL.Query("UPDATE usuarios SET CODIGO ='"
..tCodigo.."',APELLIDOSNOMBRES ='"
..tApellidosNombres.."',USUARIO ='"
..tUsuario.."',CONTRASENA ='"
..tContrasena.."',TIPOCUENTA ='"
..tTipocuenta.."',DEPENDENCIA ='"
..tDependencia.."',SEXO ='"
..tSexo.."',EMAIL ='"
..tEmail.."',FECHA ='"
..tFecha.."'WHERE ID ="..nID)
Dialog.TimedMessage("Datos atualizados", "Los datos del usuario se actualizaron con éxito "..tUsuario, 2000, MB_ICONINFORMATION);
xButton.SetVisible("xButton1", true);
xButton.SetVisible("xButton3", true);
xButton.SetVisible("xButton2", false);
xButton.SetVisible("xButton4", false);
sPesquisarPaginas();
else
end
else
Dialog.TimedMessage("Sistema de Control de Personal", "("..tUsuario..") ya existe en el Sistema.", 3000, MB_ICONSTOP);
end
end
end
On preload Pagina
--LIMPIA LOS REGISTROS AL CERRAR DIALOGO O PAGINA
tApellidosNombres = Input.SetText("INP_APELLIDOSNOMBRES", "")
tUsuario = Input.SetText("INP_USUARIO", "")
tContrasena = Input.SetText("INP_CONTRASENA", "")
tTipocuenta = Input.SetText("INP_TIPOCUENTA", "")
tDependencia = ComboBox.GetText("CBX_DEPENDENCIA")
tSexo = Input.SetText("INP_SEXO", "")
tEmail = Input.SetText("INP_EMAIL", "")
tFecha = Input.SetText("INP_FECHA", "")
---------------------------------------------------<< CONTAR E DIVIDIR EM PAGINAS >>
function tContePagina()
tbResults = MySQL.QueryToTable("SELECT COUNT(*) AS COUNT FROM usuarios");
if Application.GetLastError() == 0 then
for i,row in pairs (tbResults) do
for j,tConte in pairs (row) do
Input.SetText("Total", tConte);
nConte = String.ToNumber(Grid.GetRowCount("Grid1") - tConte)
tPagina = Math.Round(tConte / ComboBox.GetText("ComboBox1"), 0);
nConte = String.ToNumber(tPagina)+1
end
Input.SetText("Paginas", nConte);
end
end
end
---------------------------------<< PESQUISAR RECORD ID AUTO INCREMENT >>
function tRecordID()
tID = "0"
tSelected = MySQL.QueryToTable("SELECT * FROM usuarios WHERE ID")
if Application.GetLastError() == 0 then
for i,row in pairs (tSelected) do
tID = i
end
end
Input.SetText("INP_CODIGO", string.format("%010d",String.ToNumber(tID) +1));
end
----<< LIMITAR TABELA FROM PRODUTOS E ORDER by ASC ID DESC LIMIT >>
function sPesquisarPaginas()
Grid.DeleteNonFixedRows("Grid1", true);
Grid.SetCellText("Grid1", 0, 0, "ID", false);
Grid.SetCellText("Grid1", 0, 1, "APELLIDOSNOMBRES", false);
Grid.SetCellText("Grid1", 0, 2, "USUARIO", false);
Grid.SetCellText("Grid1", 0, 3, "CONTRASENA", false);
Grid.SetCellText("Grid1", 0, 4, "TIPOCUENTA", false);
Grid.SetCellText("Grid1", 0, 5, "DEPENDENCIA", false);
Grid.SetCellText("Grid1", 0, 6, "SEXO", false);
Grid.SetCellText("Grid1", 0, 7, "EMAIL", false);
Grid.SetCellText("Grid1", 0, 8, "FECHA", false);
Grid.ExpandColumnsToFit("Grid1", true, true);
Grid.Refresh("Grid1")
sPaginas = Input.GetText("Paginas")-1;
sPaginas = Math.Round(sPaginas *ComboBox.GetText("ComboBox1"), 1);
sOrdena_p = ComboBox.GetText("ComboBox2");-----<< Order by com ASC e DESC >>
tSelected = MySQL.QueryToTable("SELECT ID, CODIGO, APELLIDOSNOMBRES, USUARIO, CONTRASENA, TIPOCUENTA,DEPENDENCIA, SEXO, EMAIL, FECHA FROM usuarios ORDER BY CODIGO "..sOrdena_p.." LIMIT "..sPaginas..","..ComboBox.GetText("ComboBox1"));
if Application.GetLastError() == 0 then
for nRow, x in pairs (tSelected) do
tCodigo = tSelected[nRow][2];
tApellidosNombres = tSelected[nRow][3];
tUsuario = tSelected[nRow][4];
tContrasena = tSelected[nRow][5];
tTipocuenta = tSelected[nRow][6];
tDependencia = tSelected[nRow][7];
tSexo = tSelected[nRow][8];
tEmail = tSelected[nRow][9];
tFecha = tSelected[nRow][10];
local nLine = Grid.InsertRow("Grid1", -1, false);
Grid.SetCellText("Grid1", nLine, 0, tCodigo, false);
Grid.SetCellText("Grid1", nLine, 1, tApellidosNombres, false);
Grid.SetCellText("Grid1", nLine, 2, tUsuario, false);
Grid.SetCellText("Grid1", nLine, 3, tContrasena, false);
Grid.SetCellText("Grid1", nLine, 4, tTipocuenta, false);
Grid.SetCellText("Grid1", nLine, 5, tDependencia, false);
Grid.SetCellText("Grid1", nLine, 6, tSexo, false);
Grid.SetCellText("Grid1", nLine, 7, tEmail, false);
Grid.SetCellText("Grid1", nLine, 8, tFecha, false);
end
end
end
--COLOCAR FECHA AUTOMATICA EN EL INPUT FECHA
d = System.GetDate(DATE_FMT_DAY)
m = System.GetDate(DATE_FMT_MONTH)
a = System.GetDate(DATE_FMT_YEAR)
if d == 1 or d == 2 or d == 3 or d == 4 or d == 5 or d == 6 or d == 7 or d == 8 or d == 9 then
Input.SetText("INP_FECHA", a.."-"..m.."-".."0"..d)
else
Input.SetText("INP_FECHA", a.."-"..m.."-"..d)
end
nID = ""
On show pagina
local UserIngreso = INIFile.GetValue("UserIngreso.ini", "general", "tUsuarioEnter")
Paragraph.SetText("PG_USUARIOREGISTRO", UserIngreso)
tRecordID();
tContePagina();
sPesquisarPaginas();
j = true
------------------------<< PESQUISAR USUÁRIOS >>
function sPesquisarUsuario()
Grid.DeleteNonFixedRows("Grid1", true);
Grid.DeleteNonFixedRows("Grid1", true);
Grid.SetCellText("Grid1", 0, 0, "ID", false);
Grid.SetCellText("Grid1", 0, 1, "APELLIDOSNOMBRES", false);
Grid.SetCellText("Grid1", 0, 2, "USUARIO", false);
Grid.SetCellText("Grid1", 0, 3, "CONTRASENA", false);
Grid.SetCellText("Grid1", 0, 4, "TIPOCUENTA", false);
Grid.SetCellText("Grid1", 0, 5, "DEPENDENCIA", false);
Grid.SetCellText("Grid1", 0, 6, "SEXO", false);
Grid.SetCellText("Grid1", 0, 7, "EMAIL", false);
Grid.SetCellText("Grid1", 0, 8, "FECHA", false);
Grid.ExpandColumnsToFit("Grid1", true, true);
Grid.Refresh("Grid1")
tSelected = MySQL.QueryToTable("SELECT ID, CODIGO, APELLIDOSNOMBRES, USUARIO, CONTRASENA, TIPOCUENTA, DEPENDENCIA, SEXO, EMAIL, FECHA FROM usuarios WHERE USUARIO LIKE '"..sPesquisar.."%' or ID LIKE '"..sPesquisar.."%'");
if Application.GetLastError() == 0 then
for nRow, x in pairs (tSelected) do
tCodigo = tSelected[nRow][2];
tApellidosNombres = tSelected[nRow][3];
tUsuario = tSelected[nRow][4];
tContrasena = tSelected[nRow][5];
tTipocuenta = tSelected[nRow][6];
tDependencia = tSelected[nRow][7];
tSexo = tSelected[nRow][8];
tEmail = tSelected[nRow][9];
tFecha = tSelected[nRow][10];
local nLine = Grid.InsertRow("Grid1", -1, false);
Grid.SetCellText("Grid1", nLine, 0, tCodigo, false);
Grid.SetCellText("Grid1", nLine, 1, tApellidosNombres, false);
Grid.SetCellText("Grid1", nLine, 2, tUsuario, false);
Grid.SetCellText("Grid1", nLine, 3, tContrasena, false);
Grid.SetCellText("Grid1", nLine, 4, tTipocuenta, false);
Grid.SetCellText("Grid1", nLine, 5, tDependencia, false);
Grid.SetCellText("Grid1", nLine, 6, tSexo, false);
Grid.SetCellText("Grid1", nLine, 7, tEmail, false);
Grid.SetCellText("Grid1", nLine, 8, tFecha, false);
end
end
end
-------------------------------------------------------------------------------------------
--JALAR INFO DE CAMPO DE TABLA A COMBOBOX TIPODOCUMENTO
tSelected = MySQL.QueryToTable("SELECT * FROM dependencias ORDER BY CODIGO ASC");
ComboBox.ResetContent("CBX_DEPENDENCIA")
if Application.GetLastError() == 0 then
for nRow, x in pairs (tSelected) do
tCodigo = tSelected[nRow][2];
tDependencia = tSelected[nRow][3];
ComboBox.AddItem("CBX_DEPENDENCIA", tDependencia, nRow);
ComboBox.SetSelected("CBX_DEPENDENCIA", 1)
end
end
Page.SetFocus("CBX_DEPENDENCIA")
Page.StartTimer(1000, 11)
-------------------------------------------------------------------------------------------
On Selection Change Grid
xData = Grid.GetCellText("Grid1", e_Row, 0);
if xData ~= "" then
nID = String.ToNumber(xData);
tSelected = MySQL.QueryToTable("SELECT * FROM usuarios WHERE ID ="..nID.."")
if Application.GetLastError() == 0 then
for nRow, x in pairs (tSelected) do
Input.SetText("INP_CODIGO", tSelected[nRow][2]);
Input.SetText("INP_APELLIDOSNOMBRES", tSelected[nRow][3]);
Input.SetText("INP_USUARIO", tSelected[nRow][4]);
Input.SetText("INP_CONTRASENA", tSelected[nRow][5]);
Input.SetText("INP_TIPOCUENTA", tSelected[nRow][6]);
ComboBox.SetText("CBX_DEPENDENCIA", tSelected[nRow][7]);
Input.SetText("INP_SEXO", tSelected[nRow][8]);
Input.SetText("INP_EMAIL", tSelected[nRow][9]);
Input.SetText("INP_FECHA", tSelected[nRow][10]);
xButton.SetVisible("xButton1", true);
xButton.SetVisible("xButton3", true);
xButton.SetVisible("xButton2", false);
xButton.SetVisible("xButton4", false);
end
end
end
sCor_a = {}
sCor_a.e_Row = e_Row
sCor_a.e_Column = e_Column
if sCor_b then
for b=0,10 do
Grid.SetCellColors("Grid1", sCor_b.e_Row, b, {Background=16777215,Text=0}, true);
end
sCor_b = nil
end
if sCor_a then
if sCor_a.e_Row > 0 then
for a=0,10 do
Grid.SetCellColors("Grid1", sCor_a.e_Row, a, {Background=10526975,Text=8393216}, true);
sCor_b = {}
sCor_b = sCor_a
end
end
end