Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Declare Function GetLastError Lib "kernel32" () As Long
- Public Ods As udtOds
- Public OdsR As udtOds
- Public OdsW As udtOds
- Public User As udtUser
- Public UserR As udtUser
- Public UserW As udtUser
- Type udtUser
- Lang As String
- End Type
- Public Type udtFile
- FileName As String
- CreationDate As Date
- End Type
- Public Type udtOds
- ClientEntreprise As String
- ClientRue As String
- ClientVille As String
- ClientProvince As String
- ClientCodePostal As String
- ClientSexe As String
- ClientPrenom As String
- ClientNom As String
- ClientTitre As String
- EntenteDatePresente As String
- EntenteCommencant As String
- EntenteTerminant As String
- EntenteAcceptation As String
- EntentePeriode As String
- DirecteurSignataire1Sexe As String
- DirecteurSignataire1Titre As String
- DirecteurSignataire1Prenom As String
- DirecteurSignataire1Nom As String
- DirecteurSignataire1Telephone As String
- DirecteurSignataire1Email As String
- DirecteurSignataire2Sexe As String
- DirecteurSignataire2Titre As String
- DirecteurSignataire2Prenom As String
- DirecteurSignataire2Nom As String
- DirecteurSignataire2Telephone As String
- DirecteurSignataire2Email As String
- DirecteurSignataire2Impression As String
- GestionnaireSexe As String
- GestionnaireDirigeant As String
- GestionnairePrenom As String
- GestionnaireNom As String
- Files(500) As udtFile
- End Type
- Public Sub SaveUser()
- Dim canal As Integer
- canal = FreeFile
- With UserW
- .Lang = GetLang 'lang setter function
- End With
- On Error Resume Next
- Open ThisDocument.Path & "\user.conf" _
- For Random Access Write As #canal Len = Len(UserW)
- Put canal, 1, UserW
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub GetUser()
- Dim canal As Integer
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\user.conf" _
- For Random Access Read As #canal Len = Len(User)
- Get canal, 1, User
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub SaveAnOds()
- With Ods
- .Compagny = "Walmart"
- End With
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\Ods.ods" _
- For Random Access Write As #canal Len = Len(Ods)
- Put canal, 1, Ods
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub SaveArchives()
- With Ods
- .Compagny = "Walmart"
- End With
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\Ods.ods" _
- For Random Access Write As #canal Len = Len(Ods)
- Put canal, 1, Ods
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub ReadOds()
- Dim canal As Integer
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\lol.ods" _
- For Random Access Read As #canal Len = Len(Save)
- Get canal, 1, Save
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub ReadOdsx()
- Dim canal As Integer
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\user.config" _
- For Random Access Read As #canal Len = Len(User)
- Get canal, 1, User
- Close canal
- On Error GoTo 0
- End Sub
- Public Sub LoadArchives()
- Dim canal As Integer
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\user.conf" _
- For Random Access Read As #canal Len = Len(UserR)
- Get canal, 1, UserR
- Close canal
- On Error GoTo 0
- frmIdentification.cmbArchives.AddItem "Selectionner dequoi"
- 'display the saved enterprise
- For i = 0 To 9
- If UserR.Archives(i).Name <> "" Then
- 'MsgBox "SC2!!! " & UserR.Archives(i).Name
- frmIdentification.cmbArchives.AddItem UserR.Archives(i).Name
- End If
- Next
- frmIdentification.cmbArchives.ListIndex = 0
- End Sub
- Public Sub LoadArchives2()
- 'LUC AJOUT DES TEMPLATES FOLDER DANS LE DROPDOWN
- Dim fileList() As String
- Dim fName As String
- Dim fPath As String
- Dim i As Integer
- fPath = ThisDocument.Path & "\Archives\"
- fName = Dir$(fPath & "\*.ods", vbDirectory)
- While fName <> ""
- i = i + 1
- ReDim Preserve fileList(1 To i)
- fileList(i) = fName
- fName = Dir()
- Wend
- If i = 0 Then
- MsgBox "No files found"
- Exit Sub
- End If
- For i = 1 To UBound(fileList)
- myFile = fileList(i)
- If myFile <> "." And myFile <> ".." Then
- myFile = Replace(myFile, ".ods", "")
- If myFile <> "" Then
- frmIdentification.cmbArchives.AddItem (myFile)
- End If
- End If
- Next
- frmIdentification.cmbArchives.ListIndex = 0
- End Sub
- Public Sub LoadLanguage()
- Dim canal As Integer
- canal = FreeFile
- On Error Resume Next
- Open ThisDocument.Path & "\user.conf" _
- For Random Access Read As #canal Len = Len(UserR)
- Get canal, 1, UserR
- Close canal
- On Error GoTo 0
- If UserR.Lang = "F" Then
- blnFrench = True
- frmIdentification.Optfrancais.Value = 1
- versionFrancaise 'Change les labels
- Else
- blnFrench = False
- frmIdentification.Optenglish.Value = 1
- versionEnglish 'Change les labels
- End If
- End Sub
- Public Function GetLang()
- If frmIdentification.Optfrancais Then
- GetLang = "F"
- Else
- GetLang = "E"
- End If
- End Function
- Public Sub Quitter()
- SaveUser
- Unload frmDocuments
- Unload frmIdentification
- Unload frmValider
- Cancel = True
- End Sub
- Public Sub SaveOds()
- Dim OdsW As udtOds
- Dim canal As Integer
- Dim file As String
- canal = FreeFile
- file = ThisDocument.Path & "\Archives\" & frmIdentification.txtCie & ".ods"
- With OdsW
- 'CLIENT
- .ClientEntreprise = frmIdentification.txtCie
- .ClientRue = frmIdentification.txtNoRue
- .ClientVille = frmIdentification.txtVille
- .ClientProvince = frmIdentification.txtProv
- .ClientCodePostal = frmIdentification.txtZip
- If frmIdentification.optSexM Then
- .ClientSexe = "M"
- Else
- .ClientSexe = "F"
- End If
- .ClientPrenom = frmIdentification.txtDestPrenom
- .ClientNom = frmIdentification.txtDestNom
- .ClientTitre = frmIdentification.txtTitre
- 'ENTENTE
- .EntenteDatePresente = frmIdentification.Txtdate
- .EntenteCommencant = frmIdentification.TxtDebut
- .EntenteTerminant = frmIdentification.txtFin
- .EntenteAcceptation = frmIdentification.txtAcceptation
- .EntentePeriode = frmIdentification.Txtdurée
- 'DIRECTEUR #1
- If frmIdentification.OptionButton2 Then
- .DirecteurSignataire1Sexe = "M"
- Else
- .DirecteurSignataire1Sexe = "F"
- End If
- .DirecteurSignataire1Titre = frmIdentification.cmbTitre1
- .DirecteurSignataire1Prenom = frmIdentification.txtDCprenom
- .DirecteurSignataire1Nom = frmIdentification.txtDCnom
- .DirecteurSignataire1Telephone = frmIdentification.txtDCtel
- .DirecteurSignataire1Email = frmIdentification.txtDCemail
- 'DIRECTEUR #2
- If frmIdentification.OptionButton3 Then
- .DirecteurSignataire2Sexe = "M"
- Else
- .DirecteurSignataire2Sexe = "F"
- End If
- .DirecteurSignataire2Titre = frmIdentification.cmbTitre2
- .DirecteurSignataire2Prenom = frmIdentification.txtDPprenom
- .DirecteurSignataire2Nom = frmIdentification.txtDPnom
- .DirecteurSignataire2Telephone = frmIdentification.txtDPtel
- .DirecteurSignataire1Email = frmIdentification.txtDPemail
- .DirecteurSignataire2Impression = ""
- 'GESTIONNAIRE
- If frmIdentification.OptionButton5 Then
- .GestionnaireSexe = "M"
- Else
- .GestionnaireSexe = "F"
- End If
- .GestionnaireDirigeant = frmIdentification.cmbTitreIntro
- .GestionnairePrenom = frmIdentification.txtPrenomIntro
- .GestionnaireNom = frmIdentification.txtNomIntro
- 'FICHIERS DE L'ODS
- For i = 0 To frmDocuments.listDocAjouter.ListCount - 1
- .Files(i).FileName = frmDocuments.listDocAjouter.List(i)
- Next i
- End With
- '1.DELETE LE FICHIER AVEC LA MÊME ENTREPRISE
- '(PCQ ELLE VA ÊTRE REMPLACER PAR CELLE-CI DE TOUTE FACON,)
- '2.TRIM POUR AVOIR X FICHIERS - 1
- '(PCQ APRÈS AVOIR ENREGISTRER ON VA AVOIR X FICHIERS)
- '3.ON ENREGISTRE L'ODS DE L'ENTREPRISE
- '(PCQ C'EST LE BUT FINAL)
- '1.
- If FileExists(file) Then
- Kill file
- End If
- '2.
- TrimArchives
- '3.
- On Error Resume Next
- Open file _
- For Random Access Write As #canal Len = Len(OdsW)
- Put canal, 1, OdsW
- Close canal
- On Error GoTo ErrH
- ErrH:
- Dim Texte As String
- Dim Label As String
- If Err.Number = 53 Then
- Texte = "Il est impossible d'ouvrir le fichier OffreSer.ini" & vbCrLf & vbCrLf & _
- "Veuillez communiquer avec l'Unité de vente - Commercial au" & vbCrLf & _
- "(514) 394-5000, poste 3533 ou au 1-800-361-8688, poste 3533."
- Label = "Cette macro ne peut fonctionner correctement et sera " & _
- "interrompue."
- MsgBox "shibby " & Texte, vbCritical, Label
- End
- Else
- MsgBox "shibby2 Erreur # " & Err.Number & ", " & Err.Description, vbCritical
- MsgBox GetLastError()
- End If
- End Sub
- Public Sub SaveOds2()
- Dim OdsW As udtOds
- Dim canal As Integer
- Dim file As String
- canal = FreeFile
- file = ThisDocument.Path & "\Archives\" & frmIdentification.txtCie & ".ods"
- With OdsW
- 'CLIENT
- .ClientEntreprise = frmIdentification.txtCie
- .ClientRue = frmIdentification.txtNoRue
- .ClientVille = frmIdentification.txtVille
- .ClientProvince = frmIdentification.txtProv
- .ClientCodePostal = frmIdentification.txtZip
- If frmIdentification.optSexM Then
- .ClientSexe = "M"
- Else
- .ClientSexe = "F"
- End If
- .ClientPrenom = frmIdentification.txtDestPrenom
- .ClientNom = frmIdentification.txtDestNom
- .ClientTitre = frmIdentification.txtTitre
- 'ENTENTE
- .EntenteDatePresente = frmIdentification.Txtdate
- .EntenteCommencant = frmIdentification.TxtDebut
- .EntenteTerminant = frmIdentification.txtFin
- .EntenteAcceptation = frmIdentification.txtAcceptation
- .EntentePeriode = frmIdentification.Txtdurée
- 'DIRECTEUR #1
- If frmIdentification.OptionButton2 Then
- .DirecteurSignataire1Sexe = "M"
- Else
- .DirecteurSignataire1Sexe = "F"
- End If
- .DirecteurSignataire1Titre = frmIdentification.cmbTitre1
- .DirecteurSignataire1Prenom = frmIdentification.txtDCprenom
- .DirecteurSignataire1Nom = frmIdentification.txtDCnom
- .DirecteurSignataire1Telephone = frmIdentification.txtDCtel
- .DirecteurSignataire1Email = frmIdentification.txtDCemail
- 'DIRECTEUR #2
- If frmIdentification.OptionButton3 Then
- .DirecteurSignataire2Sexe = "M"
- Else
- .DirecteurSignataire2Sexe = "F"
- End If
- .DirecteurSignataire2Titre = frmIdentification.cmbTitre2
- .DirecteurSignataire2Prenom = frmIdentification.txtDPprenom
- .DirecteurSignataire2Nom = frmIdentification.txtDPnom
- .DirecteurSignataire2Telephone = frmIdentification.txtDPtel
- .DirecteurSignataire1Email = frmIdentification.txtDPemail
- .DirecteurSignataire2Impression = ""
- 'GESTIONNAIRE
- If frmIdentification.OptionButton5 Then
- .GestionnaireSexe = "M"
- Else
- .GestionnaireSexe = "F"
- End If
- .GestionnaireDirigeant = frmIdentification.cmbTitreIntro
- .GestionnairePrenom = frmIdentification.txtPrenomIntro
- .GestionnaireNom = frmIdentification.txtNomIntro
- 'FICHIERS DE L'ODS
- For i = 0 To frmDocuments.listDocAjouter.ListCount - 1
- .Files(i).FileName = frmDocuments.listDocAjouter.List(i)
- Next i
- End With
- '1.DELETE LE FICHIER AVEC LA MÊME ENTREPRISE
- '(PCQ ELLE VA ÊTRE REMPLACER PAR CELLE-CI DE TOUTE FACON,)
- '2.TRIM POUR AVOIR X FICHIERS - 1
- '(PCQ APRÈS AVOIR ENREGISTRER ON VA AVOIR X FICHIERS)
- '3.ON ENREGISTRE L'ODS DE L'ENTREPRISE
- '(PCQ C'EST LE BUT FINAL)
- '1.
- If FileExists(file) Then
- Kill file
- End If
- '2.
- TrimArchives
- '3.
- Open file _
- For Random Access Write As #canal Len = 10000
- Put canal, 1, OdsW
- Close canal
- End Sub
- Public Sub LoadOds()
- Dim canal As Integer
- Dim FileName As String
- canal = FreeFile
- fInitialize
- FileName = ThisDocument.Path & "\Archives\" & frmIdentification.cmbArchives.Value & ".ods"
- If FileExists(FileName) Then
- 'LE TEMPLATE EXISTE ON LE LOAD.
- On Error Resume Next
- Open FileName _
- For Random Access Read As #canal Len = Len(OdsR)
- Get canal, 1, OdsR
- Close canal
- On Error GoTo 0
- 'GESTION DES SEXES
- Select Case OdsR.DirecteurSignataire1Sexe
- Case "F"
- frmIdentification.OptionButton1.Value = 1
- Case "M"
- frmIdentification.OptionButton2.Value = 1
- End Select
- Select Case OdsR.DirecteurSignataire2Sexe
- Case "F"
- frmIdentification.OptionButton4.Value = 1
- Case "M"
- frmIdentification.OptionButton3.Value = 1
- End Select
- Select Case OdsR.GestionnaireSexe
- Case "F"
- frmIdentification.OptionButton6.Value = 1
- Case "M"
- frmIdentification.OptionButton5.Value = 1
- End Select
- Select Case OdsR.ClientSexe
- Case "F"
- frmIdentification.optSexF.Value = 1
- Case "M"
- frmIdentification.optSexM.Value = 1
- End Select
- 'FIN DE LA GESTION DES SEXES.
- With frmIdentification
- 'CLIENT
- .txtProv = Trim(OdsR.ClientProvince)
- .txtVille = Trim(OdsR.ClientVille)
- .txtCie = Trim(OdsR.ClientEntreprise)
- .txtDestNom = Trim(OdsR.ClientNom)
- .txtDestPrenom = Trim(OdsR.ClientPrenom)
- .txtNoRue = Trim(OdsR.ClientRue)
- .txtTitre = Trim(OdsR.ClientTitre)
- .txtZip = Trim(OdsR.ClientCodePostal)
- 'DIRECTEUR #1
- .txtDCnom = Trim(OdsR.DirecteurSignataire1Nom)
- .txtDCprenom = Trim(OdsR.DirecteurSignataire1Prenom)
- .txtDCtel = Trim(OdsR.DirecteurSignataire1Telephone)
- 'DIRECTEUR #2
- .txtDPnom = Trim(OdsR.DirecteurSignataire2Nom)
- .txtDPprenom = Trim(OdsR.DirecteurSignataire2Prenom)
- .txtDPtel = Trim(OdsR.DirecteurSignataire2Telephone)
- 'GESTIONNAIRE
- .txtNomIntro = Trim(OdsR.GestionnaireNom)
- .txtPrenomIntro = Trim(OdsR.GestionnairePrenom)
- .cmbTitreIntro = Trim(OdsR.GestionnaireDirigeant)
- .lblVersion = APP_VERSION
- End With
- Dim z As Integer
- z = 0
- Do While OdsR.Files(z).FileName <> ""
- 'MsgBox "Loading : " & OdsR.Files(z).FileName 'HERE IT POPS!
- LoadFile (OdsR.Files(z).FileName)
- z = z + 1
- Loop
- Else
- MsgBox "Error, cannot load this template.", vbCritical
- End If
- End Sub
- Sub TrimArchives()
- 'GARDE SEULEMENT LES 20 DERNIERES ARCHIVES.
- Dim strFileName As String
- Dim strOldestFile As String
- Dim strFolder As String
- Dim iFileCount As Integer
- Dim i As Integer
- Dim dt As Date
- strFolder = ThisDocument.Path & "\Archives"
- strFileName = Dir$(strFolder & "\*")
- strOldestFile = strFileName
- dt = FileDateTime(strFolder & "\" & strFileName)
- Do Until strFileName = ""
- Debug.Print strFileName, FileDateTime(strFolder & "\" & strFileName),
- If (FileDateTime(strFolder & "\" & strFileName)) < dt Then
- dt = FileDateTime(strFolder & "\" & strFileName)
- strOldestFile = strFileName
- End If
- i = i + 1
- strFileName = Dir$()
- Loop
- If i > 19 Then
- Kill strFolder & "\" & strOldestFile
- End If
- End Sub
- Sub total()
- Dim total As Integer
- total = frmDocuments.listDocAjouter.ListCount
- frmDocuments.lbltotal.Caption = total
- End Sub
- Public Function LoadFile(ByVal file)
- 'LOAD FILE
- 'Me.listDocAjouter.AddItem Me.listDocDisp.Text
- 'Me.listDocDisp.RemoveItem Me.listDocDisp.ListIndex
- 'MsgBox "TotalSize: " & frmDocuments.listDocDisp.ListCount - 1
- While i < frmDocuments.listDocDisp.ListCount - 1
- 'MsgBox "TotalSizel: " & frmDocuments.listDocDisp.ListCount - 1
- If frmDocuments.listDocDisp.List(i) = file Then
- 'MsgBox file
- frmDocuments.listDocDisp.RemoveItem (i)
- frmDocuments.listDocAjouter.AddItem file
- End If
- i = i + 1
- Wend
- End Function
- Public Function Validate() As Boolean
- If frmIdentification.txtCie.Value = "" Then
- MsgBox "Remplir le champ entreprise svp"
- Validate = False
- Else
- Validate = True
- End If
- End Function
- Public Sub EmptyFields()
- 'Vide tous les champs
- With frmIdentification
- 'Archives
- .cmbArchives.ListIndex = 0
- 'Client
- .txtCie = ""
- .txtNoRue = ""
- .txtVille = ""
- .txtZip = ""
- .txtProv = ""
- .txtDestPrenom = ""
- .txtDestNom = ""
- .txtTitre = ""
- .optSexM = 0
- .optSexM = 0
- 'Directeur #1
- .txtDPnom = ""
- .txtDPprenom = ""
- .txtDPtel = ""
- .OptionButton1 = 0
- .OptionButton2 = 0
- 'Directeur #2
- .txtDCnom = ""
- .txtDCprenom = ""
- .txtDCtel = ""
- .OptionButton3 = 0
- .OptionButton4 = 0
- .CheckBox1 = 0 'Checkbox pour l'impression
- 'Gestionnaire
- .txtNomIntro = ""
- .txtPrenomIntro = ""
- .cmbTitreIntro = ""
- .OptionButton5 = 0
- .OptionButton6 = 0
- 'Entente
- .txtAcceptation = ""
- .TxtDebut = ""
- .txtFin = ""
- .Txtdurée = ""
- .cmbTitre1.ListIndex = -1
- .cmbTitre2.ListIndex = -1
- If frmIdentification.Optfrancais Then
- .Txtdate = Format(Date, "d MMMM yyyy")
- Else
- .Txtdate = Format(Date, "MM/dd/yyyy")
- End If
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement