campo-sirio/mg/mg3500.cpp
alex a0a36d6b33 Patch level : XX.282
Files correlati     :
Ricompilazione Demo : [ ]
Commento            : Riportata la versione 01.05 patch 282


git-svn-id: svn://10.65.10.50/trunk@8019 c028cbd2-c16b-5b4b-a496-9718f37d4682
1999-04-06 15:34:39 +00:00

191 lines
5.9 KiB
C++
Executable File

#include <applicat.h>
#include "mglib.h"
#include "mg3500.h"
#include "mg3frm.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 ;
TForm_storgiac(const char *name,const char *code) ;
virtual ~TForm_storgiac();
};
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;
}
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();
}
/////////////////////////////////////////////////////
// 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();
public:
TStampa_storgiac() {}
virtual ~TStampa_storgiac() {};
};
bool TStampa_storgiac::create()
{
_mask = new TStampemg_mask("mg3500");
_files = new TArray();
_files->add(new TLocalisamfile(LF_STOMAG));
return TSkeleton_application::create();
}
bool TStampa_storgiac::destroy()
{
delete _mask;
delete _files;
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...
joinexp << "ANNOESRIF==" << _mask->get(F_ANNOES) << "|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(cat_merc);
}
break;
case 'R':
_form->set_ordering(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;
}
_cur->relation()->replace(new TLocalisamfile(LF_STOMAG),1,joinexp);
_cur->setfilter(cfilter,TRUE);
_cur->setregion(darec,arec);
_form->print();
delete _form;
}
} // while true
return ;
}
int mg3500(int argc, char* argv[])
{
TStampa_storgiac a;
a.run(argc,argv,"Stampa storico rimanenze");
return 0;
}