From 6d6c0793035282f00231adb29c0a3fc98b0a4b32 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 14 Mar 1995 11:12:51 +0000 Subject: [PATCH] This commit was generated by cvs2svn to compensate for changes in r1113, which included commits to RCS files with non-trunk default branches. git-svn-id: svn://10.65.10.50/trunk@1114 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- sc/sc1.cpp | 18 ++++++ sc/sc1.h | 3 + sc/sc1100.cpp | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++ sc/sc1200.cpp | 42 ++++++++++++++ 4 files changed, 221 insertions(+) create mode 100755 sc/sc1.cpp create mode 100755 sc/sc1.h create mode 100755 sc/sc1100.cpp create mode 100755 sc/sc1200.cpp diff --git a/sc/sc1.cpp b/sc/sc1.cpp new file mode 100755 index 000000000..47af2147e --- /dev/null +++ b/sc/sc1.cpp @@ -0,0 +1,18 @@ +#include +#include + +#include "sp1.h" + +int main(int argc,char** argv) +{ + const int n = (argc > 1) ? atoi(&argv[1][1]) : 0; + + switch(n) + { + case 1: + sc1200(argc,argv); break; + default: + sc1100(argc,argv); break; + } + return 0; +} diff --git a/sc/sc1.h b/sc/sc1.h new file mode 100755 index 000000000..2a0bb571d --- /dev/null +++ b/sc/sc1.h @@ -0,0 +1,3 @@ + +int sc1100(int argc, char** argv); +int sc1200(int argc, char** argv); diff --git a/sc/sc1100.cpp b/sc/sc1100.cpp new file mode 100755 index 000000000..129387d60 --- /dev/null +++ b/sc/sc1100.cpp @@ -0,0 +1,158 @@ +#include +#include +#include +#include + +#include "sc1100.h" + +TString& add_plural(TString& s, long num, const char* name) +{ + const TFixed_string n(name); + const char last = n[n.len()-1]; + + if (num < 1) + { + s << "nessun"; + if (toupper(last) == 'A' || toupper(n[0]) == 'Z' || + toupper(n[0]) == 'S' && strchr("aeiouAEIOU", n[1]) == NULL) + s << tolower(last); + s << ' ' << name; + } + else + { + s << num << ' ' << name; + if (num > 1) + s[s.len()-1] = (last == 'a') ? 'e' : 'i'; + } + + return s; +} + +class TDeletepart_app : public TApplication +{ +protected: + virtual bool create(); + virtual bool destroy(); + virtual bool menu(MENU_TAG m); + +public: + TDeletepart_app() {}; +}; + +bool TDeletepart_app::create() +{ + TApplication::create(); + dispatch_e_menu(BAR_ITEM(1)); + return TRUE; +} + +bool TDeletepart_app::destroy() +{ + return TApplication::destroy(); +} + +bool TDeletepart_app::menu(MENU_TAG) +{ + TMask m("sc1100a"); + TCursor& cur = *m.efield(F_TODATE).browse()->cursor(); + TLocalisamfile& partite = cur.file(LF_PART); + TLocalisamfile scadenze(LF_SCAD); + while (m.run() != K_QUIT) + { + TRecnotype last = cur.items()-1; + partite.zero(); + const char* s = m.get(F_TODATE); + if (*s) + { + partite.put(MOV_DATAREG, s); + partite.put(MOV_NUMREG, m.get(F_TOREG)); + last = cur.read(); + } + + const TRecnotype first = cur.read(); + const TRecnotype total = 0; + int lastanno = -1; + TString16 lastpart = ""; + + for (cur = 0; cur.pos() <= last; ++cur) + { + if (lastanno != partite.get_int(??annopart??) || + lastpart != partite.get(??CODPART??); + { + total++; + lastanno = partite.get_int(??annopart??); + lastpart = partite.get(??CODPART??); + } + } + TString80 caption("Cancellazione di "); + add_plural(caption, total, "partite"); + + if (!yesno_box(caption) || total < 1) + continue; + + TProgind pi(total, caption, FALSE, TRUE, 24); + + cur.freeze(); + lastanno = -1; + for (cur = 0; cur.pos() <= last; ++cur) + { + const int anno = partite.get_int(??anno??); + const int partita = partite.get(??codpart??); + + int err = cur.lock(); + if (err == NOERR && (lastanno != partite.get_int(??annopart??) || + lastpart != partite.get(??CODPART??))); + { + for (int rig = 1; err == NOERR; rig++) + { + scadenze.put(??anno??, lastanno); + scadenze.put(??codpart??, lastpart); + scadenze.put(??nrig??, rig); + if (scadenze.read(_isequal, _lock) == NOERR) + err = scadenze.remove(); + if (err != NOERR) + caption.format("riga scadenza %d", rig); + } + pi.addstatus(1); + lastanno = partite.get_int(??annopart??); + lastpart = partite.get(??CODPART??); + } + if (err == NOERR) + { + const TRecnotype n = partite.recno(); + partite.setkey(1); // Isam bug on remove with key != 1 + partite.readat(n); + err = partite.remove(); + if (err != NOERR) + caption = "riga %d"; + } + else + { + error_box("Errore %d nella cancellazione della %s della partita %d/%s", + err, (const char*)caption, anno, partita); + break; + } + } + for (int rig = 1; lastanno > 0 && err == NOERR; rig++) + { + scadenze.put(??anno??, lastanno); + scadenze.put(??codpart??, lastpart); + scadenze.put(??nrig??, rig); + if (scadenze.read(_isequal, _lock) == NOERR) + err = scadenze.remove(); + if (err != NOERR) + caption.format("riga scadenza %d", rig); + } + cur.freeze(FALSE); + } + + return FALSE; + } + + + int cg2200(int argc, char** argv) + { + TDeletepart_app a; + a.run(argc, argv, "Eliminazione partita chiuse"); + return 0; + } diff --git a/sc/sc1200.cpp b/sc/sc1200.cpp new file mode 100755 index 000000000..c38366af5 --- /dev/null +++ b/sc/sc1200.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include + + + +class TCreatepart_app : public TApplication +{ +protected: + virtual bool create(); + virtual bool destroy(); + virtual bool menu(MENU_TAG m); + +public: + TCreatepart_app() {}; +}; + +bool TCreatepart_app::create() +{ + TApplication::create(); + dispatch_e_menu(BAR_ITEM(1)); + return TRUE; +} + +bool TCreatepart_app::destroy() +{ + return TApplication::destroy(); +} + +bool TCreatepart_app::menu(MENU_TAG) +{ + return FALSE; +} + + +int sc1200(int argc, char** argv) +{ + TCreatepart_app a; + a.run(argc, argv, "Apertura scadenze da saldi"); + return 0; +}