Files correlati : Ricompilazione Demo : [ ] Commento : Riportate le modifiche dalla versione 2.1 222 Si puo cominciare a fare il primo CD git-svn-id: svn://10.65.10.50/trunk@12708 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			174 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			174 lines
		
	
	
		
			5.9 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <automask.h>
 | 
						|
#include <diction.h>
 | 
						|
 | 
						|
#include "velib.h"
 | 
						|
#include "velib04e.h"
 | 
						|
 | 
						|
#include <doc.h>
 | 
						|
 | 
						|
 | 
						|
class TConsuntivazione_mask : public TAutomask
 | 
						|
{
 | 
						|
protected:
 | 
						|
  void load_sheet();
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
 | 
						|
public:
 | 
						|
  TConsuntivazione_mask() : TAutomask("velib04e") { }
 | 
						|
  virtual ~TConsuntivazione_mask() { }
 | 
						|
};
 | 
						|
 | 
						|
static bool scan_rilprod(const TRelation& rel, void* pJolly)
 | 
						|
{
 | 
						|
  const TRectype& rec = rel.curr();
 | 
						|
  TSheet_field& sheet = *(TSheet_field*)pJolly;
 | 
						|
  TToken_string& row = sheet.row(-1);
 | 
						|
  row.add(rec.get(RDOC_CODART),   sheet.cid2index(S_CODART));
 | 
						|
  row.add(rec.get("PROG"),        sheet.cid2index(S_PROG));
 | 
						|
  row.add(rec.get("DATAPROD"),    sheet.cid2index(S_DATAPROD));
 | 
						|
  row.add(rec.get("ORAPROD"),     sheet.cid2index(S_ORAPROD));
 | 
						|
  row.add(rec.get("DATAFINE"),    sheet.cid2index(S_DATAFINE));
 | 
						|
  row.add(rec.get("ORAFINE"),     sheet.cid2index(S_ORAFINE));
 | 
						|
  row.add(rec.get(RDOC_IMPIANTO), sheet.cid2index(S_IMPIANTO));
 | 
						|
  row.add(rec.get(RDOC_LINEA),    sheet.cid2index(S_LINEA));
 | 
						|
  row.add(rec.get(RDOC_QTA),      sheet.cid2index(S_QTA));
 | 
						|
  row.add(rec.get("CHIUSO"),      sheet.cid2index(S_CHIUSO));
 | 
						|
 | 
						|
  row.add(rec.get(RDOC_PROVV),    sheet.cid2index(S_PROVV));
 | 
						|
  row.add(rec.get(RDOC_ANNO),     sheet.cid2index(S_ANNO));
 | 
						|
  row.add(rec.get(RDOC_CODNUM),   sheet.cid2index(S_CODNUM));
 | 
						|
  row.add(rec.get(RDOC_NDOC),     sheet.cid2index(S_NDOC));
 | 
						|
  row.add(rec.get(RDOC_NRIGA),    sheet.cid2index(S_NRIGA));
 | 
						|
  return false;
 | 
						|
}
 | 
						|
 | 
						|
