Advertisement
bousaid

PROCEDURE Virement CCP Windev

Jul 18th, 2020 (edited)
3,326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. PROCEDURE Virement_CCP()
  2. // --------------------------------------------------------------------------------------
  3. // ----------------------- Virement CCP By BOUSSAID Mustapha ---------------------------
  4. // ----------------------------- APC SALI 2020 ------------------------------------------
  5.  
  6. sRes is string = "" // Name of the selected directory
  7.  
  8. // Using the Windows directory picker
  9. sRes = fSelectDir("C:\", "اختر مجلد الحفظ", "اختر المجلد أو المكان الذي سيتم حفظ الملف النصي فيه")
  10.  
  11. // Was the selection of a directory validated the user
  12. IF sRes <> "" THEN
  13.  
  14. // Identifier of the external file:
  15. // this identifier is used by all the functions for managing the external files
  16. nFileID is int
  17. nNbrligne is int
  18.  
  19. // Retrieve the number of employees
  20. nNbrligne = HNbRec(ActiveUsers,hStateActive)
  21.  
  22. //Operation date
  23. sDatesave is string = DateToString(EDT_Date,"mm_yyyy")
  24.  
  25. // Create the txt file in the selected directory
  26. nFileID = fCreate(CompleteDir(sRes)+sDatesave+".txt",foAnsi)
  27. fClose(nFileID)
  28.  
  29. // Open the txt file in read/write found in the Selected directory
  30. nFileID = fOpen(CompleteDir(sRes)+sDatesave+".txt",foAnsi+foReadWrite)
  31.  
  32. // Check the file opening
  33. IF nFileID = -1 THEN
  34. Error("Error while creating the file",ErrorInfo())
  35. RETURN
  36. END
  37.  
  38. //Get Total & CTS
  39. nTot is int = EDT_tot
  40. cyB is currency
  41. sCt is string
  42. cyB = DecimalPart(EDT_tot)
  43. sCt = Middle(NumToString(cyB,".2f"),3,4)
  44.  
  45. //First line
  46. fWriteLine(nFileID, "*"+Complete("", 8, "0")+Complete(NumToString(EDT_ccp,"012d"),12,"0")+Complete(NumToString(nTot,"011d"),11,"0")...
  47. +Complete(sCt, 2)+Complete(NumToString(nNbrligne,"07d"),7)+DateToString(EDT_Date,"mm")+ DateToString(EDT_Date,"YYYY")+Complete("", 14)+ "0")
  48.  
  49. //Users
  50. HReadFirst(ActiveUsers,nameFR)
  51. WHILE HFound(ActiveUsers)
  52. //cle or rip
  53. sClee is string
  54. IF INT_MiniSwitchExternalD = 1 THEN
  55. sClee = ActiveUsers.CleRIP
  56. ELSE
  57. sClee = ActiveUsers.CleCCP
  58. END
  59.  
  60. //Get the amount & Decimal
  61. nMont is int = ActiveUsers.total2
  62. cyCts is currency
  63. sCts is string
  64. cyCts = DecimalPart(ActiveUsers.total2)
  65. sCts = Middle(NumToString(cyCts,".2f"),3,4)
  66.  
  67. //LINE PER EMPLOYEE
  68. fWriteLine(nFileID, "*"+Complete("", 8, "0")+Complete(NumToString(ActiveUsers.Num_Compte,"010d"),10,"0") + sClee+ Complete(NumToString(nMont,"011d"),11,"0")...
  69. +Complete(sCts, 2)+Complete(StringBuild("%1 %2",ActiveUsers.nameFR, ActiveUsers.prenome),27)+ "1")
  70. HReadNext(ActiveUsers,nameFR)
  71. END
  72.  
  73. // Close the txt file
  74. fClose(nFileID)
  75.  
  76. // Inform the user
  77. Info(CompleteDir(sRes)+sDatesave+".txt " + "was successfully generated")
  78. ELSE
  79. // No directory was selected by the user
  80. Info("تم الإلغاء")
  81. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement