Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 01.05 patch 282 git-svn-id: svn://10.65.10.50/trunk@8058 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			190 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			190 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include "db0.h"
 | 
						|
 | 
						|
#include <msksheet.h>
 | 
						|
#include <tabapp.h>
 | 
						|
#include <modaut.h>
 | 
						|
#include "dblib.h"
 | 
						|
 | 
						|
#include "dbtblav.h"
 | 
						|
 | 
						|
class TLavorazione_tab : public TLavorazione
 | 
						|
{
 | 
						|
public:
 | 
						|
  void put_sheet(TSheet_field & s);
 | 
						|
  void fill_sheet(TSheet_field & s);
 | 
						|
  TLavorazione_tab (const TRectype r) : TLavorazione(r) {}
 | 
						|
  TLavorazione_tab (const char* cod) : TLavorazione(cod) {}
 | 
						|
  virtual ~TLavorazione_tab (){}
 | 
						|
};
 | 
						|
 | 
						|
void TLavorazione_tab::fill_sheet(TSheet_field & sheet)
 | 
						|
{
 | 
						|
  sheet.destroy();
 | 
						|
  int righe = 0;
 | 
						|
  const int maxlinee = linee();
 | 
						|
  for (int j = 0; j < maxlinee ; j++)
 | 
						|
  {
 | 
						|
    TToken_string& row = sheet.row(righe);
 | 
						|
    row=cod_linea(j);
 | 
						|
    if (!row.blank())
 | 
						|
    {
 | 
						|
      row.add(raw_numpers_linea(j)   ,F_LNUMPERS-101);
 | 
						|
      row.add(raw_produttiv_linea(j).string() ,F_LPRODUTTIV-101);
 | 
						|
      sheet.check_row(righe);
 | 
						|
      righe++;
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void TLavorazione_tab::put_sheet(TSheet_field& sheet)
 | 
						|
{
 | 
						|
  int righe = sheet.items();
 | 
						|
 | 
						|
  bool ok=TRUE;
 | 
						|
  int l=0;
 | 
						|
  reset_linee();
 | 
						|
  for (int i = 0; i < righe ; i++)
 | 
						|
  {
 | 
						|
    TToken_string &  row=sheet.row(i);
 | 
						|
    TString16 linea =row.get(F_CODLIN-101);
 | 
						|
    if (!linea.blank())
 | 
						|
    {
 | 
						|
      ok=FALSE;
 | 
						|
      // aggiunge il codice linea
 | 
						|
      linea.trim();
 | 
						|
      if (set_cod_linea(l,linea))
 | 
						|
      {
 | 
						|
        // aggiunge il numero persone
 | 
						|
        linea=row.get(F_LNUMPERS-101);
 | 
						|
        linea.rtrim();
 | 
						|
        if (set_numpers_linea(l,atoi(linea)))
 | 
						|
        {
 | 
						|
          // aggiunge il fattore di produttività
 | 
						|
          linea=row.get(F_LPRODUTTIV-101);
 | 
						|
          linea.cut(5);
 | 
						|
          linea.rtrim();
 | 
						|
          if (!set_produttiv_linea(l,real(linea)))
 | 
						|
            break;
 | 
						|
          ok=TRUE;
 | 
						|
        }
 | 
						|
        else break;
 | 
						|
      }
 | 
						|
      else break;
 | 
						|
      l++;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  if (!ok)
 | 
						|
  {
 | 
						|
    set_cod_linea(l,"");
 | 
						|
    message_box("Impossibile memorizzare piu' di %d righe",l);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class TDistinta_tables : public TTable_application
 | 
						|
{
 | 
						|
protected:
 | 
						|
  virtual int read(TMask& m);
 | 
						|
  virtual int write(const TMask& m);
 | 
						|
  virtual int rewrite(const TMask& m);
 | 
						|
  virtual bool user_create();
 | 
						|
 | 
						|
  virtual TString& get_mask_name(TString& name) const;
 | 
						|
 | 
						|
  virtual TMask * set_mask(TMask * _m);
 | 
						|
public:
 | 
						|
  void rows2rel(const TMask& m);
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
bool TDistinta_tables::user_create()
 | 
						|
{
 | 
						|
  bool err = TTable_application::user_create();
 | 
						|
  if (get_tabname() == "LAV")
 | 
						|
  {
 | 
						|
    TLavorazione_tab *lav= new TLavorazione_tab("");
 | 
						|
    get_relation()->lfile().set_curr(lav);
 | 
						|
  }
 | 
						|
  return err;
 | 
						|
}
 | 
						|
 | 
						|
TMask * TDistinta_tables::set_mask(TMask* _m)
 | 
						|
{
 | 
						|
  TMask* mask = TTable_application::set_mask(_m);
 | 
						|
  if (get_tabname() == "LAV")
 | 
						|
  {
 | 
						|
    TSheet_field& sheet = mask->sfield(F_SHEET);
 | 
						|
    if (!has_module(MRAUT))
 | 
						|
      mask->disable_page(1);
 | 
						|
  }
 | 
						|
  return mask;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
TString& TDistinta_tables::get_mask_name(TString& name) const
 | 
						|
{
 | 
						|
  name = get_tabname();
 | 
						|
  name.insert("dbtb", 0);
 | 
						|
  return name;
 | 
						|
}
 | 
						|
 | 
						|
int TDistinta_tables::read(TMask& m)
 | 
						|
{
 | 
						|
  int err = TTable_application::read(m);
 | 
						|
  if (err == NOERR)
 | 
						|
  {
 | 
						|
    if (get_tabname() == "LAV")
 | 
						|
    {
 | 
						|
      TSheet_field& sheet = m.sfield(F_SHEET);
 | 
						|
      if (sheet.shown())
 | 
						|
      {
 | 
						|
        TLavorazione_tab &lav=(TLavorazione_tab &)get_relation()->curr();
 | 
						|
        lav.fill_sheet(sheet);
 | 
						|
        sheet.force_update();
 | 
						|
      } 
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return err;
 | 
						|
}
 | 
						|
 | 
						|
void TDistinta_tables::rows2rel(const TMask& m)
 | 
						|
{
 | 
						|
  if (get_tabname() == "LAV")
 | 
						|
  {
 | 
						|
    TSheet_field& sheet = m.sfield(F_SHEET);
 | 
						|
    TLavorazione_tab &lav=(TLavorazione_tab &)get_relation()->curr();
 | 
						|
    lav.put_sheet(sheet);
 | 
						|
  }  
 | 
						|
}
 | 
						|
 | 
						|
int TDistinta_tables::write(const TMask& m)
 | 
						|
{
 | 
						|
  rows2rel(m);
 | 
						|
  int err = TTable_application::write(m);
 | 
						|
  return err;
 | 
						|
}
 | 
						|
 | 
						|
int TDistinta_tables::rewrite(const TMask& m)
 | 
						|
{
 | 
						|
  rows2rel(m);
 | 
						|
  int err = TTable_application::rewrite(m);
 | 
						|
  return err;
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// Main program
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
int db0100(int argc, char* argv[])
 | 
						|
{
 | 
						|
  if (argc > 2)
 | 
						|
  {
 | 
						|
    TString name;
 | 
						|
    name << "Tabella " << argv[2];
 | 
						|
    TDistinta_tables dt;
 | 
						|
    dt.run(argc, argv, name);
 | 
						|
  }
 | 
						|
  return 0;
 | 
						|
}
 |