Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunta traduzione alla distinta base git-svn-id: svn://10.65.10.50/trunk@11140 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			242 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			242 lines
		
	
	
		
			5.2 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(FR("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);
 | |
| 
 | |
|   virtual void ini2sheet(TConfig& ini, TSheet_field &sheet);
 | |
|   virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
 | |
| 
 | |
| 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")
 | |
|     {
 | |
|       TLavorazione_tab &lav=(TLavorazione_tab &)get_relation()->curr();
 | |
|       TSheet_field& sheet = m.sfield(F_SHEET);
 | |
|       if (sheet.shown())
 | |
|       {
 | |
|         lav.fill_sheet(sheet);
 | |
|         sheet.force_update();
 | |
|       }
 | |
|       if (lav.get_real("R10").is_zero()) 
 | |
|         m.set(F_COSUNIT, lav.prezzo());
 | |
|     }
 | |
|   }
 | |
|   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;
 | |
| }
 | |
| 
 | |
| void TDistinta_tables::ini2sheet(TConfig& ini, TSheet_field &sheet)
 | |
| {
 | |
|   if (get_tabname() == "LAV")
 | |
|   {
 | |
|     TString8 para;
 | |
|     for (int i = 0; ; i++)
 | |
|     {
 | |
|       para.format("%d,%d", LF_TAB, i+1);
 | |
|       if (ini.set_paragraph(para))
 | |
|       {  
 | |
|         TToken_string& row = sheet.row(i);
 | |
|         row.add(ini.get("CODLIN"), 0);
 | |
|         row.add(ini.get("CODIMP"), 2);
 | |
|         row.add(ini.get("LNUMPERS"), 3);
 | |
|         row.add(ini.get("LPRODUTTIV"), 4);
 | |
|         sheet.check_row(i);
 | |
|       }
 | |
|       else
 | |
|         break;
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDistinta_tables::sheet2ini(TSheet_field& sheet,TConfig& ini)
 | |
| {
 | |
|   if (get_tabname() == "LAV")
 | |
|   {
 | |
|     TString8 para;
 | |
|     FOR_EACH_SHEET_ROW(sheet, i, row)
 | |
|     {
 | |
|       para.format("%d,%d", LF_TAB, i+1);
 | |
|       ini.set_paragraph(para);
 | |
|       ini.set("CODLIN", row->get(0));
 | |
|       ini.set("CODIMP", row->get(2));
 | |
|       ini.set("LNUMPERS", row->get(3));
 | |
|       ini.set("LPRODUTTIV", row->get(4));
 | |
|     }
 | |
|     for ( ; ; i++)
 | |
|     {
 | |
|       para.format("%d,%d", LF_TAB, i+1);
 | |
|       if (ini.set_paragraph(para))
 | |
|         ini.remove_all();
 | |
|       else
 | |
|         break;
 | |
|     }  
 | |
|   }
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Main program
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| int db0100(int argc, char* argv[])
 | |
| {
 | |
|   if (argc > 2)
 | |
|   {
 | |
|     TString name;
 | |
|     name << TR("Tabella ") << argv[2];
 | |
|     TDistinta_tables dt;
 | |
|     dt.run(argc, argv, name);
 | |
|   }
 | |
|   return 0;
 | |
| }
 |