Files correlati : cg4.exe Ricompilazione Demo : [ ] Commento : Aggiunto il supporto delle lingue a cg5 git-svn-id: svn://10.65.10.50/trunk@10970 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			260 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			260 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <mask.h>                     
 | 
						|
#include <prefix.h>
 | 
						|
#include <sheet.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <urldefid.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#define F_YEAR      101
 | 
						|
 | 
						|
 | 
						|
// ripristino liquidazione  
 | 
						|
// dati anno e ditta scancella tutte
 | 
						|
// le tabelle dimmerda  
 | 
						|
// piu' che altro serve alla Prassi 
 | 
						|
// per non far cazzate quando provano
 | 
						|
 | 
						|
class TRipristino_liq : public TApplication
 | 
						|
{
 | 
						|
  long          _firm;
 | 
						|
  TString       _year;
 | 
						|
  TRelation*    _nditte;
 | 
						|
  TArray_sheet* _ditte;
 | 
						|
  TArray        _nomiditte;
 | 
						|
 | 
						|
  virtual bool create();
 | 
						|
  virtual bool destroy();
 | 
						|
  
 | 
						|
  bool menu(MENU_TAG) { return do_restore(); }
 | 
						|
 | 
						|
  // handuler 
 | 
						|
  static bool ch_year_handler(TMask_field& f, KEY key);
 | 
						|
 | 
						|
public: 
 | 
						|
 | 
						|
  void          build_ditte_sheet();
 | 
						|
  void          build_nomiditte();
 | 
						|
  void          set_year(const char* y) { _year = y; }                                                             
 | 
						|
 | 
						|
  bool          do_restore(); 
 | 
						|
  bool          restore_firm(long firm);                             
 | 
						|
  void          zero_cursor(const char * tablename);
 | 
						|
 | 
						|
  static TRipristino_liq& app() { return (TRipristino_liq&)main_app(); }
 | 
						|
 | 
						|
  TRipristino_liq() {} 
 | 
						|
  virtual ~TRipristino_liq() {}
 | 
						|
};
 | 
						|
 | 
						|
