Files correlati : co0.exe co1.exe Ricompilazione Demo : [ ] Commento : aggiunta stampa progressivi conferimenti Varie stampe dei vongolari. stampa per data licenza Modificato il tracciato dell'importazione conferimenti Non genera piu' documenti se il totale documento campione e' 0 Prima prova di filtro per stampa soci INAIL Creazione report , stampa soci inail Acconto 8% sui progressivi piu' modifiche alle stampe 8% e stampa progressivi Filtro sulla stampa co2200a per data licenza Totale sulla stampa progressivi Progressivi modificabili con shift f12 aggiunta stampa registro carico scarico Dalla versione 3.2 git-svn-id: svn://10.65.10.50/trunk@20584 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			291 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			291 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// gestione anagrafica soci cooperative
 | 
						|
#include <automask.h>
 | 
						|
#include <execp.h>
 | 
						|
#include <relapp.h>
 | 
						|
#include <pconti.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <tabutil.h>
 | 
						|
 | 
						|
#include "co0600a.h"
 | 
						|
 | 
						|
////////////////////////////////////////////////////////////////////////
 | 
						|
//MASCHERA
 | 
						|
////////////////////////////////////////////////////////////////////////
 | 
						|
 
 | 
						|
class TCoop_soci_msk : public TAutomask
 | 
						|
{
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
	virtual bool on_key(KEY key);
 | 
						|
	
 | 
						|
public:
 | 
						|
	void calcola_dati_nascita(const TString& cf, TDate& datanasc, TString8& comnasc);
 | 
						|
  TCoop_soci_msk() : TAutomask("co0600a") {}
 | 
						|
};
 | 
						|
 | 
						|
bool TCoop_soci_msk::on_key(KEY key)
 | 
						|
{
 | 
						|
	if (key == K_SHIFT + K_F12)
 | 
						|
	{
 | 
						|
		TSheet_field & prog = sfield(F_PROGRESSIVI);
 | 
						|
 | 
						|
		prog.enable(true);
 | 
						|
	}
 | 
						|
	return TAutomask::on_key(key);
 | 
						|
}
 | 
						|
 | 
						|
