-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
94 lines (79 loc) · 2.67 KB
/
Copy pathmain.cpp
File metadata and controls
94 lines (79 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
Tara, simple veterinary practice support software
Copyright (C) 2009 - 2015 Jan Kusniar
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "constants.h"
#include "mainwin.h"
#define TFILE <tara/tara.t>
#include <Core/t.h>
// INI file config
INI_STRING(postgres_hostname, "localhost", "Postgresql hostname");
INI_STRING(postgres_database, "taradev", "Postgresql database");
INI_STRING(postgres_username, "postgres", "Postgresql username");
INI_STRING(postgres_password, "postgres", "Postgresql password");
GUI_APP_MAIN
{
int language = LNGC_('S','K','S','K', CHARSET_UTF8);
SetLanguage(language);
setlocale(LC_ALL,"C");
SetIniFile(GetDataFile("tara.ini"));
//RLOG(GetIniInfoFormatted());
//login and open DB session
PostgreSQLSession sql_session;
if(!sql_session.Open("host=" + AsString(postgres_hostname) + " dbname="+ AsString(postgres_database) +" user="+ AsString(postgres_username) +" password=" + AsString(postgres_password) ))
{
Exclamation(Format(t_("Error: %s"), DeQtf(sql_session.GetLastError())));
return;
}
// if DEBUG, synchronize database schema
#ifdef _DEBUG
initDebugDB(sql_session);
#endif
SQL = sql_session;
try
{
// create window
MainWin mwin(AsString(postgres_database));
// load settings from file
LoadFromFile(mwin, "tara_main.cfg");
// window setup (according to loaded settings)
// set language according to settings
switch (mwin.lang)
{
case LANG_ENG:
language = LNGC_('E','N','U','S', CHARSET_UTF8);
break;
case LANG_SK:
language = LNGC_('S','K','S','K', CHARSET_UTF8);
break;
case LANG_CZ:
language = LNGC_('C','S','C','Z', CHARSET_UTF8);
break;
default:
language = LNGC_('S','K','S','K', CHARSET_UTF8);
}
SetLanguage(language);
setlocale(LC_ALL,"C");
mwin.WindowSetup();
//start app
mwin.Run();
//store settings to file
mwin.StoreSetup();
StoreToFile(mwin,"tara_main.cfg");
}
catch(SqlExc &e)
{
Exclamation(Format(t_("Error: %s"), DeQtfLf(e)));
}
sql_session.Close();
}