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
		
			
				
	
	
		
			150 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "dbcv.h"
 | |
| #include "dbcv01a.h"
 | |
| #include "dbcv09.h"
 | |
| #include <filetext.h>
 | |
| #include <mask.h>
 | |
| #include "dbcv01.h"
 | |
| 
 | |
| 
 | |
| bool TCrea_dbf::create()
 | |
| {
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| bool TCrea_dbf::destroy()
 | |
| {
 | |
|   return TSkeleton_application::destroy();
 | |
| }
 | |
| void TCrea_dbf::txt2dbf(const char * dbf,const char *txt,const char *ini  )
 | |
| {
 | |
|   long lineno=0L;
 | |
|   TIndwin iw(80, format("Ricostruzione file DBF da file di testo BPCS ..."),FALSE,FALSE);
 | |
|   TImport_file dest(_path,dbf);
 | |
|   TFilename txtname(_path),ininame(_path);
 | |
|   txtname.add(txt);txtname.ext("txt");
 | |
|   if (ini)
 | |
|     ininame.add(ini);
 | |
|   else
 | |
|     ininame.add(txt);
 | |
|   ininame.ext("ini");
 | |
|   TFile_text source(txtname, ininame);
 | |
|   dest.zap();
 | |
|   TRecord_text rec;
 | |
|   source.open();
 | |
|   int err;
 | |
|   while ((err = source.read(rec))==NOERR)
 | |
|   {
 | |
|     if ((lineno%TICK) == 0)
 | |
|     {
 | |
|       iw.set_text(format("Importazione %s : linea %ld",txt, lineno));
 | |
|       do_events();
 | |
|     }
 | |
|     TTracciato_record *tr=source.t_rec(rec.type());
 | |
|     if (tr)
 | |
|     {
 | |
|       TArray& a_tc = tr->tracciati_campo();
 | |
|       int items =  a_tc.items();                 
 | |
|       TString valore;
 | |
|       dest.zero();
 | |
|       for (int i = 0; i < items; i++)
 | |
|       {
 | |
|         const TTracciato_campo& tc = tr->get(i);
 | |
|         TFieldref field(tc.field());
 | |
|         if (field.name().not_empty())
 | |
|         {
 | |
|           valore = rec.row(i);
 | |
|           valore.trim();
 | |
|           dest.put(field.name(),valore);
 | |
|         }  
 | |
|       }
 | |
|       dest.write();
 | |
|     }
 | |
|     lineno++;
 | |
|   }
 | |
|   source.close();
 | |
| }
 | |
| 
 | |
| void TCrea_dbf::main_loop() 
 | |
| {
 | |
|   TMask m("dbcv01a.msk");
 | |
|   while (m.run()!=K_QUIT)
 | |
|   {
 | |
|     set_path(m.get(F_PATH));
 | |
|     // anagrafiche     
 | |
|     if (m.get_bool(F_ARTS))
 | |
|     {
 | |
|       txt2dbf(BPCS_IMPORTEX,"iims_aga");
 | |
|       txt2dbf(BPCS_ANAGRAFICA, "iim_aga");
 | |
|     }
 | |
|     if (m.get_bool(F_BOMS))
 | |
|       txt2dbf(BPCS_DISTINTE,"mbm_aga");
 | |
|     if (m.get_bool(F_DIVS ))
 | |
|       txt2dbf(BPCS_DIVISORI,"cic_aga");
 | |
|     // magazzino
 | |
|     if (m.get_bool(F_MOVMAG))
 | |
|     {
 | |
|       TFilename txtname(m.get(F_MOVMAG_FILE));
 | |
|       TFilename dbfname(txtname);
 | |
|       if (txtname.blank())
 | |
|       {
 | |
|         txtname = "ith_aga";
 | |
|         dbfname = BPCS_MOVMAG;
 | |
|       } else {
 | |
|         TFilename s(m.get(F_PATH)),d(m.get(F_PATH));
 | |
|         s.add(BPCS_MOVMAG);
 | |
|         s.ext("dbf");
 | |
|         d.add(dbfname.name());
 | |
|         d.ext("dbf");
 | |
|         if (!d.exist())
 | |
|         {
 | |
|           fcopy(s,d);
 | |
|           s.ext("cdx");
 | |
|           d.ext("cdx");
 | |
|           fcopy(s,d);
 | |
|         }
 | |
|       }
 | |
|       txt2dbf(dbfname,txtname,"ith_aga");
 | |
|     }
 | |
|     // ordini
 | |
|     if (m.get_bool(F_ORDACQ))
 | |
|       txt2dbf(BPCS_ORDACQ,"ord_acq");
 | |
|     if (m.get_bool(F_ORDPROD))
 | |
|       txt2dbf(BPCS_SHOPORDS,"ord_prod");
 | |
|     if (m.get_bool(F_ORDCLI))
 | |
|       txt2dbf(BPCS_FIRMORD,"ord_cli" );
 | |
|   }
 | |
| }
 | |
| 
 | |
| class TCreaauto_dbf: public  TCrea_dbf
 | |
| {
 | |
| protected:
 | |
|   void main_loop() ;
 | |
| };
 | |
| 
 | |
| void TCreaauto_dbf::main_loop() 
 | |
| {
 | |
|   TCreaauto_dbf creadbf;
 | |
|   TMask m("dbcv01b.msk");
 | |
|   if (m.run() != K_QUIT)
 | |
|   {
 | |
|     TFilename source(m.get(F_MOVMAG_FILE));
 | |
|     TFilename txtsource(source);
 | |
|     creadbf.set_path(m.get(F_PATH));
 | |
|     creadbf.txt2dbf(source,txtsource,"ith_aga");
 | |
|   }
 | |
| }
 | |
| 
 | |
| int dbcv01(int argc, char* argv[])
 | |
| {
 | |
|   if (argc > 2 && argv[2][0]=='a')
 | |
|   {
 | |
|     TCreaauto_dbf dt;
 | |
|     dt.run(argc, argv, "Conversione txt da magazzino BPCS a files DBF");  
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     TCrea_dbf dt;
 | |
|     dt.run(argc, argv, "Conversione txt da BPCS in files DBF");
 | |
|   }
 | |
|   return 0;
 | |
| }
 |