void TCoop_soci_msk::calcola_dati_nascita(const TString& cf, TDate& datanasc, TString8& comnasc)
 | 
						|
{
 | 
						|
	comnasc = "";
 | 
						|
	datanasc = TDate(NULLDATE);
 | 
						|
	if (cf.not_empty())
 | 
						|
	{
 | 
						|
		comnasc = cf.sub(11,15);
 | 
						|
		int a = atoi(cf.sub(6,8));
 | 
						|
		a+=1900;
 | 
						|
		char mc = cf[8];
 | 
						|
		int m = 0;
 | 
						|
		switch (mc)
 | 
						|
		{
 | 
						|
			case 'A':	m = 1;	break;
 | 
						|
			case 'B':	m = 2;	break;
 | 
						|
			case 'C':	m = 3;	break;
 | 
						|
			case 'D':	m = 4;	break;
 | 
						|
			case 'E':	m = 5;	break;
 | 
						|
			case 'H':	m = 6;	break;
 | 
						|
			case 'L':	m = 7;	break;
 | 
						|
			case 'M':	m = 8;	break;
 | 
						|
			case 'P':	m = 9;	break;
 | 
						|
			case 'R':	m = 10;	break;
 | 
						|
			case 'S':	m = 11;	break;
 | 
						|
			case 'T':	m = 12;	break;
 | 
						|
			default: m = 0;		break;
 | 
						|
		}
 | 
						|
		int g = atoi(cf.sub(9,11));
 | 
						|
		if (g > 40)
 | 
						|
			g-=40;
 | 
						|
		if (g > 0 && m > 0 && a > 0)
 | 
						|
		{
 | 
						|
			datanasc.set_day(g);
 | 
						|
			datanasc.set_month(m);
 | 
						|
			datanasc.set_year(a);
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
bool TCoop_soci_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) 
 | 
						|
{
 | 
						|
  switch (o.dlg())
 | 
						|
  {                             
 | 
						|
  case F_COFISOCIO:
 | 
						|
    if (e == fe_modify || e == fe_init)
 | 
						|
    {
 | 
						|
      TMask& m = o.mask();
 | 
						|
			TString80 cf = m.get(F_COFISOCIO);
 | 
						|
			TDate datanasc;
 | 
						|
			TString8 comnasc;
 | 
						|
			calcola_dati_nascita(cf, datanasc, comnasc);
 | 
						|
			if (datanasc.ok())
 | 
						|
			{
 | 
						|
				m.set(F_DATANASC, datanasc);		
 | 
						|
				m.set(F_COMNASC, comnasc);
 | 
						|
			}
 | 
						|
    }
 | 
						|
    break;
 | 
						|
	case F_DATALIC:
 | 
						|
    if (e == fe_modify)
 | 
						|
    {
 | 
						|
      TMask& m = o.mask();
 | 
						|
			TString16 data = o.get();
 | 
						|
			
 | 
						|
			if (data.full())
 | 
						|
			{
 | 
						|
				TDate datalic(data);
 | 
						|
 | 
						|
				datalic.addyear(6);
 | 
						|
			  m.set(F_DATASCALIC, datalic);		
 | 
						|
			}
 | 
						|
			else
 | 
						|
			  m.reset(F_DATASCALIC);		
 | 
						|
    }
 | 
						|
		break;
 | 
						|
	case F_ANNO:
 | 
						|
    if (e == fe_init || e == fe_modify || e == fe_close)
 | 
						|
		{
 | 
						|
			TSheet_field & prog = sfield(F_PROGRESSIVI);
 | 
						|
 | 
						|
			prog.disable();
 | 
						|
		}
 | 
						|
    if (e == fe_init || e == fe_modify || e == fe_close)
 | 
						|
    {
 | 
						|
			const long codsocio = get_long(F_CODCF);
 | 
						|
			const int year = atoi(o.get());
 | 
						|
			TSheet_field & prog = sfield(F_PROGRESSIVI);
 | 
						|
			
 | 
						|
			if (prog.dirty())
 | 
						|
			{
 | 
						|
				if (yesno_box("I progressivi sono stati modificati, li salvo"))
 | 
						|
				{
 | 
						|
					TTable psc("PSC");
 | 
						|
					for (int month = 1; month <= 12; month++)
 | 
						|
					{
 | 
						|
						TToken_string & row = prog.row(month - 1);
 | 
						|
						psc.zero();
 | 
						|
						TString key;
 | 
						|
 | 
						|
						row.add(itom(month), prog.cid2index(F_MESE));
 | 
						|
						key.format("%06ld%04d%02d", codsocio, year, month);
 | 
						|
						psc.put("CODTAB", key);
 | 
						|
						if (psc.read(_isequal, _lock) == NOERR)
 | 
						|
						{
 | 
						|
							psc.put("R0", real(row.get(prog.cid2index(F_CONF))));
 | 
						|
							psc.put("R1", real(row.get(prog.cid2index(F_IVA))));
 | 
						|
							psc.put("R2", real(row.get(prog.cid2index(F_RIT))));
 | 
						|
							psc.put("R3", real(row.get(prog.cid2index(F_ACC8))));
 | 
						|
							psc.rewrite();
 | 
						|
						}
 | 
						|
						else
 | 
						|
						{
 | 
						|
							psc.unlock();
 | 
						|
							psc.zero();
 | 
						|
							psc.put("CODTAB", key);
 | 
						|
							psc.put("R0", row.get(prog.cid2index(F_CONF)));
 | 
						|
							psc.put("R1", row.get(prog.cid2index(F_IVA)));
 | 
						|
							psc.put("R2", row.get(prog.cid2index(F_RIT)));
 | 
						|
							psc.put("R3", row.get(prog.cid2index(F_ACC8)));
 | 
						|
							psc.write();
 | 
						|
						}
 | 
						|
					}
 | 
						|
				}
 | 
						|
			}
 | 
						|
			if (codsocio != 0L && year > 1900)
 | 
						|
			{
 | 
						|
				TTable psc("PSC");
 | 
						|
				real totconf;
 | 
						|
				real totiva;
 | 
						|
				real totrit;
 | 
						|
				real totacc8;
 | 
						|
				prog.destroy();
 | 
						|
 | 
						|
				for (int month = 1; month <= 12; month++)
 | 
						|
				{
 | 
						|
					TToken_string & row = prog.row(month - 1);
 | 
						|
					psc.zero();
 | 
						|
					TString key;
 | 
						|
 | 
						|
					row.add(itom(month), prog.cid2index(F_MESE));
 | 
						|
					key.format("%06ld%04d%02d", codsocio, year, month);
 | 
						|
					psc.put("CODTAB", key);
 | 
						|
					if (psc.read(_isequal) == NOERR)
 | 
						|
					{
 | 
						|
						const real conf = psc.get_real("R0");
 | 
						|
						const real iva = psc.get_real("R1");
 | 
						|
						const real rit = psc.get_real("R2");
 | 
						|
						const real acc8 = psc.get_real("R3");
 | 
						|
							
 | 
						|
						row.add(conf.string(18,2), prog.cid2index(F_CONF));
 | 
						|
						row.add(iva.string(18,2), prog.cid2index(F_IVA));
 | 
						|
						row.add(rit.string(18,2), prog.cid2index(F_RIT));
 | 
						|
						row.add(acc8.string(18,2), prog.cid2index(F_ACC8));
 | 
						|
						totconf += conf;
 | 
						|
						totiva += iva;
 | 
						|
						totrit += rit;
 | 
						|
						totacc8 += acc8;
 | 
						|
					}
 | 
						|
				}
 | 
						|
				
 | 
						|
				TToken_string & row = prog.row(12);
 | 
						|
					
 | 
						|
				row.add("Totali", prog.cid2index(F_MESE));
 | 
						|
				row.add(totconf.string(18,2), prog.cid2index(F_CONF));
 | 
						|
				row.add(totiva.string(18,2), prog.cid2index(F_IVA));
 | 
						|
				row.add(totrit.string(18,2), prog.cid2index(F_RIT));
 | 
						|
				row.add(totacc8.string(18,2), prog.cid2index(F_ACC8));
 | 
						|
				prog.force_update();
 | 
						|
				prog.disable_row(12);
 | 
						|
				prog.set_dirty(false);
 | 
						|
			}
 | 
						|
		}
 | 
						|
  }  
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
class TCoop_soci_application : public TRelation_application
 | 
						|
 | 
						|
{
 | 
						|
  TMask* _msk;
 | 
						|
  TRelation* _rel;
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual TMask* get_mask(int mode = MODE_QUERY) { CHECK(_msk, "Null mask"); return _msk; }
 | 
						|
  virtual bool changing_mask(int mode) { return false; }
 | 
						|
  virtual TRelation* get_relation() const {  CHECK(_rel, "Null relation"); return _rel; }
 | 
						|
 | 
						|
  virtual void init_query_mode(TMask& m);
 | 
						|
  virtual void init_query_insert_mode(TMask& m);
 | 
						|
  virtual void init_insert_mode(TMask& m);
 | 
						|
  virtual void init_modify_mode(TMask& m);
 | 
						|
 | 
						|
	void show_socio(TMask& m, const bool show = true);
 | 
						|
 
 | 
						|
	virtual bool user_create() ;
 | 
						|
  virtual bool user_destroy() ;
 | 
						|
  
 | 
						|
public:
 | 
						|
  TCoop_soci_application() : _msk(NULL), _rel(NULL) { }
 | 
						|
  virtual ~TCoop_soci_application() {}
 | 
						|
};
 | 
						|
 | 
						|
void TCoop_soci_application::show_socio(TMask& m, const bool show)
 | 
						|
{
 | 
						|
	  m.show(-1, show);
 | 
						|
		m.show(-2, !show);
 | 
						|
}
 | 
						|
void TCoop_soci_application::init_query_mode(TMask& m)
 | 
						|
{
 | 
						|
	show_socio(m);
 | 
						|
}
 | 
						|
 | 
						|
void TCoop_soci_application::init_query_insert_mode(TMask& m)
 | 
						|
{
 | 
						|
	show_socio(m, false);
 | 
						|
}
 | 
						|
 | 
						|
void TCoop_soci_application::init_insert_mode(TMask& m)
 | 
						|
{
 | 
						|
	show_socio(m);
 | 
						|
}
 | 
						|
 | 
						|
void TCoop_soci_application::init_modify_mode(TMask& m)
 | 
						|
{
 | 
						|
	show_socio(m);
 | 
						|
	m.check_fields();
 | 
						|
}
 | 
						|
 | 
						|
bool TCoop_soci_application::user_create()
 | 
						|
{
 | 
						|
	_rel = new TRelation(LF_SOCICOOP);
 | 
						|
  _msk = new TCoop_soci_msk; 
 | 
						|
  TString title;
 | 
						|
  _msk->get_caption(title);
 | 
						|
  set_title(title);
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
bool TCoop_soci_application::user_destroy() 
 | 
						|
{
 | 
						|
  if (_msk)
 | 
						|
		delete _msk;
 | 
						|
  if (_rel)
 | 
						|
		delete _rel;
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
int co0600(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TCoop_soci_application a;
 | 
						|
 | 
						|
  a.run(argc, argv, TR("Anagrafica soci"));
 | 
						|
  return 0;
 | 
						|
}
 | 
						|
 |