Prikazi cijelu temu 24.03.2011 11:06
miro35 Van mreze
Clan
Registrovan od:05.01.2009
Lokacija:-


Predmet:Re: Gotova rjeÅ¡enja za fiskalne uređaje
Sada ide funkcija za provjeru "ProvjeraP(Me.BrojRacuna).Nju stavimo odmah ispod ovog koda za ispis računa:
PreuzmiIzvorni kôd (Text):
  1.  Function ProvjeraP(BrojRac As String) As String
  2.      Const PutTO = "C:\HCP\TO_FP"
  3.     Const PutFrom = "C:\HCP\FROM_FP"
  4.      
  5.    
  6.     Dim temp As String
  7.     Dim ImeF(1 To 2) As String
  8.     Dim ImeR(1 To 2) As String
  9.     Dim fs, R, F
  10.     Dim Brojac As Integer
  11.     Dim i As Integer
  12.     Dim Putanja_Filea As String
  13.      
  14.    
  15.     ImeR(1) = "RCP_" & BrojRac & ".XML"  ' Broj rac iz polja me.Me.BROIZD + RCP_ tekst
  16. ImeR(2) = "RCP_" & BrojRac & ".ERR"
  17. Provjera1:
  18. Set fs = Application.FileSearch
  19. With fs
  20.     .LookIn = PutTO
  21.     .FileType = 1
  22.     If .Execute > 0 Then
  23.         For i = 1 To .foundfiles.Count
  24.          F = Right(.foundfiles(i), 3)
  25.           If F = "XML" Then
  26.           ImeF(1) = .foundfiles(i)
  27.           ImeF(1) = ImeFajla(ImeF(1))
  28.             If ImeF(1) = ImeR(1) Then
  29.             DoEvents
  30.             Brojac = Brojac + 1
  31.                If Brojac > 3 Then GoTo Izlaz
  32.                Zaustavi (Brojac)
  33.                GoTo Provjera1
  34.             End If
  35.           End If
  36.         Next i
  37.     End If
  38.  
  39. End With
  40.      
  41. Provjera2:
  42. Set fs = Application.FileSearch
  43. With fs
  44.     .LookIn = PutFrom
  45.     .FileType = 1
  46.     If .Execute > 0 Then
  47.         For i = 1 To .foundfiles.Count
  48.         F = Right(.foundfiles(i), 3)
  49.             If F = "ERR" Then
  50.             ImeF(2) = ImeFajla(.foundfiles(i))
  51.                 If ImeF(2) = ImeR(2) Then
  52.                 Putanja_Filea = .foundfiles(i)
  53.                 Close #1
  54.                 Open Putanja_Filea For Input As 1
  55.                 Input #1, temp
  56.                 Close #1
  57.                 MsgBox "GreÅ¡ka:" & temp & "!", vbExclamation, "Ra
  58. un nije fiskaliziran"
  59.                DoCmd.SetWarnings False
  60.             DoCmd.RunSQL "UPDATE Proba SET Nefiskaliziran='" & "-1" & "' WHERE BrojRacuna='" & Forms.frmIZLAZMP.brojRacuna & "'"
  61. DoCmd.SetWarnings True
  62.                 GoTo Kraj
  63.                 End If
  64.             End If
  65.         Next i
  66.     End If
  67. End With
  68.      
  69. Kraj:
  70.  
  71.     Exit Function
  72. Izlaz:
  73.     MsgBox "Ra
  74. un nije ispisan,greška u komunikaciji sa ureajem!", vbExclamation, "Obavijest"
  75.     DoCmd.SetWarnings False
  76.             DoCmd.RunSQL "UPDATE Proba SET Nefiskaliziran='" & "-1" & "' WHERE BrojRacuna='" & Forms.frmIZLAZMP.brojRacuna & "'"
  77. DoCmd.SetWarnings True
  78. BrisiFile (PutTO)
  79.  
  80. GoTo Provjera2
  81.     GoTo Kraj
  82.     End Function
  83.      
  84.     Function ImeFajla(PutanjaF As String) As String
  85.     '*******************************************
  86.     'Ime:      ImeDir   (Function)
  87.     'Sadržaj: Odvaja ime fajla od putanje
  88.     'Autor:     ZXZ
  89.     'Datum:      09 01, 2010, 11:36:53
  90.     'Adresa: Tuzla BiH
  91.     'Email:     zxz@icentar.ba
  92.     'Ulazni parametri:Putanja
  93.     'Izlazni parametri:Zadnj dir od putanja
  94.     '*******************************************
  95.        Dim X As Integer
  96.         Dim Putanja As String
  97.        
  98.         On Error Resume Next
  99.     Putanja = PutanjaF
  100. Start:
  101.     Do Until Right$(Putanja, 1) = "\"
  102.             Putanja = Left$(Putanja, Len(Putanja) - 1)
  103.      Loop
  104.      ImeFajla = Mid(PutanjaF, Len(Putanja) + 1)
  105.     End Function
  106.     Function Zaustavi(Trajanje)
  107.     Dim VRIJEME
  108.      
  109.     DoEvents
  110.      
  111.     Trajanje = Trajanje + Timer()
  112. Start:
  113.     VRIJEME = Timer()
  114.     If VRIJEME < Trajanje Then GoTo Start
  115.     End Function
  116.     Function BrisiFile(Putanja As String)
  117.     Dim fs
  118.     Dim i As Integer
  119.        
  120.     Set fs = Application.FileSearch
  121.     With fs
  122.         .LookIn = Putanja
  123.         .FileType = 1
  124.         If .Execute > 0 Then
  125.             For i = 1 To .foundfiles.Count
  126.             Kill .foundfiles(i)
  127.             Next i
  128.         End If
  129.     End With
  130.     End Function

Miro