PRIVATE FUNCTION MySetButton()
FasMod = NOT myset
Bnuovo.Enabled = MySet
Bmodifica.Enabled = MySet
Belimina.Enabled = MySet
Bannulla.Enabled = NOT MySet
Bsalva.Enabled = NOT MySet
Btrova.Enabled = MySet
Bstampa.Enabled = MySet
Bchiudi.Enabled = MySet
Binizio.Enabled = MySet
Bindietro.Enabled = MySet
Bavanti.Enabled = MySet
Bfine.Enabled = MySet
Bgriglia.Enabled = MySet
END
PUBLIC SUB Form_Open()
m1.MyNaF = Contasoldi
FMdi.InsForm
ValueBox1.Alignment = 3
ValueBox2.Alignment = 3
ValueBox3.Alignment = 3
ValueBox4.Alignment = 3
ValueBox5.Alignment = 3
ValueBox6.Alignment = 3
ValueBox7.Alignment = 3
ValueBox8.Alignment = 3
ValueBox9.Alignment = 3
ValueBox10.Alignment = 3
ValueBox11.Alignment = 3
ValueBox12.Alignment = 3
ValueBox13.Alignment = 3
ValueBox14.Alignment = 3
ValueBox15.Alignment = 3
ValueBox1.Select
END
mancano alcuni componenti: gb.db.mysql, gb.db.odbc, gb.option
PUBLIC SUB _new()
DIM pdf AS PdfClienti 'commento: qui dovrei inserire una variabile e non il nome della classe
RANDOMIZE
EXEC ["pwd"] TO sDir
sDir = Replace(sDir, "\n", "")
pdf = NEW PdfClienti '("Portrait", "mm", "A4")
pdf.Open()
pdf.AliasNbPages()
pdf.Data()
pdf.Output(sDir &/ "report1.pdf", FALSE)
DrawingArea1.y = 60
label3.y = 60
panel2.y = label3.y + 6
CATCH
Message.Error(Error.Text & "\n" & Error.Where)
END
PUBLIC SUB stampa(modo AS Integer) AS Integer
DIM hStampa AS Process
DIM pdf AS mystampa
RANDOMIZE
pdf = NEW mystampa("Portrait", "mm", "A4")
pdf.Open()
pdf.AliasNbPages()
pdf.Data
pdf.Output(User.Home & "/.Gestione/listino.pdf", FALSE)
IF modo = 0 THEN 'stampo direttamente
hStampa = SHELL ("lpr " & User.Home & "/.Gestione/listino.pdf") WAIT
ENDIF
IF modo = 1 THEN 'stampo in anteprima
hStampa = SHELL ("evince " & User.Home & "/.Gestione/listino.pdf")
ENDIF
IF modo = 2 THEN ' esporto in pdf
Dialog.Filter = ["*.pdf", "file pdf"]
Dialog.Title = "Salva file PDF"
IF Dialog.SaveFile() THEN RETURN
pdf.Output(Dialog.Path, FALSE)
ENDIF
END
Penso proprio che te lo ruberò
desadex ha scritto:
inoltre vorrei creare uno script o una funzione che in fase d'installazione mi crei il database.
Io in un mio programma faccio creare la tabella mediante codice al primo avvio del programma...in questo modo sto sicuro che le volte successive non mi crea il database. Se ti serve ti dico come ho fatto.
Se guardi l'esempio di tableview che avevo postato io, con con sqlite, crea il database al primo avvio, cioè se non lo trova lo crea. Però con mysql non ho mai provato.
ps. se mi rubi Pdfprint non devi ringraziare me ma MD visto che il progetto era suo, io ho solo fatto delle modifiche. e non solo Pdfprint è una bomba ma anche pdfwriter, ora che sto cominciando a fare i report mi rendo conto delle sue enormi potenzialità
PUBLIC SUB _new()
'-- se la cartella del database non esiste la crea
IF NOT Exist(User.Home &/ ".database") THEN MKDIR User.Home &/ ".database"
'-- se il database non esiste lo crea
'-- Imposta i parametri di connessione al database
WITH $hConn
.Type = "sqlite3" ' indicazione del tipo di database da utilizzare
.Host = sPercorso
.Login = ""
.Password = ""
END WITH
'-- apre la connessione per testare esistenza database
$hConn.Open
'-- se non esiste crea il nuovo database
IF NOT $hConn.Databases.Exist(sName) THEN
$hConn.Databases.Add(sName)
$hConn.Close
$hConn.Name = sName
$hConn.Open()
'-- da uno scheletro alla tabella interna (vedere testo "info")
sql = "CREATE TABLE 'tabella' ( 'id' INTEGER PRIMARY KEY, 'nome1' VARCHAR(255) DEFAULT NULL, 'nome2' VARCHAR(255) DEFAULT NULL, 'nome3' VARCHAR(255) DEFAULT NULL, 'nome4' VARCHAR(250) DEFAULT NULL, 'nome5' VARCHAR(4) DEFAULT NULL, 'nome6' VARCHAR(10) DEFAULT NULL, 'nome7' VARCHAR(4) DEFAULT NULL);"
hres = $hConn.EXEC(sql)
$hConn.Commit
END IF
'-- chiude la connessione
$hConn.Close
END
DIM sql AS String
sql = "Select MAX(CodClie) as valormax from clienti"
MyRS = MODMain.$conn.Exec(sql)
tb1.Text = MyRS!valormax
PUBLIC SUB formtvaluta(stringa AS String) AS String
DIM p, p1, itemp, itemp1 AS Integer
DIM initstringa AS String
''''sostituzione o aggiunta della virgola
IF InStr(stringa, ",") <> 0 THEN
stringa = Replace(stringa, ",", ".")
ENDIF
IF InStr(stringa, ".") <> 0 THEN
stringa = Replace(stringa, ".", ",")
ELSE
stringa = stringa & ",00"
ENDIF
'''''arrotondamento a due decimali
p = InStr(stringa, ",")
p1 = Len(stringa) - p
initstringa = Left(stringa, p - 1)
IF p1 = 2 THEN
stringa = stringa
ELSE IF p1 <= 1 THEN
stringa = stringa & "0"
ELSE IF p1 > 2 THEN
itemp = CInt(Mid(stringa, p + 1, 2))
itemp1 = CInt(Mid(stringa, p + 1 + 2, 1))
IF itemp1 >= 5 THEN
INC itemp
ENDIF
IF itemp = 100 THEN
stringa = CString(CInt(initstringa) + 1) & ",00"
ELSE
stringa = initstringa & "," & CString(itemp)
ENDIF
ENDIF
'''''''''''aggiunta puntini ogni 1000
IF Len(stringa) >= 7 THEN
stringa = Mid(stringa, 1, (Len(stringa) - 6)) & "." & Right(stringa, 6)
ENDIF
IF Len(stringa) >= 11 THEN
stringa = Mid(stringa, 1, (Len(stringa) - 10)) & "." & Right(stringa, 10)
ENDIF
IF Len(stringa) >= 15 THEN
stringa = Mid(stringa, 1, (Len(stringa) - 14)) & "." & Right(stringa, 14)
ENDIF
IF Len(stringa) >= 19 THEN
stringa = Mid(stringa, 1, (Len(stringa) - 18)) & "." & Right(stringa, 18)
ENDIF
RETURN stringa
END
PUBLIC SUB trasfvaluta(stringa AS String) AS String
''se scrivo l'importo con separatore decimale "." anzichè ","
IF Left(Right(stringa, (Len(stringa)) - (InStr(stringa, ".")) + 1), 1) = "." THEN
stringa = Left(stringa, (Len(stringa) - 3)) & "," & Right(stringa, 2)
ENDIF
''tolgo i punti di separatori migliaia
stringa = Replace(stringa, ".", "")
''cambio il separatore decimale da "," a "." per salvarlo in db
stringa = Replace(stringa, ",", ".")
RETURN stringa
END
MyRS!prezzo = Funzioni.trasfvaluta(tbprezzo.Text)
tbprezzo.text = Funzioni.formtvaluta(MyRS!prezzo)
PUBLIC $conn AS NEW Connection
PUBLIC PROCEDURE Connect()
$conn.Close
$conn.Type = "mysql"
$conn.Host = "localhost"
$conn.Login = "root"
$conn.port = "3306"
$conn.Name = "miodatabase"
$conn.Password = "miapassword" '
$conn.Open
END
PUBLIC PROCEDURE disconnect()
$conn.Close
END
PUBLIC MyRS AS Result
PUBLIC SUB Form_Open()
MODMain.Connect() 'Apro il database
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
devo cominciare a fare un report per le fatture con pdfwriter, ho visto che nel tuo progetto nion hai fatto un report fatture, non lo hai previsto oppure non ti serve?
Premetto che non ho installato MySQL come avete fatto voi (solo per comodità) e quale distribuzione linux state usando, ma tempo fà ho incontrato lo stesso problema (io uso Ubuntu).Date un'occhiata a questa discussione è vedete se può esservi utile. http://www.gambas-it.org/gmbs/modules ... c.php?topic_id=95&forum=3
#!/bin/sh mkdir /var/run/mysqld
cd /var/run/mysqld/
ln -s /var/mysql/mysql.sock mysqld.sock