campo-sirio/mg/mg3500.cpp
alex 3005fcd67a Patch level : 2.1 048
Files correlati     : mg0.exe mg1.exe mg3.exe mg4.exe
Ricompilazione Demo : [ ]
Commento            :
Bug  0000134

Implementare la gestione multilingua


git-svn-id: svn://10.65.10.50/trunk@12084 c028cbd2-c16b-5b4b-a496-9718f37d4682
2004-05-18 10:44:57 +00:00

222 lines
6.8 KiB
C++
Executable File

#include <applicat.h>
#include <fraction.h>
#include "mglib.h"
#include "mg3500.h"
#include "mg3frm.h"
#include "../cg/cglib01.h"
// mg3500 Stampa
class TForm_storgiac : public TForm_stampemg
{
TSorted_cursor * _sortcur;
bool _use_alternate_cursor;
public:
void use_alternate_cursor(const bool b = TRUE) { _use_alternate_cursor = b; }
virtual TCursor* cursor() const ;
virtual bool validate(TForm_item &cf, TToken_string &s);
TForm_storgiac(const char *name,const char *code) ;
virtual ~TForm_storgiac();
};
TCursor* TForm_storgiac::cursor() const
{
if (_use_alternate_cursor) // Se e' settata la stampa per ragg. fisc ritorna il cursore appropriato
return (TCursor*)_sortcur;
return TForm_stampemg::cursor();
}
bool TForm_storgiac::validate(TForm_item &cf, TToken_string &s)
{
const TString80 cmd = s.get(0);
if (cmd == "_FRACTION_MULT")
{
const TString16 id1 = s.get();
const TString16 id2 = s.get();
const fraction f1 = cf.find_field(id1).get();
const fraction f2 = cf.find_field(id2).get();
const real m = f1 * f2;
cf.set(m.string());
return TRUE;
}
return TForm_stampemg::validate(cf, s);
}
TForm_storgiac::TForm_storgiac(const char *name,const char *code) :
TForm_stampemg(name,code)
{
_use_alternate_cursor = FALSE;
_sortcur = new TSorted_cursor(relation(),"RAGGFIS|CODART");
}
TForm_storgiac::~TForm_storgiac()
{
delete _sortcur;
}
/////////////////////////////////////////////////////
// Applicazione
/////////////////////////////////////////////////////
class TStampa_storgiac : public TSkeleton_application
{
TArray * _files;
TStampemg_mask * _mask;
TCursor * _cur;
TForm_storgiac * _form; // to be moved into TPrint_application
protected:
virtual bool create();
virtual bool destroy();
virtual void main_loop();
virtual void set_def_valuta(TForm_storgiac & f) {}
public:
TStampa_storgiac() {}
virtual ~TStampa_storgiac() {};
};
bool TStampa_storgiac::create()
{
_mask = new TStampemg_mask("mg3500");
return TSkeleton_application::create();
}
bool TStampa_storgiac::destroy()
{
delete _mask;
return TSkeleton_application::destroy();
}
// ORDINAMENTO
void TStampa_storgiac::main_loop()
{
while (_mask->run() == K_ENTER)
{
if (_mask->magazz_ini().gestmag(TRUE))
{
TRectype darec(LF_ANAMAG),arec(LF_ANAMAG);
TString cfilter,joinexp, espr;
cfilter.format("%d->NRIGA!=0", LF_STOMAG); //Considera l'articolo solo se ha almeno una riga di storico...
TString16 es ; es.format("\"%04d\"", _mask->get_int(F_ANNOES));
joinexp << "ANNOESRIF==" << es << "|CODART==CODART";
_form = new TForm_storgiac("mg3500", "");
_cur = _form->cursor();
const char ordine = *_mask->get(F_ORDINE);
switch (ordine)
{
case 'C':
_cur->setkey(1);
darec.put("CODART",_mask->get(F_DAART));
arec.put("CODART",_mask->get(F_AART));
_form->find_field('B',odd_page,"H_CATMER").hide();
_form->find_field('B',odd_page,"TOT_CATMER").hide();
_form->find_field('B',odd_page,"H_SCATMER").hide();
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART[1,1]",_strexpr);
break;
case 'D':
_cur->setkey(2);
darec.put("DESCR",_mask->get(F_DADES));
arec.put("DESCR",_mask->get(F_ADES));
_form->find_field('B',odd_page,"H_CATMER").hide();
_form->find_field('B',odd_page,"TOT_CATMER").hide();
_form->find_field('B',odd_page,"H_SCATMER").hide();
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART[1,1]",_strexpr);
break;
case 'S':
case 'M':
{
TString16 m1,m2;
m1 = _mask->get(F_DAGRMERC);
m2 = _mask->get(F_AGRMERC);
if (ordine == 'S')
{
m1 << _mask->get(F_DASGRMERC);
m2 << _mask->get(F_ASGRMERC);
m1.trim();
m2.trim();
}
if (m2.empty() && _mask->get(F_AART).not_empty())
m2.fill('\254',5);
_cur->setkey(3);
darec.put("GRMERC", m1);
darec.put("CODART",_mask->get(F_DAART));
arec.put("GRMERC", m2);
arec.put("CODART",_mask->get(F_AART));
_form->find_field('B',odd_page,"H_CATMER").show();
_form->find_field('B',odd_page,"TOT_CATMER").show();
if (ordine == 'S')
{
_form->find_field('B',odd_page,"H_SCATMER").show();
_form->find_field('B',odd_page,"TOT_SCATMER").show();
}
else
{
_form->find_field('B',odd_page,"H_SCATMER").hide();
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("CODART[1,1]",_strexpr);
}
_form->set_ordering(mg_cat_merc);
}
break;
case 'R':
_form->set_ordering(mg_ragg_fisc);// Setta la subsection in modo da raggruppare per RAGGFIS
_form->use_alternate_cursor();
_cur = _form->cursor();
_cur->setkey(1);
darec.put("CODART",_mask->get(F_DAART));
arec.put("CODART",_mask->get(F_AART));
if (_mask->get(F_DARAGGFIS).not_empty())
cfilter.format("(RAGGFIS>=\"%s\")",(const char*)_mask->get(F_DARAGGFIS));
if (cfilter.not_empty() && _mask->get(F_ARAGGFIS).not_empty())
{
cfilter << "&&(RAGGFIS<=\"";
cfilter << _mask->get(F_ARAGGFIS);
cfilter << "\")";
}
_form->find_field('B',odd_page,"H_CATMER").show();
_form->find_field('B',odd_page,"TOT_CATMER").show();
_form->find_field('B',odd_page,"GRUPPI_CATMER").setcondition("RAGGFIS",_strexpr);
_form->find_field('B',odd_page,"H_SCATMER").hide();
_form->find_field('B',odd_page,"TOT_SCATMER").hide();
_form->find_field('B',odd_page,"GRUPPI_SCATMER").setcondition("RAGGFIS",_strexpr);
break;
default:
break;
}
TEsercizi_contabili esercizi;
const int cod_es_prec = esercizi.pred(_mask->get_int(F_ANNOES));
TString16 es_prec ; es_prec.format("%04d", cod_es_prec);
_form->find_field('H',odd_page,4).set(es_prec);
_cur->relation()->replace(new TLocalisamfile(LF_STOMAG),1,joinexp);
_cur->setfilter(cfilter,TRUE);
_cur->setregion(darec,arec);
set_def_valuta(*_form);
_form->print();
delete _form;
}
} // while true
return ;
}
int mg3500(int argc, char* argv[])
{
TStampa_storgiac a;
a.run(argc,argv,TR("Stampa storico rimanenze"));
return 0;
}