#include #include "mglib.h" #include "mg3500.h" #include "mg3500a.h" #include "mg3frm.h" #include "../cg/cglib01.h" // mg3500 Stampa 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 ///////////////////////////////////////////////////// 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... 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,"Stampa storico rimanenze"); return 0; }