Patch level : 10.0 nopatch

Files correlati     : pc0001.exe
Ricompilazione Demo : [ ]
Commento           :

Gestione Commesse GAM


git-svn-id: svn://10.65.10.50/trunk@17024 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2008-08-06 22:35:14 +00:00
parent 80d1dfcd68
commit 539886a225
4 changed files with 451 additions and 0 deletions

15
ps/pc0001.cpp Executable file
View File

@ -0,0 +1,15 @@
#include <xvt.h>
#include "pc0001.h"
int main(int argc, char** argv)
{
const int n = argc > 1 ? argv[1][1]-'0' : 0;
switch (n)
{
case 0:
default:
pc0001100(argc, argv); // Commesse
break;
}
return 0;
}

1
ps/pc0001.h Executable file
View File

@ -0,0 +1 @@
int pc0001100(int argc, char* argv[]);

259
ps/pc0001100.cpp Executable file
View File

@ -0,0 +1,259 @@
#include "../ve/velib.h"
#include "../ve/sconti.h"
#include "../mg/mglib.h"
#include "../ve/vepriv.h"
#include "../ve/veuml.h"
#include <automask.h>
#include <defmask.h>
#include <execp.h>
#include <agasys.h>
#include <tabutil.h>
#include <utility.h>
#include "../mg/anamag.h"
#include "../ve/ve0100.h"
#include "../ve/veini.h"
#include "../ve/veuml.h"
#include "../ve/veuml1.h"
#include "../ve/verig.h"
#include <clifo.h>
#include "pc0001.h"
class TCommesse_mask : public TDocumento_mask
{
TBit_array _modified_rows;
TBit_array _deleted_rows;
int _last_row;
protected:
static bool cc_notify(TSheet_field& ss, int r, KEY key);
public:
TBit_array & modified_rows() { return _modified_rows;}
TBit_array & deleted_rows() {return _deleted_rows;}
void reset_last_row() { _last_row = -1;}
void set_last_row(int r) { _last_row = r;}
int last_row() const { return _last_row;}
bool modified(long idriga) const{ return _modified_rows[(int)idriga];}
bool deleted(long idriga) const {return _deleted_rows[(int)idriga];}
TCommesse_mask(const char* tipodoc);
virtual ~TCommesse_mask() {}
};
bool TCommesse_mask::cc_notify( TSheet_field& ss, int r, KEY key )
{
TCommesse_mask& m = (TCommesse_mask&)ss.mask();
TDocumento& doc = m.doc();
if ( key == K_ENTER )
{
TRiga_documento& riga = doc[r + 1];
const long idriga = riga.get_long(RDOC_IDRIGA);
m.modified_rows().set(idriga);
}
else
if ( key == K_TAB && m.is_running() && m.last_row() != r)
{
m.set_last_row(r);
TRiga_documento& riga = doc[r + 1];
const long idriga = riga.get_long(RDOC_IDRIGA);
if (!m.modified(idriga))
{
TToken_string key;
key.add(riga.get(RDOC_CODNUM));
key.add(riga.get(RDOC_ANNO));
key.add(riga.get(RDOC_PROVV));
key.add(riga.get(RDOC_NDOC));
for (int i = 1; ; i++)
{
key.add(i, 4);
const TRectype& rec = cache().get(LF_RIGHEDOC, key);
if (rec.empty()) break;
if (rec.get_long(RDOC_IDRIGA) == idriga)
{
TDocumento::copy_data(riga, rec);
riga.autoload(ss);
ss.check_row(r, 0x2);
ss.force_update(r);
break;
}
}
}
}
else
if ( key == K_DEL ) // Cancellazione
{
TRiga_documento& riga = doc[r + 1];
const long idriga = riga.get_long(RDOC_IDRIGA);
m.deleted_rows().set(idriga);
m.modified_rows().set(idriga, false);
}
else
if (key == K_CTRL + K_INS)
{
doc.set_row_ids();
TRiga_documento & riga = doc[r + 1];
const long idriga = riga.get_long(RDOC_IDRIGA);
m.modified_rows().set(idriga);
}
return TDocumento_mask::ss_notify(ss, r,key);
}
TCommesse_mask::TCommesse_mask(const char* tipodoc):
TDocumento_mask(tipodoc), _last_row(-1)
{
sfield(F_SHEET).set_notify( cc_notify );
}
// Definizione della classe dell'applicazione motore
class TCommesse_application : public TMotore_application
{
TAssoc_array _masks; // assoc_array delle maschere da utilizzare
TString4 _tipodoc;
TBit_array _modified;
protected:
virtual TMask* get_mask( int mode );
virtual int read( TMask& m );
virtual int rewrite( const TMask& m );
public:
virtual TMask & query_mask();
virtual TDocumento_mask & edit_mask() const;
TCommesse_application() {}
};
inline TCommesse_application& pcapp() { return (TCommesse_application &) main_app(); };
TMask& TCommesse_application::query_mask()
{
TMask* m = (TMask*) _masks.objptr("pc0001100a");
if (m == NULL)
{
m = new TMask("pc0001100a");
_masks.add("pc0001100a", m);
}
return *m;
}
TDocumento_mask& TCommesse_application::edit_mask() const
{
TDocumento_mask* m = (TDocumento_mask*) _masks.objptr(_tipodoc);
if (m == NULL)
{
m = new TCommesse_mask(_tipodoc);
((TAssoc_array&)_masks).add(_tipodoc, m);
}
return *m;
}
TMask* TCommesse_application::get_mask( int mode )
{
TMask* m = NULL;
if (mode == MODE_MOD || mode == MODE_INS)
{
_tipodoc = query_mask().get(F_TIPODOC);
m = &edit_mask();
}
else
m = &query_mask();
return m;
}
// maschera di ricerca
// maschera di edit
int TCommesse_application::read(TMask& m )
{
TCommesse_mask & mask = (TCommesse_mask &) m;
mask.modified_rows().reset();
mask.deleted_rows().reset();
mask.reset_last_row();
const int err = TMotore_application::read(m);
if (err == NOERR)
((TDocumento_mask &) m).doc().read(_isequal, _unlock);
return err;
}
int TCommesse_application::rewrite( const TMask& m )
{
int err = NOERR;
const TCommesse_mask & mask = (const TCommesse_mask &) m;
const TDocumento & maskdoc = mask.doc();
TDocumento outdoc = maskdoc;
while ((err = outdoc.read(_isequal, _testandlock)) == _islocked)
xvt_sys_sleep (500);
if (err == NOERR)
{
for (int p = mask.fields()-1; p >= 0; p--)
{
TMask_field& f = mask.fld(p);
const TFieldref* fr = f.field();
if (fr != NULL)
fr->write(f.get(), outdoc);
}
int outrows = outdoc.physical_rows();
for (int j = outrows; j > 1; j--)
{
TRiga_documento & outrow = outdoc[j];
const long idriga = outrow.get_long(RDOC_IDRIGA);
if (mask.deleted(idriga))
outdoc.destroy_row(j, true);
}
outrows = outdoc.physical_rows();
const int rows = maskdoc.physical_rows();
for (int i = 1; i <= rows; i++)
{
const TRiga_documento & row = maskdoc[i];
const long idriga = row.get_long(RDOC_IDRIGA);
if (mask.modified(idriga))
{
bool newrow = true;
for (int j = 1; newrow && j <= outrows; j++)
{
TRiga_documento & outrow = outdoc[j];
if (idriga == outrow.get_int(RDOC_IDRIGA))
{
TDocumento::copy_data(outrow, row);
newrow = false;
}
}
if (newrow)
{
outdoc.insert_row(i);
TRiga_documento & outrow = outdoc[i];
TDocumento::copy_data(outrow, row);
}
}
}
err = outdoc.rewrite();
}
return err;
}
int pc0001100( int argc, char* argv[])
{
TCommesse_application a;
a.run( argc, argv, TR("Commesse GAM"));
return 0;
}

176
ps/pc0001100a.uml Executable file
View File

@ -0,0 +1,176 @@
#include "..\ve\veuml.h"
TOOLBAR "" 0 -2 0 2
#include "toolbar.h"
ENDPAGE
PAGE "Estremi del documento" 1 1 60 14
GROUPBOX DLG_NULL 78 3
BEGIN
PROMPT 1 1 "@bDitta"
END
NUMBER F_CODDITTA 5
BEGIN
PROMPT 3 2 "Codice "
FLAGS "FD"
USE LF_NDITTE
CHECKTYPE NORMAL
INPUT CODDITTA F_CODDITTA
OUTPUT F_RAGSOCDITTA RAGSOC
END
STRING F_RAGSOCDITTA 50
BEGIN
PROMPT 17 2 "Ragione "
FLAGS "D"
END
GROUPBOX DLG_NULL 78 7
BEGIN
PROMPT 1 4 "Estremi del documento"
END
LISTBOX F_PROVV 14
BEGIN
FIELD PROVV
PROMPT 46 7 "Tipo "
ITEM "D|Definitiva "
ITEM "P|Provvisoria"
KEY 1 2
FLAGS "DPG"
END
LISTBOX F_CODNUM 4
BEGIN
PROMPT 2 5 "Numerazione "
FIELD CODNUM
ITEM "COM|COM"
HELP "Codice numerazione"
FLAG "D"
WARNING "Numerazione assente"
KEY 1 2
END
LISTBOX F_DESNUM 50
BEGIN
PROMPT 24 5 ""
ITEM "COM|Commesse"
HELP "Descrizione numerazione"
FLAGS "D"
END
LISTBOX F_TIPODOC 4
BEGIN
PROMPT 2 6 "Tipo "
FIELD TIPODOC
ITEM "COM|COM"
HELP "Codice tipo documento"
FLAG "D"
END
LISTBOX F_DESTIPODOC 50
BEGIN
PROMPT 24 6 ""
ITEM "COM|Commessa"
HELP "Descrizione tipo documento"
FLAGS "D"
END
NUMBER F_ANNO 4
BEGIN
PROMPT 2 7 "Esercizio "
FIELD ANNO
CHECKTYPE REQUIRED
NUM_EXPR #F_ANNO>0
FLAG "AP"
KEY 1 2
WARNING "Inserire un anno valido"
END
NUMBER F_NDOC 6
BEGIN
PROMPT 24 7 "Numero "
FIELD NDOC
USE LF_DOC
JOIN LF_CLIFO TO LF_DOC INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT PROVV F_PROVV SELECT
INPUT ANNO F_ANNO SELECT
INPUT CODNUM F_CODNUM SELECT
INPUT NDOC F_NDOC
DISPLAY "Num." CODNUM
DISPLAY "Anno" ANNO
DISPLAY "Provv" PROVV
DISPLAY "Tipo" TIPODOC
DISPLAY "N.Doc. " NDOC
DISPLAY "Stato@R" STATO
DISPLAY "Data\ndocumento" DATADOC
DISPLAY "C/F" TIPOCF
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" LF_CLIFO->RAGSOC
OUTPUT F_NDOC NDOC
OUTPUT F_STATO STATO
OUTPUT F_TIPODOC TIPODOC
OUTPUT F_PROVV PROVV
CHECKTYPE REQUIRED
KEY 1 2
FLAG "R"
END
STRING F_STATO 1
BEGIN
PROMPT 69 7 "Stato "
FIELD STATO
FLAG "D"
END
LIST F_TIPOCF 1 12
BEGIN
PROMPT 2 8 "Tipo "
ITEM "C|Cliente"
ITEM "F|Fornitore"
KEY 2
END
NUMBER F_CODCF 6
BEGIN
PROMPT 24 8 "Codice "
USE LF_DOC KEY 2 SELECT (CODNUM==#F_CODNUM) && (PROVV==#F_PROVV) && (ANNO==#F_ANNO)
JOIN LF_CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF
INPUT TIPOCF F_TIPOCF SELECT
INPUT CODCF F_CODCF
INPUT PROVV F_PROVV
INPUT ANNO F_ANNO
DISPLAY "Codice" CODCF
DISPLAY "Ragione Sociale@50" LF_CLIFO->RAGSOC
DISPLAY "Partita IVA@12" LF_CLIFO->PAIV
DISPLAY "Num." CODNUM
DISPLAY "Anno" ANNO
DISPLAY "Provv" PROVV
DISPLAY "Tipo" TIPODOC
DISPLAY "N.Doc. " NDOC
DISPLAY "Data\ndocumento" DATADOC
DISPLAY "Valuta" CODVAL
DISPLAY "Totale\ndocumento@18V" G1:TOTDOC
COPY OUTPUT F_NDOC
OUTPUT F_CODCF CODCF
CHECKTYPE NORMAL
KEY 2
END
STRING F_NUMDOCRIF 7
BEGIN
PROMPT 46 8 "Riferimento "
FLAGS "B"
END
STRING F_RAGSOCSEARCH 50
BEGIN
PROMPT 2 9 "Ragione Sociale "
FLAGS "B"
END
ENDPAGE
ENDMASK