Corretta formattazione
git-svn-id: svn://10.65.10.50/trunk@590 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fc18e775ab
commit
6b2cda0c60
505
ba/ba0.cpp
505
ba/ba0.cpp
@ -1,495 +1,3 @@
|
|||||||
<<<<<<< ba0.cpp
|
|
||||||
#include <applicat.h>
|
|
||||||
#include <execp.h>
|
|
||||||
#include <mask.h>
|
|
||||||
#include <isam.h>
|
|
||||||
#include <prefix.h>
|
|
||||||
#include <progind.h>
|
|
||||||
#include <utility.h>
|
|
||||||
#include <urldefid.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include <cpb.h>
|
|
||||||
}
|
|
||||||
#include <dos.h>
|
|
||||||
#else
|
|
||||||
#include <dirent.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ba0.h"
|
|
||||||
#include "ba0100a.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
// Picture Mask
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TPicture_mask : public TMask
|
|
||||||
{
|
|
||||||
static short _id;
|
|
||||||
static PICTURE _picture;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void handler(WINDOW win, EVENT* ep);
|
|
||||||
void set_picture(short id);
|
|
||||||
|
|
||||||
public:
|
|
||||||
TPicture_mask(const char* name, int dx, int dy, short picture_id);
|
|
||||||
void reset();
|
|
||||||
};
|
|
||||||
|
|
||||||
short TPicture_mask::_id = 0;
|
|
||||||
PICTURE TPicture_mask::_picture = 0L;
|
|
||||||
|
|
||||||
void TPicture_mask::set_picture(short id)
|
|
||||||
{
|
|
||||||
if (id != _id)
|
|
||||||
{
|
|
||||||
_id = id;
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
if (_picture) picture_free(_picture);
|
|
||||||
_picture = cpb_picture_load(id);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TPicture_mask::reset()
|
|
||||||
{
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
if (_picture)
|
|
||||||
{
|
|
||||||
picture_free(_picture);
|
|
||||||
_picture = 0L;
|
|
||||||
_id = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
TPicture_mask::TPicture_mask(const char* name, int dx, int dy, short pic)
|
|
||||||
: TMask(name, 1, dx, dy)
|
|
||||||
{
|
|
||||||
set_picture(pic);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TPicture_mask::handler(WINDOW win, EVENT* ep)
|
|
||||||
{
|
|
||||||
TMask::handler(win, ep);
|
|
||||||
|
|
||||||
if (ep->type == E_UPDATE)
|
|
||||||
{
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
if (_picture)
|
|
||||||
cpb_win_picture_draw_at(win, _picture, 1, CHARY<<1);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
const int max = 16;
|
|
||||||
for (int i = 0; i < max; i++)
|
|
||||||
{
|
|
||||||
TTemp_window w(win);
|
|
||||||
w.rect(i*2, i, max-i*2, max-i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
// Menu application
|
|
||||||
///////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TMenu_application : public TApplication
|
|
||||||
{
|
|
||||||
const char* _name;
|
|
||||||
|
|
||||||
enum { MAXLEVEL = 1024 };
|
|
||||||
int _first[MAXLEVEL];
|
|
||||||
TArray _menu; // TAG|DESCRIPTION|ACTION
|
|
||||||
TBit_array _enabled;
|
|
||||||
TArray _modules;
|
|
||||||
|
|
||||||
int _level, _max;
|
|
||||||
bool _ditta_asked;
|
|
||||||
|
|
||||||
static int _last_button;
|
|
||||||
static bool _find_button;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void test_temp() const;
|
|
||||||
void load_menu();
|
|
||||||
int do_level();
|
|
||||||
int find_menu(const char* s) const;
|
|
||||||
bool check_user();
|
|
||||||
virtual bool create();
|
|
||||||
virtual bool menu(MENU_TAG m);
|
|
||||||
|
|
||||||
static bool menu_item_handler(TMask_field&f, KEY k);
|
|
||||||
static bool menu_find_handler(TMask_field&f, KEY k);
|
|
||||||
bool module_enabled(const char * program) const;
|
|
||||||
bool module_enabled(int module) const { return has_module(module);}
|
|
||||||
|
|
||||||
public:
|
|
||||||
TMenu_application(const char* name) : _name(name), _ditta_asked(FALSE) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
int TMenu_application::_last_button = 0;
|
|
||||||
bool TMenu_application::_find_button = FALSE;
|
|
||||||
|
|
||||||
inline TMenu_application& app()
|
|
||||||
{ return (TMenu_application&)main_app(); }
|
|
||||||
|
|
||||||
bool TMenu_application::module_enabled(const char * program) const
|
|
||||||
{
|
|
||||||
bool ok = FALSE;
|
|
||||||
const int nmod = _modules.items();
|
|
||||||
for (int aut = 0; aut < nmod; aut++)
|
|
||||||
{
|
|
||||||
const TString& s = (const TString&) _modules[aut];
|
|
||||||
if (strncmp((const char *) s, program, 2) == 0) { ok = TRUE; break; }
|
|
||||||
}
|
|
||||||
return ok && has_module(aut);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TMenu_application::load_menu()
|
|
||||||
{
|
|
||||||
TScanner s(_name);
|
|
||||||
|
|
||||||
_max = -1;
|
|
||||||
|
|
||||||
while (s.line().not_empty())
|
|
||||||
{
|
|
||||||
TToken_string* ts = new TToken_string(s.token());
|
|
||||||
int l = ts->get_int();
|
|
||||||
|
|
||||||
if (l < _max)
|
|
||||||
{
|
|
||||||
error_box("Item of level %d while %d was expected)", l, _max);
|
|
||||||
l = _max;
|
|
||||||
}
|
|
||||||
if (l > _max)
|
|
||||||
{
|
|
||||||
if (l >= MAXLEVEL)
|
|
||||||
{
|
|
||||||
error_box("Too many menu levels: %d", l);
|
|
||||||
l = _max;
|
|
||||||
}
|
|
||||||
_first[_max = l] = _menu.items();
|
|
||||||
}
|
|
||||||
|
|
||||||
_menu.add(ts);
|
|
||||||
const TString16 action = ts->get(2);
|
|
||||||
const int last = _menu.items() - 1;
|
|
||||||
|
|
||||||
if (atoi(action) > 0)
|
|
||||||
{
|
|
||||||
TToken_string list(ts->get(), ',');
|
|
||||||
int module = list.get_int();
|
|
||||||
|
|
||||||
if (module == 0)
|
|
||||||
_enabled.set(last);
|
|
||||||
while(!_enabled[last] && module > 0)
|
|
||||||
{
|
|
||||||
if (has_module(module))
|
|
||||||
_enabled.set(last);
|
|
||||||
module = list.get_int();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_enabled.set(last, module_enabled(action));
|
|
||||||
}
|
|
||||||
_first[++_max] = _menu.items();
|
|
||||||
}
|
|
||||||
|
|
||||||
int TMenu_application::find_menu(const char* s) const
|
|
||||||
{
|
|
||||||
TString80 str(s); str.upper();
|
|
||||||
int found = -1;
|
|
||||||
|
|
||||||
for (int i = 0; i < _menu.items(); i++)
|
|
||||||
{
|
|
||||||
if (_enabled[i])
|
|
||||||
{
|
|
||||||
TToken_string& l = (TToken_string&)_menu[i];
|
|
||||||
const int m = l.get_int(0);
|
|
||||||
if (m != _level)
|
|
||||||
{
|
|
||||||
TString80 v(l.get()); v.upper();
|
|
||||||
|
|
||||||
if (v.find(str) >= 0)
|
|
||||||
{
|
|
||||||
found = i;
|
|
||||||
if (isalpha(l.get_char())) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TMenu_application::menu_item_handler(TMask_field&f, KEY k)
|
|
||||||
{
|
|
||||||
if (k == K_SPACE)
|
|
||||||
{
|
|
||||||
_last_button = f.dlg();
|
|
||||||
_find_button = FALSE;
|
|
||||||
f.mask().stop_run(K_AUTO_ENTER);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool TMenu_application::menu_find_handler(TMask_field&f, KEY k)
|
|
||||||
{
|
|
||||||
if (k == K_TAB && f.focusdirty())
|
|
||||||
{
|
|
||||||
const TString& v = f.get();
|
|
||||||
if (v.not_empty())
|
|
||||||
{
|
|
||||||
_last_button = app().find_menu(v);
|
|
||||||
if (_last_button >= 0)
|
|
||||||
{
|
|
||||||
_find_button = TRUE;
|
|
||||||
f.mask().stop_run(K_AUTO_ENTER);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
beep();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int TMenu_application::do_level()
|
|
||||||
{
|
|
||||||
const int first = _first[_level];
|
|
||||||
const int last = _first[_level+1];
|
|
||||||
TToken_string& row = (TToken_string&)_menu[first];
|
|
||||||
const TString80 head(row.get(1));
|
|
||||||
|
|
||||||
const int width = 72;
|
|
||||||
const int height = 18;
|
|
||||||
const int bwidth = 20;
|
|
||||||
const int x = width-bwidth-12;
|
|
||||||
const short pic = BA0_PICTURE+(short)row.get_int();
|
|
||||||
TPicture_mask menu(head, width, height, pic);
|
|
||||||
|
|
||||||
int y = 1;
|
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
TString16 t(format("#%d", BMP_STOPREC));
|
|
||||||
#else
|
|
||||||
TString16 t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = first+1; i < last; i++, y++)
|
|
||||||
{
|
|
||||||
TToken_string& row = (TToken_string&)_menu[i];
|
|
||||||
TString80 item(row.get(1));
|
|
||||||
if (isdigit(*row.get())) item << "...";
|
|
||||||
menu.add_static(-1, 0, item, x+4, y);
|
|
||||||
menu.add_button(100+y, 0, t, x, y, 1, 1);
|
|
||||||
menu.set_handler(100+y, menu_item_handler);
|
|
||||||
if (!_enabled[i]) menu.disable(100 + y);
|
|
||||||
}
|
|
||||||
menu.add_static(-1, 0, "Cerca", 1,-3);
|
|
||||||
menu.add_string(99, 0, "", -12, -3, 50, "", bwidth+1);
|
|
||||||
menu.set_handler(99, menu_find_handler);
|
|
||||||
|
|
||||||
t = first ? "Menu precedente" : "Fine";
|
|
||||||
menu.add_button(first ? DLG_CANCEL : DLG_QUIT, 0, t, -22, -1, bwidth, 2);
|
|
||||||
if (first)
|
|
||||||
menu.add_button(DLG_QUIT, 0, "Fine", -12, -1, bwidth, 2);
|
|
||||||
|
|
||||||
if (_find_button && _last_button > first)
|
|
||||||
menu.first_focus(100+_last_button-first);
|
|
||||||
|
|
||||||
_last_button = _find_button = 0;
|
|
||||||
|
|
||||||
const int k = menu.run();
|
|
||||||
int m = 0;
|
|
||||||
switch (k)
|
|
||||||
{
|
|
||||||
case K_ESC:
|
|
||||||
m = -1; break;
|
|
||||||
case K_QUIT:
|
|
||||||
menu.reset();
|
|
||||||
m = -2; break;
|
|
||||||
default:
|
|
||||||
if (_find_button)
|
|
||||||
m = -1;
|
|
||||||
else
|
|
||||||
m = first+_last_button-100;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TMenu_application::test_temp() const
|
|
||||||
{
|
|
||||||
TFilename dir; dir.tempdir(); // Directory temporanea
|
|
||||||
|
|
||||||
TFilename name = dir;
|
|
||||||
name << "/" << "*.*"; // Cerca tutti i file
|
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
|
||||||
struct _find_t f;
|
|
||||||
if (_dos_findfirst(name, _A_NORMAL, &f) == 0 &&
|
|
||||||
yesno_box("Cancellare i file temporanei?"))
|
|
||||||
{
|
|
||||||
TIndwin pi(40, "Cancellazione file temporanei", FALSE, FALSE);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
name = dir;
|
|
||||||
name << "/" << f.name;
|
|
||||||
remove(name);
|
|
||||||
} while (_dos_findnext(&f) == 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TMenu_application::check_user()
|
|
||||||
{
|
|
||||||
TMask m("ba0100a");
|
|
||||||
TLocalisamfile users(LF_USER);
|
|
||||||
TString16 user;
|
|
||||||
TString16 password;
|
|
||||||
|
|
||||||
for (int i = 0 ; i < 3; i++)
|
|
||||||
{
|
|
||||||
if (m.run() == K_ESC) return FALSE;
|
|
||||||
user = m.get(F_USER);
|
|
||||||
password = m.get(F_PASSWORD);
|
|
||||||
if (password.len() > 3)
|
|
||||||
{
|
|
||||||
users.zero();
|
|
||||||
users.put("USERNAME", user);
|
|
||||||
if (users.read() == NOERR)
|
|
||||||
{
|
|
||||||
const TString16 pwd(users.get("PASSWORD"));
|
|
||||||
|
|
||||||
if (pwd == encode(password))
|
|
||||||
{
|
|
||||||
set_user(user);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
message_box("Password errata");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (user == "PRASSI")
|
|
||||||
{
|
|
||||||
if (m.get(F_PASSWORD) == "pr.assi")
|
|
||||||
{
|
|
||||||
set_user(user);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
message_box("Password errata");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
message_box("Utente sconosciuto");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
message_box("Password errata");
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TMenu_application::create()
|
|
||||||
{
|
|
||||||
if (!check_user()) return FALSE;
|
|
||||||
set_perms();
|
|
||||||
test_temp();
|
|
||||||
{
|
|
||||||
TScanner scanner("prassi.aut");
|
|
||||||
|
|
||||||
for (int aut = 0; scanner.line() != ""; aut++)
|
|
||||||
_modules.add(new TString(scanner.token()));
|
|
||||||
}
|
|
||||||
load_menu();
|
|
||||||
dispatch_e_menu(BAR_ITEM(1));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool TMenu_application::menu(MENU_TAG)
|
|
||||||
{
|
|
||||||
int refarray[256];
|
|
||||||
memset(refarray, 0, sizeof(refarray));
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
_level = 0;
|
|
||||||
while (i >= 0)
|
|
||||||
{
|
|
||||||
const int m = do_level();
|
|
||||||
if (m >= 0)
|
|
||||||
{
|
|
||||||
TToken_string& row = (TToken_string&)_menu[m];
|
|
||||||
const TFilename option(row.get(2));
|
|
||||||
|
|
||||||
if (option.not_empty())
|
|
||||||
{
|
|
||||||
bool ok = TRUE;
|
|
||||||
const int l = atoi(option);
|
|
||||||
if (l > 0)
|
|
||||||
{
|
|
||||||
const TString16 flags(row.get());
|
|
||||||
if (flags.find('F') >= 0)
|
|
||||||
_ditta_asked = ok = set_firm();
|
|
||||||
if (ok)
|
|
||||||
{
|
|
||||||
refarray[i++] = _level;
|
|
||||||
if (l < _max) _level = l;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TExternal_app a(option);
|
|
||||||
const TString& module = option.left(2);
|
|
||||||
if (module == "ba") _ditta_asked = FALSE; else
|
|
||||||
if (module == "cg" && !_ditta_asked)
|
|
||||||
_ditta_asked = ok = set_firm();
|
|
||||||
if (ok) a.run();
|
|
||||||
prefhndl->set("DEF"); // Aggiorna prefix se hanno cambiato ditta
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m < -1) break;
|
|
||||||
if (_find_button)
|
|
||||||
{
|
|
||||||
TToken_string& row = (TToken_string&)_menu[_last_button];
|
|
||||||
_level = row.get_int(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_level = (i > 0) ? refarray[--i] : 0;
|
|
||||||
if (_level == 0) i = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
const char* menu = (argc < 2) ? "prassi.mnu" : argv[1];
|
|
||||||
TMenu_application ma(menu);
|
|
||||||
ma.run(argc, argv, "Menu Principale");
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
#include <applicat.h>
|
#include <applicat.h>
|
||||||
#include <execp.h>
|
#include <execp.h>
|
||||||
#include <mask.h>
|
#include <mask.h>
|
||||||
@ -935,15 +443,17 @@ int TMenu_application::do_level()
|
|||||||
|
|
||||||
void TMenu_application::test_temp() const
|
void TMenu_application::test_temp() const
|
||||||
{
|
{
|
||||||
TFilename name; name.tempdir();
|
TFilename dir; dir.tempdir(); // Directory temporanea
|
||||||
name << "/" << "ci*";
|
|
||||||
|
TFilename name = dir;
|
||||||
|
name << "/" << "*.*"; // Cerca tutti i file
|
||||||
|
|
||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
struct _find_t f;
|
struct _find_t f;
|
||||||
if (_dos_findfirst(name, _A_NORMAL, &f) == 0 &&
|
if (_dos_findfirst(name, _A_NORMAL, &f) == 0 &&
|
||||||
yesno_box("Si desidera cancellare i file temporanei?"))
|
yesno_box("Cancellare i file temporanei?"))
|
||||||
{
|
{
|
||||||
TIndwin pi(40, "Cancellazione file temporanei residui", FALSE, FALSE);
|
TIndwin pi(40, "Cancellazione file temporanei", FALSE, FALSE);
|
||||||
TFilename dir; dir.tempdir();
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
name = dir;
|
name = dir;
|
||||||
@ -1088,4 +598,3 @@ int main(int argc, char** argv)
|
|||||||
ma.run(argc, argv, "Menu Principale");
|
ma.run(argc, argv, "Menu Principale");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
>>>>>>> 1.14
|
|
||||||
|
1176
cg/cg2103.cpp
1176
cg/cg2103.cpp
File diff suppressed because it is too large
Load Diff
440
cg/cg2104.cpp
440
cg/cg2104.cpp
@ -1,220 +1,220 @@
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Scadenzario
|
// Scadenzario
|
||||||
// fv 24/8/94
|
// fv 24/8/94
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "cg2102.h"
|
#include "cg2102.h"
|
||||||
#include "cg2100.h"
|
#include "cg2100.h"
|
||||||
#include "cg2104a.h"
|
#include "cg2104a.h"
|
||||||
#include "pagament.h"
|
#include "pagament.h"
|
||||||
|
|
||||||
struct shuttle
|
struct shuttle
|
||||||
{
|
{
|
||||||
Pagamento* _pag; // pagamento
|
Pagamento* _pag; // pagamento
|
||||||
TSheet_field* _sheet; // sheet
|
TSheet_field* _sheet; // sheet
|
||||||
TMask* _mask; // maschera
|
TMask* _mask; // maschera
|
||||||
TArray* _rows; // righe spreadsheet nella versione originale
|
TArray* _rows; // righe spreadsheet nella versione originale
|
||||||
};
|
};
|
||||||
|
|
||||||
bool TPrimanota_application::pag_notify(int r, KEY k)
|
bool TPrimanota_application::pag_notify(int r, KEY k)
|
||||||
{
|
{
|
||||||
// questo e' il bello
|
// questo e' il bello
|
||||||
shuttle* sh = (shuttle*)(((TPrimanota_application&)main_app()).get_app_data());
|
shuttle* sh = (shuttle*)(((TPrimanota_application&)main_app()).get_app_data());
|
||||||
|
|
||||||
Pagamento* pag = sh->_pag;
|
Pagamento* pag = sh->_pag;
|
||||||
TSheet_field* ps = sh->_sheet;
|
TSheet_field* ps = sh->_sheet;
|
||||||
TMask* msk = sh->_mask;
|
TMask* msk = sh->_mask;
|
||||||
TArray* rws = sh->_rows;
|
TArray* rws = sh->_rows;
|
||||||
|
|
||||||
int rdiff = atoi(msk->get(F_RDIFFER));
|
int rdiff = atoi(msk->get(F_RDIFFER));
|
||||||
|
|
||||||
// ts contiene la vecchia riga, ns la nuova
|
// ts contiene la vecchia riga, ns la nuova
|
||||||
TToken_string ts(36), ns(36);
|
TToken_string ts(36), ns(36);
|
||||||
|
|
||||||
|
|
||||||
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
|
bool doit = TRUE, m_imp = FALSE, m_perc = FALSE, m_pag = FALSE;
|
||||||
bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE;
|
bool m_scad = FALSE, m_tipo = FALSE, mod = FALSE;
|
||||||
word ahiahi = P_OK;
|
word ahiahi = P_OK;
|
||||||
|
|
||||||
TString news(15), newi(15), newp(15), newt(2);
|
TString news(15), newi(15), newp(15), newt(2);
|
||||||
|
|
||||||
bool recalc = msk->get_bool(F_RECALC);
|
bool recalc = msk->get_bool(F_RECALC);
|
||||||
bool mcomm = msk->get_bool(F_MCOMM);
|
bool mcomm = msk->get_bool(F_MCOMM);
|
||||||
|
|
||||||
switch (k)
|
switch (k)
|
||||||
{
|
{
|
||||||
case K_SPACE:
|
case K_SPACE:
|
||||||
break;
|
break;
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
ns = ps->row(r);
|
ns = ps->row(r);
|
||||||
ts = (TToken_string&)(*rws)[r];
|
ts = (TToken_string&)(*rws)[r];
|
||||||
|
|
||||||
news = ns.get(0);
|
news = ns.get(0);
|
||||||
newp = ns.get(1);
|
newp = ns.get(1);
|
||||||
newi = ns.get(2);
|
newi = ns.get(2);
|
||||||
newt = ns.get(3);
|
newt = ns.get(3);
|
||||||
|
|
||||||
// qui viene il bello, si fa per dire
|
// qui viene il bello, si fa per dire
|
||||||
if (strcmp(ts.get(0),news) != 0) // modificata data scadenza
|
if (strcmp(ts.get(0),news) != 0) // modificata data scadenza
|
||||||
{
|
{
|
||||||
mod = m_scad = TRUE;
|
mod = m_scad = TRUE;
|
||||||
}
|
}
|
||||||
if (strcmp(ts.get(1),newp) != 0) // modificata percentuale
|
if (strcmp(ts.get(1),newp) != 0) // modificata percentuale
|
||||||
{
|
{
|
||||||
mod = m_perc = TRUE;
|
mod = m_perc = TRUE;
|
||||||
}
|
}
|
||||||
if (strcmp(ts.get(2),newi) != 0) // modificato importo
|
if (strcmp(ts.get(2),newi) != 0) // modificato importo
|
||||||
{
|
{
|
||||||
if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato
|
if ((recalc && !m_perc) || (!recalc)) // se si modifica la percentuale l'importo non viene cagato
|
||||||
{
|
{
|
||||||
mod = m_imp = TRUE;
|
mod = m_imp = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strcmp(ts.get(3),newt) != 0) // modificato tipo pagamento
|
if (strcmp(ts.get(3),newt) != 0) // modificato tipo pagamento
|
||||||
{
|
{
|
||||||
mod = m_tipo = TRUE;
|
mod = m_tipo = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case K_DEL:
|
case K_DEL:
|
||||||
case K_INS:
|
case K_INS:
|
||||||
doit = FALSE;
|
doit = FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// settato da recalc_rate se occorre ridefinire lo sheet
|
// settato da recalc_rate se occorre ridefinire lo sheet
|
||||||
// aggiungendo o togliendo righe
|
// aggiungendo o togliendo righe
|
||||||
bool need_recalc = FALSE;
|
bool need_recalc = FALSE;
|
||||||
|
|
||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
if (mod && recalc)
|
if (mod && recalc)
|
||||||
{
|
{
|
||||||
// ricalcola sheet come sai fare tu
|
// ricalcola sheet come sai fare tu
|
||||||
ahiahi = pag->recalc_rate(r, m_perc,
|
ahiahi = pag->recalc_rate(r, m_perc,
|
||||||
((m_perc || m_imp) ?
|
((m_perc || m_imp) ?
|
||||||
(m_perc ? (const char*)newp : (const char*)newi) :
|
(m_perc ? (const char*)newp : (const char*)newi) :
|
||||||
NULL),
|
NULL),
|
||||||
(m_scad ? (const char*)news : NULL),
|
(m_scad ? (const char*)news : NULL),
|
||||||
(m_tipo ? (const char*)newt : NULL),
|
(m_tipo ? (const char*)newt : NULL),
|
||||||
rdiff, mcomm, need_recalc);
|
rdiff, mcomm, need_recalc);
|
||||||
// see if rdiff changed
|
// see if rdiff changed
|
||||||
msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
|
msk->field(F_RDIFFER).set(pag->rate_differenziate() ? "1" : "2");
|
||||||
}
|
}
|
||||||
if (!recalc)
|
if (!recalc)
|
||||||
{
|
{
|
||||||
ahiahi = P_OK;
|
ahiahi = P_OK;
|
||||||
// put data as they are
|
// put data as they are
|
||||||
TToken_string& trw = pag->rata(r);
|
TToken_string& trw = pag->rata(r);
|
||||||
TToken_string srw = trw;
|
TToken_string srw = trw;
|
||||||
if (m_scad) trw.add(news,3);
|
if (m_scad) trw.add(news,3);
|
||||||
if (m_perc) trw.add(newp,1);
|
if (m_perc) trw.add(newp,1);
|
||||||
if (m_imp) trw.add(newi,4);
|
if (m_imp) trw.add(newi,4);
|
||||||
if (m_tipo) trw.add(newt,2);
|
if (m_tipo) trw.add(newt,2);
|
||||||
// validate the payment
|
// validate the payment
|
||||||
if ((ahiahi = pag->validate()) != P_OK)
|
if ((ahiahi = pag->validate()) != P_OK)
|
||||||
pag->rata(r) = srw;
|
pag->rata(r) = srw;
|
||||||
}
|
}
|
||||||
if (ahiahi) // any error?
|
if (ahiahi) // any error?
|
||||||
// rimetti le righe com'erano prima
|
// rimetti le righe com'erano prima
|
||||||
{
|
{
|
||||||
beep();
|
beep();
|
||||||
|
|
||||||
// se gli errori sono voluti, spiegali
|
// se gli errori sono voluti, spiegali
|
||||||
if (!recalc)
|
if (!recalc)
|
||||||
{
|
{
|
||||||
TString s(256);
|
TString s(256);
|
||||||
pag->strerr(ahiahi,s);
|
pag->strerr(ahiahi,s);
|
||||||
warning_box(s);
|
warning_box(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ps->row(r) = (TToken_string&)(*rws)[r];
|
ps->row(r) = (TToken_string&)(*rws)[r];
|
||||||
ps->force_update(r);
|
ps->force_update(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (recalc && mod && need_recalc)
|
else if (recalc && mod && need_recalc)
|
||||||
{
|
{
|
||||||
// ridefinisci lo sheet sulla base delle nuove rate
|
// ridefinisci lo sheet sulla base delle nuove rate
|
||||||
pag->set_sheet(*ps);
|
pag->set_sheet(*ps);
|
||||||
ps->force_update(-1);
|
ps->force_update(-1);
|
||||||
rws->destroy();
|
rws->destroy();
|
||||||
(*rws) = ps->rows_array();
|
(*rws) = ps->rows_array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return doit;
|
return doit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
void TPrimanota_application::aggiorna_scadenzario(const TMask& m)
|
||||||
{
|
{
|
||||||
real imponibile(0.0);
|
real imponibile(0.0);
|
||||||
real imposta(0.0);
|
real imposta(0.0);
|
||||||
real spese(0.0);
|
real spese(0.0);
|
||||||
TString dt(m.get(F_DATAREG));
|
TString dt(m.get(F_DATAREG));
|
||||||
Pagamento pag(m.get(F_CODPAG), (const char*)dt);
|
Pagamento pag(m.get(F_CODPAG), (const char*)dt);
|
||||||
|
|
||||||
if (pag.is_new()) return;
|
if (pag.is_new()) return;
|
||||||
|
|
||||||
TMask ms("cg2104a");
|
TMask ms("cg2104a");
|
||||||
TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET);
|
TSheet_field& ps = (TSheet_field&)ms.field(F_RATESHEET);
|
||||||
ps.set_notify(pag_notify);
|
ps.set_notify(pag_notify);
|
||||||
|
|
||||||
ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2");
|
ms.field(F_RDIFFER).set(pag.rate_differenziate() ? "1" : "2");
|
||||||
ms.field(F_NAMEPAG).set(pag.name());
|
ms.field(F_NAMEPAG).set(pag.name());
|
||||||
ms.field(F_TIPOPR).set(pag.desc_tpr());
|
ms.field(F_TIPOPR).set(pag.desc_tpr());
|
||||||
ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : "");
|
ms.field(F_MCOMM).set(pag.mese_commerciale() ? "X" : "");
|
||||||
|
|
||||||
TSheet_field& iva_sh = ivas();
|
TSheet_field& iva_sh = ivas();
|
||||||
|
|
||||||
for (int i = 0; i < iva_sh.items(); i++)
|
for (int i = 0; i < iva_sh.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string& tt = iva_sh.row(i);
|
TToken_string& tt = iva_sh.row(i);
|
||||||
real mpo(tt.get(0));
|
real mpo(tt.get(0));
|
||||||
real imp(tt.get(3));
|
real imp(tt.get(3));
|
||||||
imponibile += mpo;
|
imponibile += mpo;
|
||||||
imposta += imp;
|
imposta += imp;
|
||||||
// TBI: le spese che cazzo sono?
|
// TBI: le spese che cazzo sono?
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.field(F_IMPONIBILE).set(imponibile.string());
|
ms.field(F_IMPONIBILE).set(imponibile.string());
|
||||||
ms.field(F_IMPOSTA).set(imposta.string());
|
ms.field(F_IMPOSTA).set(imposta.string());
|
||||||
ms.field(F_SPESE).set(spese.string());
|
ms.field(F_SPESE).set(spese.string());
|
||||||
ms.field(F_RECALC).set("X");
|
ms.field(F_RECALC).set("X");
|
||||||
|
|
||||||
pag.set_total(imponibile, imposta, spese);
|
pag.set_total(imponibile, imposta, spese);
|
||||||
|
|
||||||
// TBI TBI TBI TBI TBI TBI TBI TBI TBI
|
// TBI TBI TBI TBI TBI TBI TBI TBI TBI
|
||||||
// controllare se c'e' una rateazione non standard gia' registrata
|
// controllare se c'e' una rateazione non standard gia' registrata
|
||||||
// in tal caso occorre zappare e settare le rate a mano
|
// in tal caso occorre zappare e settare le rate a mano
|
||||||
pag.set_rate_auto();
|
pag.set_rate_auto();
|
||||||
|
|
||||||
// se la prima rata e' fissa non si tocca
|
// se la prima rata e' fissa non si tocca
|
||||||
if (pag.tipo_prima_rata() > 0)
|
if (pag.tipo_prima_rata() > 0)
|
||||||
{
|
{
|
||||||
ps.disable_cell(0,0);
|
ps.disable_cell(0,0);
|
||||||
ps.disable_cell(0,1);
|
ps.disable_cell(0,1);
|
||||||
ps.disable_cell(0,2);
|
ps.disable_cell(0,2);
|
||||||
ps.disable_cell(0,3);
|
ps.disable_cell(0,3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepara lo sheet
|
// prepara lo sheet
|
||||||
pag.set_sheet(ps);
|
pag.set_sheet(ps);
|
||||||
TArray rows(ps.rows_array());
|
TArray rows(ps.rows_array());
|
||||||
|
|
||||||
shuttle sh;
|
shuttle sh;
|
||||||
|
|
||||||
sh._pag = &pag;
|
sh._pag = &pag;
|
||||||
sh._sheet = &ps;
|
sh._sheet = &ps;
|
||||||
sh._mask = &ms;
|
sh._mask = &ms;
|
||||||
sh._rows = &rows;
|
sh._rows = &rows;
|
||||||
|
|
||||||
set_app_data(&sh);
|
set_app_data(&sh);
|
||||||
ms.run();
|
ms.run();
|
||||||
|
|
||||||
// TBI se modificato riaggiustare i files
|
// TBI se modificato riaggiustare i files
|
||||||
// chiamando la write del caso
|
// chiamando la write del caso
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user