Files correlati : Ricompilazione Demo : [ ] Commento : RIportata la verione 3.2 1167 git-svn-id: svn://10.65.10.50/trunk@16733 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			184 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			184 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <automask.h>
 | |
| #include <execp.h>
 | |
| #include <filetext.h>
 | |
| #include <progind.h>
 | |
| #include <printer.h>
 | |
| #include <reprint.h>
 | |
| #include <reputils.h>
 | |
| #include <sort.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "co0.h"
 | |
| #include "co0900a.h"
 | |
| 
 | |
| #include "clifo.h"
 | |
| #include "comuni.h"
 | |
| #include "doc.h"
 | |
| #include "rdoc.h"
 | |
| 
 | |
| #include "..\cg\cglib01.h"
 | |
| #include "..\ve\velib.h"
 | |
| 
 | |
| // TAutomask
 | |
| 
 | |
| class TAggiornaPrezzi_mask : public TAutomask
 | |
| {
 | |
| protected:
 | |
|   bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| public:
 | |
|   TAggiornaPrezzi_mask();
 | |
|   virtual ~TAggiornaPrezzi_mask() {};
 | |
| };
 | |
|   
 | |
| TAggiornaPrezzi_mask::TAggiornaPrezzi_mask() :TAutomask ("co0900a")
 | |
| {
 | |
| }  
 | |
| 
 | |
| bool TAggiornaPrezzi_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
 | |
| { 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| 
 | |
| HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_F9)
 | |
|   {  
 | |
|     FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC));
 | |
|     strcpy(fs.type, "");
 | |
|     strcpy(fs.name, f.get());
 | |
|     xvt_fsys_get_default_dir(&fs.dir);
 | |
|     xvt_fsys_save_dir();
 | |
|     if (xvt_dm_post_file_open(&fs, TR("Selezione file")) == FL_OK)
 | |
|     {       
 | |
|       TFilename n;
 | |
|       xvt_fsys_convert_dir_to_str(&fs.dir, n.get_buffer(n.size()), n.size());
 | |
|       n.add(fs.name);
 | |
|       f.set(n);
 | |
|     }
 | |
|     xvt_fsys_restore_dir();
 | |
|     f.set_focus();
 | |
|   }
 | |
|   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| 
 | |
| // TSkeleton_application
 | |
| 
 | |
| class TAggiornaPrezzi : public TSkeleton_application
 | |
| {
 | |
| 	TAggiornaPrezzi_mask*		_msk;
 | |
|   TRelation*      _rel;
 | |
|   TCursor*        _cur;
 | |
|   TProgind*       _prog;  
 | |
| 
 | |
| public:           
 | |
| 	virtual bool create();
 | |
|   virtual bool destroy();
 | |
|   virtual void main_loop();
 | |
|   TAggiornaPrezzi() {}
 | |
| };
 | |
| 
 | |
| TAggiornaPrezzi& app() { return (TAggiornaPrezzi&) main_app(); }
 | |
| 
 | |
| bool TAggiornaPrezzi::create()
 | |
| {
 | |
|   open_files(LF_CLIFO, 0);
 | |
|   _msk = new TAggiornaPrezzi_mask();
 | |
|   return TSkeleton_application::create ();
 | |
| }
 | |
| 
 | |
| bool TAggiornaPrezzi::destroy()
 | |
| {
 | |
| 	delete _msk;
 | |
|   return TApplication::destroy();
 | |
| }
 | |
| 
 | |
| void TAggiornaPrezzi::main_loop()
 | |
| {  
 | |
| //	TConfig configfile("co0900.ini");
 | |
| 
 | |
|   if (_msk->run() == K_ENTER)
 | |
|   {
 | |
| 		TLog_report log("Errori generazione documenti pianificazione");
 | |
| 		bool errors = false;
 | |
| 
 | |
| 		TRelation rel_doc(LF_DOC);
 | |
| 		TRectype darec(LF_DOC), arec(LF_DOC);
 | |
| 		const TDate dadata = _msk->get_date(F_DATAINI);
 | |
| 		const TDate adata = _msk->get_date(F_DATAFIN);
 | |
| 		const int anno = dadata.year();
 | |
| 		const TString8 codnum = _msk->get(F_CODNUM);
 | |
| 		const TString8 codmer = _msk->get(F_CODMER);
 | |
| 		const TString80 codart = _msk->get(F_CODART);
 | |
| 		const real prezzo = _msk->get_real(F_PREZZO);
 | |
| 
 | |
| 		darec.put(DOC_DATADOC, dadata);	
 | |
| 		darec.put(DOC_PROVV, "D");
 | |
| 		darec.put(DOC_ANNO, anno);
 | |
| 		darec.put(DOC_CODNUM, codnum);
 | |
| 
 | |
| 		arec.put(DOC_DATADOC, adata);
 | |
| 		arec.put(DOC_PROVV, "D");
 | |
| 		arec.put(DOC_ANNO, anno);
 | |
| 		arec.put(DOC_CODNUM, codnum);
 | |
| 
 | |
| 		TString filtro;
 | |
| 		filtro << "CODNUM='" << codnum << "'";
 | |
| 		TCursor cur_doc (&rel_doc, filtro, 3, &darec, &arec);
 | |
| 		const long items = cur_doc.items();
 | |
| 		TProgind progind(items, "Aggiornamento prezzi in corso...", false, true);
 | |
| 
 | |
| 		for (cur_doc = 0; cur_doc.pos() < items; ++cur_doc)
 | |
| 		{ 
 | |
| 			TDocumento doc(cur_doc.curr());
 | |
| 
 | |
| 			if (codmer == doc.get("MERCATO"))
 | |
| 			{
 | |
| 				bool rewrite = false;
 | |
| 
 | |
| 				progind.addstatus(1);
 | |
| 				for (int i = 1; i <= doc.rows(); i++)
 | |
| 				{
 | |
| 					TRiga_documento& row = doc[i];
 | |
| 					const TString80 codice(row.get(RDOC_CODART));
 | |
| 
 | |
| 					if (row.is_articolo() && codice == codart)
 | |
| 					{
 | |
| 						rewrite = true;
 | |
| 						row.put(RDOC_PREZZO, prezzo);
 | |
| 					}
 | |
| 				}
 | |
| 				if (rewrite)
 | |
| 				{
 | |
| 					int err = doc.rewrite();
 | |
| 					if (err != NOERR)
 | |
| 					{
 | |
| 						TString errore;
 | |
| 						errore.format("Errore %d nell'aggiornamento del documento %ld", err, doc.get_long(DOC_NDOC));
 | |
| 						log.log(2, errore);
 | |
| 						errors = true;
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 		if (errors)
 | |
| 		{
 | |
| 			TReport_book buc;
 | |
| 			buc.add(log);
 | |
| 			buc.preview();
 | |
| 		}
 | |
|   }   
 | |
| }
 | |
| 
 | |
| 
 | |
| int co0900(int argc, char* argv[])
 | |
| {
 | |
|   TAggiornaPrezzi main_app;
 | |
|   main_app.run(argc, argv, TR("Aggiornamento prezzi"));
 | |
|   return TRUE;
 | |
| }
 | |
| 
 |