Files correlati : tp0.exe Commento : Aggiunte query personalizzabili per cliente al trasferimento Pack. Interno: Bisogna definire nel paragrafo tp di ditta.ini o studio.ini una variabile tra le seguenti : query personalizzabili archivio variabile standard CLIENTI/AGENTI Qtp0100Clienti "SELECT Customers_Suppliers.*, Unit_Measure.UMDesc FROM Customers_Suppliers LEFT JOIN Unit_Measure ON (CurrencyCode = Unit_Measure.UMCode AND Unit_Measure.UMType='9') " WHERE (StatusFlag=1 OR StatusFlag=2 OR StatusFlag=3) AND " dietro viene messa una condizione per clienti o agenti ARTICOLI Qtp0100Articoli "SELECT Paper_Composition_Group.CompDesc FROM Mag_Existing_Article, Articles_Composition, Paper_Composition_Group WHERE (Mag_Existing_Article.ArtCode='" << key << "') AND (Mag_Existing_Article.ArticleCode=Articles_composition.ArticleCode) AND (Mag_Existing_Article.VariantCode=Articles_composition.VariantCode) AND (Articles_Composition.CompCode=Paper_Composition_Group.CompCode);" INFORMAZIONI AGGIUNTIVE ARTICOLI Qtp0100Extra_info_articoli "SELECT Mag_Existing_Article.ArticleCustCode, Mag_Existing_Article.ArticleCode FROM Mag_Existing_Article WHERE Mag_Existing_Article.ArtCode='" << key << "';" CONAI Qtp0100Conai "SELECT SubclassCode,Weight FROM Articles_environmentTax WHERE Articles_environmentTax.ArticleCode=" dietro viene messo il codice articolo IVA Qtp0100IVA "SELECT * FROM IVA WHERE IVACode=#CODIVA;" Composizione imballi Qtp0100OrderPaperComp "SELECT Paper_Composition_Group.CompDesc FROM CDoc_Rows, Paper_Composition_Group WHERE (CDoc_Rows.DocNumber=#NDOC) AND (CDoc_Rows.RowNumber=#NROW) AND (CDoc_Rows.CompCode=Paper_Composition_Group.CompCode);"; #NROW deve essere lasciato così BOLLE Qtp010Bolle "SELECT DISTINCT PDdT_Header.DocCode, PDdT_Header.StoreDocType, PDdT_Header.DocRefNumber,PDdT_Header.DocDate, Store_Year.SyReferenceYear, PDdT_Header.CustSuppCode, Customers_Suppliers.FlagCustSupp, Customers_Suppliers.CodContab, Customers_Suppliers.CategoryCode, Customers_Suppliers.ZoneCode,Customers_Suppliers_1.CodContab AS AgentCode, PDdT_Header.Change, CAMPOCurrencies.UMDesc AS Currency,PDdT_Header.PaymentCode, PDdT_Header.ApplyEnvTax, PDdT_Header.DiscountOnPayment, CausaliTrasporto.Code AS CodTrasporto, Porto.Code AS CodResa, CausaliTrasporto.Description1 AS TipoTrasporto,Porto.Description1 AS TipoResa, PDdT_Header.Appearance, PDdT_Header.GrossWeight, PDdT_Header.NetWeight, PDdT_Header.ShiverNumber, (select case when PDdT_Header.BankDesc is null Or [PDdT_Header].[BankDesc]<>''then PDdT_Header.BankDesc else customers_suppliers.bankname end) AS BankDesc, PDdT_Header.CodIvaNI, Customers_Suppliers_2.CustSuppCode AS DestCode, Customers_Suppliers_2.FlagCustSupp AS FlagDestCode, Customers_Suppliers_2.CodContab AS DestCodContab,Customers_Suppliers_2.TradeName1, Customers_Suppliers_2.Address, Customers_Suppliers_2.Locality, Customers_Suppliers_2.ZipCode, Customers_Suppliers_2.Region, PDdT_Row.DocRow, PDdT_Row.ArtCode,PDdT_Row.ArtDesc, PDdT_Row.CDocNumber, PDdT_Row.CDocRow,CDoc_Rows.CustReference AS RowCustReference, CDoc_Header.CustReference, PDdT_Row.Provv, PDdT_Row.DiscountRowDesc, CDoc_Header.DocDate AS OrderDate,PDdT_Row.Quantity, Unit_Measure.UMDesc, PDdT_Row.Quantity1, Unit_Measure_1.UMDesc AS UMDesc1,PDdT_Row.Quantity2, Unit_Measure_2.UMDesc AS UMDesc2, PDdT_Row.AdvanceSale, PDdT_Row.Price, PDdT_Row.DefPrice, PDdT_Row.PriceNet, PDdT_Row.PriceNetDef, PDdT_Row.AmountNet, PDdT_Row.AmountNetDef,PDdT_Row.Amount, PDdT_Row.AmountDef, PDdT_Row.FlagUMPrice, IVA.IVACode, PDdT_Row.AccountCode, " PDdT_Row.AccountSubCode, PDdT_Row.WeightETUnit, PDdT_Row.ClassCode, PDdT_Row.SubclassCode,PDdT_Row.DDTRowType, PDdT_Header.StatusFlag, PDdT_Row.Report, PDdT_Row.FamilyCode, Mag_Existing_Article.ArtType, Mag_Existing_Article.Height, Mag_Existing_Article.Width, Mag_Existing_Article.Lenght,(select case when [Modalità Fornitura Bancali].[Value1] is null then 1 else [Modalità Fornitura Bancali].[Value1] end) AS FornituraBancali, PDdT_Header.InvoicingType, PDdT_Header.DocProvv, PDdT_Header.ReceiptBook FROM ((((((PDdT_Header LEFT JOIN Customers_Suppliers ON PDdT_Header.CustSuppCode = Customers_Suppliers.CustSuppCode) LEFT JOIN Unit_Measure AS CAMPOCurrencies ON (CAMPOCurrencies.UMcode=PDdT_Header.CurrencyCode AND CAMPOCurrencies.UMType='9') LEFT JOIN Customers_Suppliers AS Customers_Suppliers_1 ON PDdT_Header.AgentCode = Customers_Suppliers_1.CustSuppCode) LEFT JOIN Porto ON PDdT_Header.PortCode = Porto.Code) " LEFT JOIN Store_Year ON PDdT_Header.DocYear = Store_Year.SyCode) " LEFT JOIN Customers_Suppliers AS Customers_Suppliers_2 ON PDdT_Header.DestCode = Customers_Suppliers_2.CustSuppCode) " LEFT JOIN CausaliTrasporto ON PDdT_Header.DocCausalCode = CausaliTrasporto.Code) RIGHT JOIN (Mag_Existing_Article RIGHT JOIN ((CDoc_Header RIGHT JOIN (((IVA RIGHT JOIN (((CDoc_Rows RIGHT JOIN PDdT_Row ON (CDoc_Rows.DocNumber = PDdT_Row.CDocNumber)AND (CDoc_Rows.RowNumber = PDdT_Row.CDocRow)) LEFT JOIN Unit_Measure ON PDdT_Row.UMQty = Unit_Measure.UMCode) LEFT JOIN [Modalità Fornitura Bancali] ON PDdT_Row.DeliveryPalletType = [Modalità Fornitura Bancali].Code)ON IVA.IVACode = PDdT_Row.IVACode) LEFT JOIN Unit_Measure AS Unit_Measure_1 ON PDdT_Row.UMQta1 = Unit_Measure_1.UMCode) LEFT JOIN Unit_Measure AS Unit_Measure_2 ON PDdT_Row.UMQta2 = Unit_Measure_2.UMCode)ON CDoc_Header.DocNumber = CDoc_Rows.DocNumber) LEFT JOIN CDoc_Rows_Detail ON (CDoc_Rows.RowNumber = CDoc_Rows_Detail.RowNumber) AND (CDoc_Rows.DocNumber = CDoc_Rows_Detail.DocNumber))ON Mag_Existing_Article.ArtCode = PDdT_Row.ArtCode) ON PDdT_Header.DocCode = PDdT_Row.DocCode WHERE (((PDdT_Row.DDTRowType)='0' Or (PDdT_Row.DDTRowType)='2') AND ((PDdT_Header.StatusFlag)='1' OR (PDdT_Header.StatusFlag)='2' Or (PDdT_Header.StatusFlag)='3') AND ((select case when [Modalità Fornitura Bancali].[Value1] is null then 1 else [Modalità Fornitura Bancali].[Value1] end)=1) AND ((PDdT_Header.InvoicingType) Is Not Null) AND ((PDdT_Header.DocProvv)<>-1)) ORDER BY PDdT_Header.DocRefNumber, PDdT_Row.DocRow;"
206 lines
7.9 KiB
C++
Executable File
206 lines
7.9 KiB
C++
Executable File
#ifndef __RECORDSET_H
|
|
#define __RECORDSET_H
|
|
|
|
#ifndef XVT_INCL_XVT
|
|
#include <xvt.h>
|
|
#endif
|
|
|
|
#ifndef __RELATION_H
|
|
#include <relation.h>
|
|
#endif
|
|
|
|
#ifndef __VARIANT_H
|
|
#include <variant.h>
|
|
#endif
|
|
|
|
struct TRecordset_column_info : public TObject
|
|
{
|
|
TString _name; // Table.Column
|
|
int _width, _pos;
|
|
TFieldtypes _type;
|
|
|
|
void copy(const TRecordset_column_info & i) { _name = i._name; _width = i._width; _pos = i._pos; _type = i._type; }
|
|
virtual TObject* dup() const { return new TRecordset_column_info(*this); }
|
|
|
|
TRecordset_column_info(const TRecordset_column_info & i) {copy(i);}
|
|
TRecordset_column_info() : _width(0), _pos(0), _type(_alfafld) {}
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TAttributes
|
|
///////////////////////////////////////////////////////////
|
|
|
|
struct TAttributes : public TObject
|
|
{
|
|
XVT_FNTID _font;
|
|
COLOR _back;
|
|
COLOR _fore;
|
|
|
|
public:
|
|
XVT_FNTID get_font() const{ return _font; }
|
|
COLOR get_background() const { return _back; }
|
|
COLOR get_foreground() const { return _fore; }
|
|
void set_font(XVT_FNTID font) { _font = font; }
|
|
void set_background(COLOR back) { _back = back; }
|
|
void set_foreground(COLOR fore) { _fore = fore; }
|
|
|
|
TAttributes() : _font(NULL), _back(COLOR_INVALID), _fore(COLOR_INVALID) {}
|
|
virtual ~TAttributes() {}
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRecordset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_campo, fmt_dbf, fmt_as400, fmt_csv };
|
|
|
|
const TString & get_custom_query(const char * module, const char * query_var, TString & query);
|
|
|
|
class TRecordset : public TObject
|
|
{
|
|
TAssoc_array _var;
|
|
TString_array _varnames;
|
|
const TRecordset* _parentset;
|
|
char _text_separator;
|
|
bool _disable_variables;
|
|
bool _frozen;
|
|
|
|
protected:
|
|
virtual bool save_as_html(const char* path);
|
|
virtual bool save_as_text(const char* path);
|
|
virtual bool save_as_as400(const char* path) { set_text_separator(' '); return save_as_text(path);}
|
|
virtual bool save_as_csv(const char* path) { set_text_separator(';'); return save_as_text(path);}
|
|
virtual bool save_as_campo(const char* path);
|
|
virtual bool save_as_dbf(const char* table, int mode);
|
|
|
|
void find_and_reset_vars();
|
|
void parsed_text(TString& sql) const;
|
|
//TVariant& get_tmp_var() const;
|
|
bool export_dbf(int logicnum);
|
|
|
|
public: // Absolutely needed methods
|
|
virtual TRecnotype items() const pure;
|
|
virtual bool move_to(TRecnotype pos) pure;
|
|
virtual TRecnotype current_row() const pure;
|
|
virtual void requery() pure;
|
|
bool empty() const { return items() == 0; }
|
|
virtual const TString& query_text() const pure;
|
|
virtual const TString& driver_version() const;
|
|
|
|
virtual char text_separator() const { return _text_separator;}
|
|
virtual void set_text_separator(char sep) { _text_separator = sep;}
|
|
|
|
virtual void freeze(bool on = true) { _frozen = on; }
|
|
virtual void unfreeze() { freeze(false); }
|
|
virtual bool frozen() const { return _frozen; }
|
|
virtual bool not_frozen() const { return !_frozen; }
|
|
|
|
virtual bool move_first() { return move_to(0); }
|
|
virtual bool move_prev() { return move_to(current_row()-1); }
|
|
virtual bool move_next() { return move_to(current_row()+1); }
|
|
virtual bool move_last() { return move_to(items()-1); }
|
|
virtual bool bof() const { return current_row() == TRecnotype(-1); }
|
|
virtual bool eof() const { return current_row() >= items(); }
|
|
|
|
virtual unsigned int columns() const pure;
|
|
virtual const TRecordset_column_info& column_info(unsigned int column) const pure;
|
|
virtual const TRecordset_column_info& add_column_info(const TRecordset_column_info& c) {return c; }
|
|
const TString& get_string(const char* field) const { return get(find_column(field)).as_string(); };
|
|
const TString& get_string_zerofilled(const char* field, const int zero_filled) const;
|
|
int get_int(const char* field) const { return get(find_column(field)).as_int(); }
|
|
long get_long(const char* field) const { return get(find_column(field)).as_int(); }
|
|
bool get_bool(const char* field) const { return get(find_column(field)).as_bool(); }
|
|
real get_real(const char* field) const { return get(find_column(field)).as_real(); }
|
|
TDate get_date(const char* field) const { return get(find_column(field)).as_date(); }
|
|
|
|
virtual const TVariant& get(unsigned int column) const pure;
|
|
|
|
virtual const TString_array& variables() const { return _varnames; }
|
|
virtual const TVariant& get_var(const char* name) const;
|
|
virtual bool set_var(const char* name, const TVariant& var, bool create = false);
|
|
virtual bool ask_variables(bool all);
|
|
|
|
virtual int find_column(const char* column_name) const;
|
|
virtual const TVariant& get(const char* column_name) const;
|
|
virtual bool get_attr(int column, TAttributes & attr, bool header = false) const { return false; }
|
|
bool get_attr(const char* column_name, TAttributes & attr, bool header = false) const { return get_attr(column_name, attr, header); }
|
|
virtual const TToken_string& sheet_head() const;
|
|
|
|
// mode = 0|1=append 2=update 3=update|append 4=zap before writing
|
|
virtual bool save_as(const char* path, TRecordsetExportFormat fmt = fmt_unknown, int mode = 0);
|
|
|
|
// gestione per abilitare o disabilitare variabili
|
|
virtual void disable_variables() { _disable_variables = true; }
|
|
virtual void enable_variables() { _disable_variables = false; }
|
|
|
|
|
|
void set_parent(const TRecordset* rs) { _parentset = rs; }
|
|
|
|
const TString & get_custom_query(const char * module, const char * query_var, TString & query);
|
|
|
|
TRecordset();
|
|
virtual ~TRecordset() { }
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TISAM_recordset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TISAM_recordset : public TRecordset
|
|
{
|
|
TString _use;
|
|
|
|
TRelation* _relation;
|
|
TCursor* _cursor;
|
|
TArray _column; // Column infos
|
|
|
|
protected:
|
|
TRelation* relation() const;
|
|
|
|
virtual void reset();
|
|
virtual const TVariant& get_field(int logic, const char* field) const;
|
|
virtual void set_custom_filter(TCursor& cursor) const { }
|
|
|
|
public:
|
|
bool valid_cursor() const { return _cursor != NULL; }
|
|
virtual TCursor* cursor() const;
|
|
virtual void freeze(bool on = true) { return cursor()->freeze(on); }
|
|
virtual void unfreeze() { return cursor()->freeze(false); }
|
|
virtual bool frozen() const { return cursor()->frozen(); }
|
|
virtual bool not_frozen() const { return cursor()->not_frozen(); }
|
|
void set(const char* use);
|
|
virtual void requery();
|
|
virtual TRecnotype items() const;
|
|
virtual bool move_to(TRecnotype pos);
|
|
virtual TRecnotype current_row() const;
|
|
virtual unsigned int columns() const;
|
|
virtual const TRecordset_column_info& column_info(unsigned int c) const;
|
|
virtual const TRecordset_column_info& add_column_info(const TRecordset_column_info& c) { _column.add(c); return c; }
|
|
virtual const TVariant& get(unsigned int column) const;
|
|
virtual const TVariant& get(const char* column_name) const;
|
|
virtual const TVariant& get(int logic, const char* field) const { return get_field(logic, field);}
|
|
virtual const TString& driver_version() const;
|
|
virtual const TString& query_text() const { return _use; }
|
|
|
|
static TString& add_between_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
|
static TString& add_between_num_filter(TString & clause, const TString& field, const char * from_val, const char * to_val);
|
|
static TString& add_between_date_filter(TString & clause, const TString& field, const TDate & from_val, const TDate & to_val);
|
|
|
|
TISAM_recordset(const char* use);
|
|
TISAM_recordset(TCursor & c);
|
|
virtual ~TISAM_recordset();
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Utility
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool list_custom_files(const char* ext, const char* library, TString_array& files);
|
|
bool select_custom_file(TFilename& path, const char* ext, const char* classe = NULL);
|
|
const TString& logic2table(int logic_num);
|
|
int table2logic(const TString& name);
|
|
TRecordset* create_recordset(const TString& sql);
|
|
|
|
#endif
|