which included commits to RCS files with non-trunk default branches. git-svn-id: svn://10.65.10.50/trunk@1681 c028cbd2-c16b-5b4b-a496-9718f37d4682
258 lines
5.9 KiB
C++
Executable File
258 lines
5.9 KiB
C++
Executable File
#include "ve2400.h"
|
|
|
|
#define LF_ANAMAG 47
|
|
#define LF_CODCORR 48
|
|
#define LF_DESLIN 51
|
|
|
|
|
|
|
|
#ifndef __CHECKS_H
|
|
#include <checks.h>
|
|
#endif
|
|
|
|
#ifndef __RELAPP_H
|
|
#include <relapp.h>
|
|
#endif
|
|
|
|
#ifndef __MSKSHEET_H
|
|
#include <msksheet.h>
|
|
#endif
|
|
|
|
#ifndef __LFFILES_H
|
|
#include <lffiles.h>
|
|
#endif
|
|
|
|
#define F_SHEET1 300
|
|
#define F_SHEET2 301
|
|
|
|
|
|
class TAnamag_application : public TRelation_application
|
|
{
|
|
TMask* _msk;
|
|
TRelation* _rel;
|
|
|
|
TRecord_array * _linee_rec1;
|
|
TSheet_field * _sheet1;
|
|
|
|
TRecord_array * _linee_rec2;
|
|
TSheet_field * _sheet2;
|
|
|
|
|
|
virtual int read(TMask& m);
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual TMask* get_mask(int mode) { return _msk;}
|
|
virtual bool changing_mask(int mode) { return FALSE;}
|
|
virtual TRelation* get_relation() const { return _rel;}
|
|
TSheet_field& ss() const { return *_sheet1; }
|
|
|
|
|
|
virtual int write(const TMask& m);
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
|
|
|
|
public:
|
|
|
|
TAnamag_application( ) { };
|
|
virtual ~TAnamag_application() { }
|
|
};
|
|
|
|
bool TAnamag_application::user_create()
|
|
{
|
|
_msk = new TMask( "VE2400" );
|
|
_sheet1 = &(TSheet_field &)_msk->field( F_SHEET1 );
|
|
_sheet2 = &(TSheet_field &)_msk->field( F_SHEET2 );
|
|
|
|
_rel = new TRelation( LF_ANAMAG );
|
|
_linee_rec1 = new TRecord_array( LF_DESLIN, "NRIGA", 1 );
|
|
_rel->add( LF_DESLIN, "CODART=CODART" );
|
|
|
|
_linee_rec2 = new TRecord_array( LF_CODCORR, "NRIGA", 1 );
|
|
_rel->add( LF_CODCORR, "CODART=CODART" );
|
|
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TAnamag_application::user_destroy()
|
|
{
|
|
delete _msk;
|
|
delete _rel;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
int TAnamag_application::read(TMask& m)
|
|
{
|
|
int err = TRelation_application::read( m );
|
|
if ( err == NOERR )
|
|
{
|
|
// message_box( "Entrato nel ciclo di caricamento delle righe!" );
|
|
TLocalisamfile& rdoc = _rel->lfile(LF_DESLIN);
|
|
TRectype r(rdoc.curr());
|
|
r.zero();
|
|
r.put( "CODART", m.get( F_CODART ) );
|
|
_linee_rec1->read( r );
|
|
|
|
TSheet_field& f = (TSheet_field&) m.field( F_SHEET1 );
|
|
f.destroy();
|
|
int last = _linee_rec1->last_row();
|
|
for( int i = 1; i <= last; i ++ )
|
|
{ TRectype &rec = _linee_rec1->row( i, TRUE );
|
|
TToken_string& row = f.row( i -1 );
|
|
row = rec.get("CODLIN");
|
|
row.add( rec.get("DESCR") );
|
|
}
|
|
|
|
TLocalisamfile& rdoccor = _rel->lfile(LF_CODCORR);
|
|
TRectype rcor(rdoccor.curr());
|
|
rcor.zero();
|
|
rcor.put( "CODART", m.get( F_CODART ) );
|
|
_linee_rec2->read( rcor );
|
|
|
|
TSheet_field& fcorr = (TSheet_field&) m.field( F_SHEET2 );
|
|
fcorr.destroy();
|
|
last = _linee_rec2->last_row();
|
|
for( i = 1; i <= last; i ++ )
|
|
{ TRectype &rec = _linee_rec2->row( i, TRUE );
|
|
TToken_string& row = f.row( i -1 );
|
|
row = rec.get("CODARTALT");
|
|
row.add( rec.get("TIPO") );
|
|
|
|
}
|
|
}
|
|
return err;
|
|
}
|
|
|
|
int TAnamag_application::write(const TMask& m)
|
|
{
|
|
int err = TRelation_application::write(m);
|
|
if (err == NOERR)
|
|
{
|
|
TSheet_field& f = (TSheet_field&) m.field( F_SHEET1 );
|
|
_linee_rec1->destroy_rows();
|
|
|
|
if (m.insert_mode())
|
|
_linee_rec1->renum_key("CODART", m.get(F_CODART));
|
|
|
|
|
|
for (int i = 0; i < f.items(); i++)
|
|
{
|
|
TToken_string & row = f.row(i);
|
|
const TString16 codlin(row.get(0));
|
|
const TString80 descr(row.get());
|
|
|
|
if (codlin.not_empty() || descr.not_empty() )
|
|
{
|
|
TRectype & rec = _linee_rec1->row( i+1 , TRUE);
|
|
|
|
rec.put("CODLIN", codlin);
|
|
rec.put("DESCR", descr);
|
|
}
|
|
}
|
|
err = _linee_rec1->write();
|
|
}
|
|
|
|
if (err == NOERR)
|
|
{
|
|
TSheet_field& f = (TSheet_field&) m.field( F_SHEET2 );
|
|
_linee_rec2->destroy_rows();
|
|
|
|
if (m.insert_mode())
|
|
_linee_rec2->renum_key("CODART", m.get(F_CODART));
|
|
|
|
|
|
for (int i = 0; i < f.items(); i++)
|
|
{
|
|
TToken_string & row = f.row(i);
|
|
const TString80 codartalt(row.get(0));
|
|
const TString16 tipo(row.get());
|
|
|
|
if (codartalt.not_empty() || tipo.not_empty() )
|
|
{
|
|
TRectype & reccor = _linee_rec2->row( i+1 , TRUE);
|
|
|
|
reccor.put("CODARTALT", codartalt);
|
|
reccor.put("TIPO", tipo);
|
|
}
|
|
}
|
|
err = _linee_rec2->write();
|
|
}
|
|
|
|
|
|
|
|
|
|
return err;
|
|
}
|
|
|
|
int TAnamag_application::rewrite(const TMask& m)
|
|
{
|
|
int err = TRelation_application::rewrite(m);
|
|
if (err == NOERR)
|
|
{
|
|
TSheet_field& f = (TSheet_field&) m.field( F_SHEET1 );
|
|
_linee_rec1->destroy_rows();
|
|
|
|
if (m.insert_mode())
|
|
_linee_rec1->renum_key("CODART", m.get(F_CODART));
|
|
|
|
|
|
for (int i = 0; i < f.items(); i++)
|
|
{
|
|
TToken_string & row = f.row(i);
|
|
const TString16 codlin(row.get(0));
|
|
const TString80 descr(row.get());
|
|
|
|
if (codlin.not_empty() || descr.not_empty() )
|
|
{
|
|
TRectype & rec = _linee_rec1->row( i+1 , TRUE);
|
|
|
|
rec.put("CODLIN", codlin);
|
|
rec.put("DESCR", descr);
|
|
}
|
|
}
|
|
err = _linee_rec1->rewrite();
|
|
}
|
|
|
|
if (err == NOERR)
|
|
{
|
|
TSheet_field& f = (TSheet_field&) m.field( F_SHEET2 );
|
|
_linee_rec2->destroy_rows();
|
|
|
|
if (m.insert_mode())
|
|
_linee_rec2->renum_key("CODART", m.get(F_CODART));
|
|
|
|
|
|
for (int i = 0; i < f.items(); i++)
|
|
{
|
|
TToken_string & row = f.row(i);
|
|
const TString80 codartalt(row.get(0));
|
|
const TString80 tipo(row.get());
|
|
|
|
if (codartalt.not_empty() || tipo.not_empty() )
|
|
{
|
|
TRectype & reccor = _linee_rec2->row( i+1 , TRUE);
|
|
|
|
reccor.put("CODARTALT", codartalt);
|
|
reccor.put("TIPO", tipo);
|
|
}
|
|
}
|
|
err = _linee_rec2->write();
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
|
|
TAnamag_application a;
|
|
|
|
a.run(argc, argv, "Anagrafica di magazzino " );
|
|
return 0;
|
|
}
|