void TConsuntivazione_mask::load_sheet()
 | 
						|
{
 | 
						|
  TRelation rel(LF_RILPROD);
 | 
						|
  TCursor cur(&rel, "ANNOP=''", 5);
 | 
						|
 | 
						|
  TSheet_field& sheet = sfield(F_SHEET);
 | 
						|
  sheet.destroy();
 | 
						|
  cur.scan(scan_rilprod, &sheet);
 | 
						|
  sheet.force_update();
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
bool TConsuntivazione_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{
 | 
						|
  switch (o.dlg())
 | 
						|
  {
 | 
						|
  case F_SHEET:
 | 
						|
    if (e == fe_init)
 | 
						|
      load_sheet();
 | 
						|
    break;
 | 
						|
  default:
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
bool TConsuntivazione_produzione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
 | 
						|
                                          const TDate& data_elab, bool interattivo)
 | 
						|
{ 
 | 
						|
  TConsuntivazione_mask msk;
 | 
						|
  bool done = false;
 | 
						|
  while (msk.run() == K_ENTER)
 | 
						|
  {
 | 
						|
    TSheet_field& sheet = msk.sfield(F_SHEET);
 | 
						|
    TLocalisamfile rilevazioni(LF_RILPROD);
 | 
						|
    TRectype& ril = rilevazioni.curr();
 | 
						|
 | 
						|
    TDocumento& outdoc = doc_out[0];
 | 
						|
 | 
						|
    TDocumento ordine;
 | 
						|
 | 
						|
    FOR_EACH_SHEET_ROW(sheet, i, row) if (*row->get(0)=='X')  // Per ogni riga selezionata
 | 
						|
    {
 | 
						|
      const TString codart  = row->get(sheet.cid2index(S_CODART));
 | 
						|
      const TDate dataprod  = row->get(sheet.cid2index(S_DATAPROD));
 | 
						|
      const int prog        = row->get_int(sheet.cid2index(S_PROG));
 | 
						|
      const real qta        = row->get(sheet.cid2index(S_QTA));
 | 
						|
      bool chiuso           = row->get(sheet.cid2index(S_CHIUSO))[0] > ' ';
 | 
						|
      const char provv      = row->get(sheet.cid2index(S_PROVV))[0];
 | 
						|
      const int anno        = row->get_int(sheet.cid2index(S_ANNO));
 | 
						|
      const TString8 codnum = row->get(sheet.cid2index(S_CODNUM));
 | 
						|
      const long ndoc       = row->get_long(sheet.cid2index(S_NDOC));
 | 
						|
      const int nriga       = row->get_int(sheet.cid2index(S_NRIGA));
 | 
						|
 | 
						|
      int err = ordine.read(provv, anno, codnum, ndoc, _isequal, _testandlock);
 | 
						|
      if (err == NOERR)
 | 
						|
      {
 | 
						|
        if (nriga > 0 && nriga <= ordine.rows())
 | 
						|
        {
 | 
						|
          TRiga_documento& riga_ordine = ordine[nriga];
 | 
						|
          const TString& qta_fld = riga_ordine.field_qta();
 | 
						|
          const TString& qte_fld = riga_ordine.field_qtaevasa();
 | 
						|
 | 
						|
          const real qta_evasa = riga_ordine.qtaevasa() + qta;      
 | 
						|
          riga_ordine.put(qte_fld, qta_evasa);
 | 
						|
          if (chiuso || riga_ordine.qtaresidua().is_zero())
 | 
						|
          {
 | 
						|
            riga_ordine.put(RDOC_RIGAEVASA, 'X');
 | 
						|
            chiuso = true;
 | 
						|
          }
 | 
						|
 | 
						|
          const TString4 tiporiga = riga_ordine.get(RDOC_TIPORIGA);
 | 
						|
          TRiga_documento& outrec = outdoc.new_row(tiporiga);
 | 
						|
          TDocumento::copy_data(outrec, riga_ordine);
 | 
						|
          outrec.put(qta_fld, qta);
 | 
						|
          if (qta_fld != RDOC_QTA) 
 | 
						|
          {
 | 
						|
            const real q = riga_ordine.get_real(RDOC_QTA);
 | 
						|
            if (q.is_zero()) 
 | 
						|
              outrec.put(RDOC_QTA, UNO);             // Pezza temporanea
 | 
						|
          }
 | 
						|
          outrec.dirty_fields();                     // Forza ricalcolo peso etc. 
 | 
						|
          outrec.put(RDOC_DATACONS, dataprod);       // Setta la data di consegna con la data di produzione
 | 
						|
          outrec.zero(qte_fld);                      // Azzera quantita' evasa erroneamente copiata dall'ordine
 | 
						|
          outrec.zero(RDOC_RIGAEVASA);               // Azzera flag di evasa erroneamente copiata dall'ordine
 | 
						|
          outrec.set_original_rdoc_key(riga_ordine);
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
          err = _iskeynotfound;
 | 
						|
        }
 | 
						|
        err = ordine.rewrite();  // Unlocca
 | 
						|
      }
 | 
						|
      if (err != NOERR)
 | 
						|
      {
 | 
						|
        const char* msg = TR("Impossibile aggiornare il documento");
 | 
						|
        error_box("%s %d %s %ld", msg, anno, (const char*)codnum, ndoc);
 | 
						|
        break;
 | 
						|
      }
 | 
						|
 | 
						|
      ril.put("CODART",   codart);
 | 
						|
      ril.put("DATAPROD", dataprod);
 | 
						|
      ril.put("PROG",     prog);
 | 
						|
      err = rilevazioni.read(_isequal, _testandlock);
 | 
						|
      if (err == NOERR)
 | 
						|
      {
 | 
						|
        ril.put("QTA",      qta);
 | 
						|
        ril.put("CHIUSO",   chiuso);
 | 
						|
        ril.put("IMPIANTO", row->get(sheet.cid2index(S_IMPIANTO)));
 | 
						|
        ril.put("LINEA",    row->get(sheet.cid2index(S_LINEA)));
 | 
						|
        ril.put("PROVVP",   outdoc.get(DOC_PROVV));
 | 
						|
        ril.put("ANNOP",    outdoc.get(DOC_ANNO));
 | 
						|
        ril.put("CODNUMP",  outdoc.get(DOC_CODNUM));
 | 
						|
        ril.put("NDOCP",    outdoc.get(DOC_NDOC));
 | 
						|
        ril.put("NRIGAP",   outdoc.rows());
 | 
						|
        err = rilevazioni.rewrite();
 | 
						|
      }
 | 
						|
      if (err != NOERR)
 | 
						|
      {
 | 
						|
        const char* msg = TR("Impossibile aggiornare la riga di rilevazione");
 | 
						|
        error_box("%s %s %s %d", msg, (const char*)codart, (const char*)dataprod.string(), prog);
 | 
						|
        break;
 | 
						|
      }
 | 
						|
      else
 | 
						|
        done = true;
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  return done;
 | 
						|
} |