Ahora es posible abrir el fichero MDB con otras versines de Access

This commit is contained in:
Juan Ferrer Toribio 2017-09-22 14:36:15 +02:00
parent 7158d9d72e
commit 2433b4377a
1 changed files with 41 additions and 20 deletions

View File

@ -1,13 +1,33 @@
var Conf = var Conf =
{ {
appName: 'Verdnatura', appName: 'Verdnatura'
dsName: 'verdnatura', ,dsName: 'verdnatura'
dsPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\verdnatura', ,dsPath: 'HKCU\\Software\\ODBC\\ODBC.INI\\verdnatura'
regPath: 'HKCU\\Software\\Verdnatura\\vn-access', ,regPath: 'HKCU\\Software\\Verdnatura\\vn-access'
remoteUrl: 'https://www.verdnatura.es/vn-access', ,remoteUrl: 'https://verdnatura.es/vn-access'
dbHost: 'db.verdnatura.es', ,dbHost: 'db.verdnatura.es'
defaultModule: 'tpv' ,defaultModule: 'tpv'
,defaultLocale: 'es'
};
var Locale ={
es: {
"Enter a user name":
"Introduce un nombre de usuario"
,"Enter a password":
"Introduce una contraseña"
,"Server can't be reached":
"No se ha podido conectar con el servidor"
,"Updating":
"Actualizando"
,"Bad login":
"Usuario o contraseña incorrectos"
,"Loading":
"Cargando"
,"Error while updating":
"Error al actualizar"
}
}; };
var App = var App =
@ -191,7 +211,7 @@ var App =
_onEnterClick: function () _onEnterClick: function ()
{ {
this._disableUi (true, 'Cargando'); this._disableUi (true, _('Loading'));
setTimeout (function () {App.login();}, 0); setTimeout (function () {App.login();}, 0);
}, },
@ -202,9 +222,9 @@ var App =
try { try {
if (!user || user === '') if (!user || user === '')
throw new Error ('Introduce un nombre de usuario'); throw new Error (_('Enter a user name'));
if (!password || password === '') if (!password || password === '')
throw new Error ('Introduce una contraseña'); throw new Error (_('Enter a password'));
this.regWrite (Conf.dsPath, 'UID', user, 'REG_SZ'); this.regWrite (Conf.dsPath, 'UID', user, 'REG_SZ');
this.regWrite (Conf.dsPath, 'PWD', password, 'REG_SZ'); this.regWrite (Conf.dsPath, 'PWD', password, 'REG_SZ');
@ -225,17 +245,14 @@ var App =
{ {
var errorMsg; var errorMsg;
var dbError = dbErrors.item(0); var dbError = dbErrors.item(0);
alert (dbError.description );
switch (dbError.NativeError) switch (dbError.NativeError)
{ {
case 1045: // Access denied case 1045: // Access denied
errorMsg = 'Usuario o contraseña incorrectos'; errorMsg = _('Bad login');
break; break;
case 2003: // Can't connect case 2003: // Can't connect
errorMsg = 'No se ha podido conectar con el ' errorMsg = _('Server can\'t be reached');
+'servidor, comprueba que tienes conexión a '
+'Internet y que el servidor está accesible';
break; break;
default: default:
errorMsg = dbError.description; errorMsg = dbError.description;
@ -277,7 +294,7 @@ var App =
if (localVersion < lastVersion) if (localVersion < lastVersion)
{ {
this._disableUi (true, 'Actualizando'); this._disableUi (true, _('Updating'));
var request = new ActiveXObject ('MSXML2.XMLHTTP'); var request = new ActiveXObject ('MSXML2.XMLHTTP');
request.open ('GET', this.remoteFile +'?'+ new Date().getTime(), true); request.open ('GET', this.remoteFile +'?'+ new Date().getTime(), true);
request.onreadystatechange = function () { request.onreadystatechange = function () {
@ -325,7 +342,7 @@ var App =
} }
catch (e) catch (e)
{ {
alert ('Error al actualizar: '+ e.message); alert (_('Error while updating') +': '+ e.message);
} }
this._disableUi (false); this._disableUi (false);
@ -338,9 +355,7 @@ var App =
{ {
var remember = this.$('remember').checked ? 1 : 0; var remember = this.$('remember').checked ? 1 : 0;
this.regWrite (Conf.regPath, 'remember', remember, 'REG_DWORD'); this.regWrite (Conf.regPath, 'remember', remember, 'REG_DWORD');
this.shell.run (this.mdbFile, 0, false);
this.shell.exec ('"%ProgramFiles%\\Microsoft Office\\OFFICE11\\MSACCESS.EXE" "'+
this.mdbFile +'" /cmd "'+ this.$('user').value +'"');
window.close (); window.close ();
}, },
@ -418,3 +433,9 @@ var App =
}; };
App.init (); App.init ();
function _(string)
{
var translation = Locale[Conf.defaultLocale][string];
return translation ? translation : string;
}