Re: Własne pola dla dok. sprzedaży i magazynowych na wydruku
Stare wydruki (AmBasic)?
Robiłem coś takiego, bez obiektów, myślę, że mogę pomóc.
Raport "Drukowanie wymiarów"Kod:
dispatch con = GetAdoConnection()
dispatch sub RsFromSql(string sSQL, dispatch con)
dispatch recordset = "ADODB.Recordset"
if recordset.State == 1 then recordset.Close()
recordset.Open(sSQL,con,3)
if recordset.RecordCount > 0 then recordset.MoveFirst()
RSFromSql = recordset
endsub
//RS typy danych:
#define adSmallInt 2 //This data type indicates a 2-byte (16-bit) signed integer (DBTYPE_I2).
#define adInteger 3 //This data type indicates a 4-byte (32bit) signed integer (DBTYPE_I4).
#define adSingle 4 //This data type indicates a 4-byte (32-bit) single-precision IEEE floating-point number (DBTYPE_R4).
#define adDouble 5 //This data type indicates an 8-byte (64-bit) double-precision IEEE floating-point number (DBTYPE_R8).
#define adCurrency 6 //A data type indicates a currency value (DBTYPE_CY). Currency is a fixed-point number with four digits to the right of the decimal point. It is stored in an 8-byte signed integer scaled by 10,000. This data type is not supported by the Microsoft® OLE DB Provider for AS/400 and VSAM or the Microsoft OLE DB Provider for DB2.
#define adDate 7 //This data type indicates a date value stored as a Double, the whole part of which is the number of days since December 30, 1899, and the fractional part of which is the fraction of a day. This data type is not supported by the OLE DB Provider for AS/400 and VSAM or the OLE DB Provider for DB2.
#define adBoolean 11 //Indicates a Boolean value (DBTYPE_BOOL).
#define adVarChar 200 //This data type indicates variable-length character data (DBTYPE_STR).
#define adLongVarChar 201 //This data type indicates a long string value.
#define adVarWChar 202 //This data type indicates a Unicode string value. This data type is not supported by the OLE DB Provider for AS/400 and VSAM or the OLE DB Provider for DB2.
#define adLongVarWChar 203 //This data type indicates a long Unicode string value. This data type is not supported by the OLE DB Provider for AS/400 and VSAM or the OLE DB Provider for DB2.
#define adDBDate 133 //This data type indicates an OLE DB date structure (DBTYPE_DATE).
#define adDBTimeStamp 135 //Indicates a date/time stamp (yyyymmddhhmmss plus a fraction in billionths) (DBTYPE_DBTIMESTAMP).
string sub DajNazweWymiaru(string sSkrot)
string sSQL = using " SELECT [Name] FROM [SSCommon].[STDimensions] WHERE Symbol='%s' ", sSkrot
dispatch rs = RsFromSQL(sSQL,con)
if rs.Recordcount > 0 then DajNazweWymiaru = rs.Fields(0).Value
endsub
record rWym
string sNazwa[200]
string sWartosc[200]
int iWartosc
endrec
rWym w(1)
int sub GenerujWymiary(long iddk, string sKartoteka)
string sTabZ
int i
if lcase(sKartoteka) == "zo" then sTabZ = "HMF_SalesOrderClassification"
if lcase(sKartoteka) == "zw" then sTabZ = "HMF_PurchasingOrderClassification"
if lcase(sKartoteka) == "sp" then sTabZ = "HMF_SalesInvoiceClassification"
if lcase(sKartoteka) == "mg" then sTabZ = "HMF_WarehouseDocumentClassification"
if lcase(sKartoteka) == "zk" then sTabZ = "HMF_PurchasingInvoiceClassification"
if lcase(sKartoteka) == "zw" then sTabZ = "HMF_PurchasingOrderClassification"
string sSQL = ""
sSQL = " SELECT * "
sSQL+= using " FROM [SSCommon].%s WHERE ElementId=%L", sTabZ, iddk
dispatch rs = RsFromSQL(sSQL, con)
if rs.RecordCount > 0 then
for i=0 to i>rs.Fields.Count-1
if rs.Fields(i).Value && UCASE(mid(rs.Fields(i).Name,1,4)) == "CDIM" then
buf = mid(rs.Fields(i).Name,6,len(rs.Fields(i).Name))
w(i+1).sNazwa = DajNazweWymiaru(buf)
select case rs.Fields(i).Type
case adInteger,adSmallInt
w(i+1).iWartosc = rs.Fields(i).Value
if w(i+1).iWartosc != 0 then GenerujWymiary = 1
case else
w(i+1).sWartosc = rs.Fields(i).Value
if w(i+1).sWartosc != "" then GenerujWymiary = 1
endselect
endif
Grow w,1
next i
endif
if size(w)>1 then shrink w,1
endsub
int sub DrukujWymiary(long iddk, string sKartoteka)
int iCzySaWymiary = GenerujWymiary(iddk, sKartoteka)
int i
int nl = Styl ( "tekst", -1, "nl" )
int nc = Styl ( "tekst", 0, "nc" )
int nr = Styl ( "tekst", 1, "nr" )
int kr = Styl ( "kwota", 1, "kr" )
int nb = CopyFont ( "tekst",1,35 )
int nbl = Styl ( nb, -1, "nbl" )
int kolTab(2) = 600,(str.szer-600)
int stylTab(2) = nbl, nl
int tab = Tabela 1, 10, kolTab, stylTab
if iCzySaWymiary !=0 then
Tabela #tab, od 0,#B+10 // tylko po to by zrobić odstęp
Koniec
for i=1 to i>size(w)
if w(i).sWartosc != "" then
Tabela #tab
kolumna 1, w(i).sNazwa
kolumna 2, w(i).sWartosc
Koniec
endif
next i
print LF
endif
endsub
I później dodajesz w raporcie drukującym WZ pod nagłówkiem, przed pozycjami 2 linie:
Kod:
#include "Drukowanie wymiarów"
DrukujWymiary(xDocument.id, "mg")