bool TRipristino_liq::ch_year_handler(TMask_field& f, KEY key)
 | 
						|
{                                                    
 | 
						|
  if (key == K_TAB && f.focusdirty())
 | 
						|
  {                         
 | 
						|
    TWait_cursor hourglass;
 | 
						|
    app().set_year(f.get());
 | 
						|
    app().build_nomiditte();
 | 
						|
    app().build_ditte_sheet();    
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
} 
 | 
						|
 | 
						|
 | 
						|
void TRipristino_liq::build_ditte_sheet()
 | 
						|
{
 | 
						|
  // build sheet
 | 
						|
  _ditte->destroy();
 | 
						|
  for (int i = 0; i < _nomiditte.items(); i++)
 | 
						|
  {
 | 
						|
    TToken_string* d = new TToken_string(64);
 | 
						|
    *d = (TToken_string&)_nomiditte[i];
 | 
						|
    const char vers = d->get_char(2);
 | 
						|
    
 | 
						|
    bool selectable = vers == '?';
 | 
						|
    d->insert(" |", 0);        
 | 
						|
    
 | 
						|
    const long pos = _ditte->add(d);     
 | 
						|
    if (selectable)  _ditte->disable_row(pos);
 | 
						|
  }     
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void TRipristino_liq::build_nomiditte()
 | 
						|
{                 
 | 
						|
  _nomiditte.destroy();
 | 
						|
  // ricostruire _nomiditte e rifare build_ditte_sheet
 | 
						|
	TRectype & ditta = _nditte->lfile().curr();
 | 
						|
	TCursor cur(_nditte);
 | 
						|
	const TRecnotype items = cur.items();
 | 
						|
 | 
						|
	cur.freeze();
 | 
						|
  for (cur = 0L; cur.pos() < items; ++cur)
 | 
						|
  {     
 | 
						|
    // check no archivi
 | 
						|
    bool good = prefix().exist(ditta.get_long("CODDITTA"));                        
 | 
						|
    
 | 
						|
    if (good) 
 | 
						|
    {   
 | 
						|
      // check no parametri liquidazione                                               
 | 
						|
      TString16 cod; 
 | 
						|
      
 | 
						|
			cod.format("%05ld%s", ditta.get_long("CODDITTA"), (const char *)_year);
 | 
						|
      
 | 
						|
			const TRectype & lia = cache().get("%LIA", cod);
 | 
						|
 | 
						|
	    TToken_string* d = new TToken_string(64);
 | 
						|
    
 | 
						|
	    // add record 
 | 
						|
		  d->add(ditta.get("CODDITTA"));
 | 
						|
			d->add(ditta.get("RAGSOC"));
 | 
						|
			const TString & fr = lia.get("S7");
 | 
						|
 | 
						|
			d->add(fr.empty() ? "??" : fr);
 | 
						|
		  _nomiditte.add(d);  
 | 
						|
		}
 | 
						|
  }
 | 
						|
  TApplication::set_firm(_firm);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
bool TRipristino_liq::create()
 | 
						|
{                     
 | 
						|
  TApplication::create();
 | 
						|
  _firm = get_firm();
 | 
						|
  TDate oggi(TODAY);                    
 | 
						|
  _year.format("%d",oggi.year());
 | 
						|
  _nditte = new TRelation(LF_NDITTE);
 | 
						|
  _ditte  = new TArray_sheet(-1, -1, 65, 20, TR("Selezione Ditte"),
 | 
						|
                             HR("@1|Cod.@5|Ragione Sociale@50|Vers."));  
 | 
						|
  build_nomiditte();
 | 
						|
  build_ditte_sheet();
 | 
						|
  
 | 
						|
  dispatch_e_menu(BAR_ITEM(1));    
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TRipristino_liq::destroy()
 | 
						|
{
 | 
						|
  delete _nditte;
 | 
						|
  delete _ditte;
 | 
						|
  return TApplication::destroy();
 | 
						|
}  
 | 
						|
 | 
						|
bool TRipristino_liq::do_restore()
 | 
						|
{ 
 | 
						|
  KEY k; int i;
 | 
						|
  TMask m("cg5600a"); 
 | 
						|
  
 | 
						|
  m.field(F_YEAR).set(_year);
 | 
						|
  m.set_handler(F_YEAR, ch_year_handler);
 | 
						|
  _ditte->enable_check();
 | 
						|
  
 | 
						|
  while ((k = m.run()) != K_ESC)
 | 
						|
  {                            
 | 
						|
    if (k == K_QUIT) break;
 | 
						|
    switch(k)
 | 
						|
    {
 | 
						|
    case K_ENTER: 
 | 
						|
      begin_wait();
 | 
						|
      for(i = 0; i < _ditte->items(); i++)
 | 
						|
      {
 | 
						|
        if (_ditte->checked(i))
 | 
						|
        {              
 | 
						|
          TToken_string& rw = _ditte->row(i);
 | 
						|
          restore_firm(rw.get_long(1));
 | 
						|
        } 
 | 
						|
      }
 | 
						|
      end_wait();
 | 
						|
      break;
 | 
						|
    case DLG_SELECT:
 | 
						|
      _ditte->run();
 | 
						|
      break;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  
 | 
						|
  set_firm(_firm); 
 | 
						|
  return k != K_QUIT; 
 | 
						|
}
 | 
						|
 | 
						|
void TRipristino_liq::zero_cursor(const char * tablename)
 | 
						|
{
 | 
						|
	TRelation rel(tablename);
 | 
						|
	TRectype & rec = rel.curr();
 | 
						|
	
 | 
						|
	rec.put("CODTAB", _year);
 | 
						|
 | 
						|
	TCursor cur(&rel, "", 1, &rec, &rec);
 | 
						|
	const TRecnotype items = cur.items();
 | 
						|
 | 
						|
	cur.freeze();
 | 
						|
	for (cur = 0L; cur.pos() < items; ++cur)
 | 
						|
		rel.remove();
 | 
						|
}
 | 
						|
 | 
						|
bool TRipristino_liq::restore_firm(long firm)
 | 
						|
{  
 | 
						|
  // azzera: campi progressivi in LIA e PLA
 | 
						|
  // cancella: tutti PPA, LIM, PIM, RMB, PLM, PTM
 | 
						|
  set_firm(firm);
 | 
						|
  
 | 
						|
  TTable lia("%LIA");
 | 
						|
	TString cod;
 | 
						|
 | 
						|
	cod.format("%05ld%s", firm, (const char *)_year);
 | 
						|
	lia.put("CODTAB", cod);
 | 
						|
 | 
						|
  if (lia.read(_isequal, _lock) == NOERR)
 | 
						|
  {
 | 
						|
    lia.zero("R1");
 | 
						|
    lia.zero("R2");
 | 
						|
    lia.zero("R3");
 | 
						|
    lia.zero("R4");
 | 
						|
    lia.zero("R5");
 | 
						|
    lia.zero("R6"); 
 | 
						|
	  lia.rewrite();
 | 
						|
  }
 | 
						|
  
 | 
						|
  TRelation relpla("%PLA");
 | 
						|
  TRectype & pla = relpla.curr();
 | 
						|
	
 | 
						|
	pla.put("CODTAB", cod);
 | 
						|
 | 
						|
	TCursor cur(&relpla, "", 1, &pla, &pla);
 | 
						|
	const TRecnotype items = cur.items();
 | 
						|
 | 
						|
  cur.freeze();
 | 
						|
	for (cur = 0L; cur.pos() < items; ++cur)
 | 
						|
  {
 | 
						|
		relpla.lfile().reread(_lock);
 | 
						|
    pla.zero("R0");
 | 
						|
    pla.zero("R1");
 | 
						|
    pla.zero("R2");
 | 
						|
    pla.zero("R3");
 | 
						|
    pla.zero("R4");
 | 
						|
    pla.zero("R9");
 | 
						|
    pla.zero("R10");
 | 
						|
    pla.zero("S1");
 | 
						|
    pla.zero("S2");
 | 
						|
    pla.zero("S3");
 | 
						|
    pla.zero("S4");
 | 
						|
	  relpla.rewrite();
 | 
						|
  }
 | 
						|
	zero_cursor("PIM");
 | 
						|
	zero_cursor("PLM");
 | 
						|
	zero_cursor("PTM");
 | 
						|
	zero_cursor("PPA");
 | 
						|
	zero_cursor("RMB");
 | 
						|
	zero_cursor("LIM");
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
int cg5600(int argc, char* argv[])
 | 
						|
{   
 | 
						|
  TRipristino_liq app;
 | 
						|
  app.run(argc, argv, TR("Ripristino liquidazione")); 
 | 
						|
  return 0;
 | 
						|
}
 |