Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 1.5 fino alla patch 811 git-svn-id: svn://10.65.10.50/trunk@8985 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			137 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			137 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <execp.h>
 | 
						|
#include <tabapp.h>
 | 
						|
#include <tabutil.h>
 | 
						|
 | 
						|
// @cmember Costruttore
 | 
						|
TTable_application::TTable_application() 
 | 
						|
               : _msk(NULL), _rel(NULL) 
 | 
						|
{ }
 | 
						|
 | 
						|
// @cmember Distruttore
 | 
						|
TTable_application::~TTable_application() 
 | 
						|
{ }
 | 
						|
 | 
						|
// @cmember Indica se la futura <mf TTable_application::get_mask> ritornera' una maschera diversa
 | 
						|
//        dalla corrente.
 | 
						|
bool TTable_application::changing_mask(int mode) 
 | 
						|
{ return FALSE; }
 | 
						|
 | 
						|
// @cmember Richiede la maschera da usare
 | 
						|
TMask* TTable_application::get_mask(int mode) 
 | 
						|
{ 
 | 
						|
  CHECK(_msk, "Null mask");
 | 
						|
  return _msk; 
 | 
						|
}
 | 
						|
 | 
						|
// @cmember Ritorna la relazione da modificare
 | 
						|
TRelation* TTable_application::get_relation() const 
 | 
						|
{ 
 | 
						|
  CHECK(_rel, "Null relation");
 | 
						|
  return _rel; 
 | 
						|
}
 | 
						|
 | 
						|
void TTable_application::print()
 | 
						|
{
 | 
						|
  TString16 cmd;
 | 
						|
  cmd << "ba3 -1 " << get_tabname();
 | 
						|
  TExternal_app stampa(cmd);
 | 
						|
  stampa.run();
 | 
						|
}
 | 
						|
 | 
						|
void TTable_application::init_query_mode(TMask& m) 
 | 
						|
{
 | 
						|
  m.enable(-GR_MODIFY_PROTECTED);
 | 
						|
  m.enable(-GR_RECORD_PROTECTED);
 | 
						|
}
 | 
						|
 | 
						|
void TTable_application::init_modify_mode(TMask& m) 
 | 
						|
{
 | 
						|
  m.disable(-GR_MODIFY_PROTECTED);
 | 
						|
  const bool enable = !(_rel->curr().get_bool(FPC));
 | 
						|
  m.enable(-GR_RECORD_PROTECTED,enable);
 | 
						|
}
 | 
						|
 | 
						|
bool TTable_application::protected_record(TRectype& rec) 
 | 
						|
{ 
 | 
						|
  return rec.get_bool(FPC);
 | 
						|
}
 | 
						|
 | 
						|
TString& TTable_application::get_mask_name(TString& t) const
 | 
						|
{
 | 
						|
  CHECK(_rel,"Can't use a NULL relation to retrieve table module");
 | 
						|
  TTable& tab = (TTable&) _rel->lfile();
 | 
						|
 | 
						|
  TString16 m = _tabname;
 | 
						|
  if (m[0] == '%') m.ltrim(1);
 | 
						|
  
 | 
						|
  t = tab.module();
 | 
						|
  t << "tb" << m;
 | 
						|
  t.upper();
 | 
						|
  if (!fexist(t))
 | 
						|
    t.overwrite("ba");
 | 
						|
  return t;
 | 
						|
}
 | 
						|
 | 
						|
TMask* TTable_application::set_mask(TMask* m)
 | 
						|
{
 | 
						|
  if (_msk != NULL)  
 | 
						|
    delete _msk;
 | 
						|
 | 
						|
  if (m != NULL) 
 | 
						|
  {
 | 
						|
    // imposta la maschera come maschera della applicazione
 | 
						|
    _msk = m;
 | 
						|
  } 
 | 
						|
  else 
 | 
						|
  {
 | 
						|
    // alloca la maschera standard come maschera della applicazione
 | 
						|
    TFilename name;       
 | 
						|
    get_mask_name(name);
 | 
						|
    _msk = new TMask(name);
 | 
						|
  }
 | 
						|
  return _msk;
 | 
						|
}
 | 
						|
 | 
						|
bool TTable_application::user_create()
 | 
						|
{
 | 
						|
  if (argc() < 3) 
 | 
						|
    return FALSE;
 | 
						|
  
 | 
						|
  _tabname = argv(2);
 | 
						|
  _tabname.upper();
 | 
						|
  _rel = new TRelation(_tabname);
 | 
						|
  
 | 
						|
  set_mask();
 | 
						|
  
 | 
						|
  const int campi = _msk->fields();
 | 
						|
  for (int i = 0; i < campi; i++)
 | 
						|
  {
 | 
						|
    const TMask_field& f = _msk->fld(i);
 | 
						|
    if (f.in_group(GR_SEARCH))
 | 
						|
    {
 | 
						|
      set_search_field(f.dlg());
 | 
						|
      break;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  
 | 
						|
  TFilename rpt; 
 | 
						|
  get_mask_name(rpt); 
 | 
						|
  rpt.ext("rpt");
 | 
						|
  if (rpt.exist()) 
 | 
						|
    enable_menu_item(M_FILE_PRINT);
 | 
						|
  
 | 
						|
  TString title;
 | 
						|
  _msk->get_caption(title);
 | 
						|
  set_title(title);
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TTable_application::user_destroy() 
 | 
						|
{
 | 
						|
  if (_msk) delete _msk;
 | 
						|
  if (_rel) delete _rel;
 | 
						|
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 |