1 Geïntegreerde proef Boekhouden - Informatica Lennart Yseboodt Schooljaar2 Woord vooraf Elke 6 de jaars moet een geïntegreerde proef maken, die op he...
Ge¨ıntegreerde proef Boekhouden - Informatica Lennart Yseboodt Schooljaar 2001-2002
Woord vooraf Elke 6de jaars moet een ge¨ıntegreerde proef maken, die op het einde van het jaar moet worden afgegeven. Dit was geen sinecure daar het de eerste keer was dat ik een groot project op lange termijn moest plannen en voorbereiden. Vanaf het begin van het jaar heb ik steeds geprobeerd elke deeltaak tot een goed einde te brengen wat in de meeste gevallen goed gelukt is. Voor informatica heb geprobeert een programma te ontwikkelen dat op een hoger niveau stond dan hetgene wat ons in de cursus aangeboden werd. Mede dankzij Mevr. Jegers die hierin zeer soepel is geweest is dit gelukt. Omdat ik vrijheid van gedachten zeer belangrijk vind, heb ik deze bundel onder de GNU General Free Documentation License1 en het programma zelf onder de GNU General Public License2 geplaatst. De GPL heb ik vertaald naar het Nederlands, deze staat op de GNU website, bij de lijst van vertalingen.
Dankbetuigingen Eerst en vooral zou ik Forest & Bold willen bedanken om mij een schooljaar lang te willen begeleiden als GIP bedrijf. Ook zou ik Dhr Blommaert willen bedanken, die mij steeds van goede raad heeft voorzien tijdens het schooljaar, waardoor het maken van de GIP heel wat aangenamer was. Mvr. Jegers heeft bijzondere prestaties geleverd door zeer soepel te zijn met mijn niet gemakkelijk te verbeteren en soms nukkige GIP. Steven Van Heghe, mijn neef die me altijd steunt. Dhr. Bisschop die ons altijd bereidwillend geholpen heeft. Door het werk van deze personen is deze bundel gerealiseerd : Richard Stallman, oprichter van de FSF die het besturingssysteem GNU3 maakt(e), waaronder dit document geschreven is. 1
http://www.gnu.org/licenses/fdl.txt http://www.gnu.org/licenses/gpl.txt 3 Dit systeem staat ook bekend als (GNU/)Linux 2
i
WOORD VOORAF
ii
Linus Torvalds voor het beginnen van een revolutie. Daniel Robbins voor Gentoo GNU/Linux (en vooral Portage). Donald E Knuth, die de opmaaktaal TEX schreef, dat dit document zijn huidige vorm gaf. Leslie Lamport, voor LATEX , een onmisbaar programma om met TEX te werken. Tobias Oetiker, voor zijn schitterende LATEX 2ε handleiding. Mark Edel, voor NEdit, mijn favoriete editor.
Inleiding Toen ik vorig jaar een GIP bedrijf moest kiezen dacht ik meteen aan Forest & Bold, dat in mijn buurt gevestigd is. Ik heb een afspraak gemaakt en zij waren bereid om mij bij deze taak te helpen, ondanks het feit dat ik voor hun niets kon doen daar zij met Apple computers werken. Ondanks dit heeft Forest & Bold mij het hele jaar altijd zeer stipt en correct geholpen met interviews en documenten, waarvoor mijn dank. Omdat ik van Mevr. Jegers mocht kiezen wat ik dan zou maken, heb ik gekozen om een programma te maken, dat enerzijds zoveel mogelijk aanleunde bij wat we in de les zagen en toch nuttig kon zijn voor een breed publiek. Na wat wikken en wegen heb ik een programma gemaakt voor stockbeheer, uitgewerkt voor hardware onderdelen en facturen voor computerwinkels. Het programma is zo opgesteld dat het met zeer weinig moeite omgevormd kan worden voor andere producten. Het programma heet Sims4 - Stock & Invoice Management System en is bedoeld voor mensen die in een (computer)winkel werken en een gratis5 programma voor stockbeheer willen.
4 5
Er bestaat ook een spel genaamd ’Sims(c)’, beiden hebben niets met elkaar te maken Een correctere term zou ’vrij’ zijn
vii
Deel I GIP Boek
1
Hoofdstuk 1 Forest & Bold Forest & Bold werd in 1992 door Koen Meeuwels opgericht. Het bedrijf is gespecialiseerd in reclamecampagnes voor middelgrote en grote bedrijven. In 1992 besloot Koen Meeuwels om een reclamebureau te starten. Hij renoveerde zijn ouderlijk huis tot kantoorruimte. Het bedrijf is rustig maar vastberaden gegroeid, zowel qua omzet als personeelsbestand. Gemiddeld wordt elk anderhalf jaar iemand aangenomen. Tijdens vakanties kunnen jobstudenten er terecht als grafisch ontwerper. Er werken nu in totaal 7 mensen. Ondanks het feit dat vele jonge of informatica gerichte bedrijven failliet zijn gegaan tijdens de ’.com’ crisis, heeft Forest & Bold hier geen of zeer weinig hinder van ondervonden: dit wijst op gezond management en een goede balans. De omzet bedraagt nu gemiddeld 150.000.000 BEF per jaar met een winstmarge van 12.6%. Naar de toekomst toe ziet men een gestage groei, geen spectaculaire vernieuwingen of veranderingen. Men gaat met de hedendaagse technologie mee zonder zich in gevaarlijke financi¨ele avonturen te storten. Dhr. Huyens (Financieel directeur Forest & Bold) heeft weet van de vereiste documenten en zal deze bezorgen voor januari. Het bleek geen probleem om de balans te mogen inkijken. Het bedrijf gebruikt Mac G4 computers voor al zijn ontwerpen en administratie. Men is nog niet overgeschakeld op Mac OS X, omdat de meest gebruikte pakketten nog niet in Carbon versie beschikbaar zijn. Dit zou de systeemstabiliteit niet ten goede komen, dus men heeft besloten zich voorlopig tot MacOS 9.1 te beperken. Net daarom is het vrij zinloos een programma voor dit bedrijf te schrijven. Ik heb dus een programma geschreven dat van algemeen nut is voor mensen die een hardware winkel uitbaten. Het programma zal de voorraad van tweedehandshands onderdelen bijhouden. Het heeft ook de mogelijkheid een pc samen te stellen, waarna de onderdelen uit de stock verdwijnen, en omgedraaid.
2
Hoofdstuk 2 Boekhoudkundige verwerking van documenten 2.1 2.1.1
Investeringen Fontshop
Zie factuur op pagina 175. Beschrijving APKO +/Bezit stijgt A + Vordering stijgt A + Schuld stijgt P +
I 750000 II 0 III 0 IV 1525000 V -1429258 VI 0 VII 0 VIII 3352441 IX 6616321 X 0 TOTAAL 10814504
4623869 6190636
VA VlA
EV 845742 VVLT 3352441 VVKT 6616321
42.8% 57.2%
VA VlA
EV 7.8% VVLT 31.0% VVKT 61.2% 100%
100%
Zie ook de grafieken op pagina 16.
3.1.2
Liquiditeit
Current ratio 6190636 = 0.93 6616321 Forest & Bold kan indien het al zijn vorderingen onmiddellijk int, en al zijn voorraden onmiddellijk kan verkopen aan de waarde zoals aangeduid in de boekhouding (er zijn geen voorraden), slechts 93% van zijn vorderingen op korte termijn betalen. 8
HOOFDSTUK 3. BALANSANALYSE
9
Quick ratio 6190636 − 0 = 0.93 6616321 Daar er geen voorraden zijn is de Quick ratio identiek aan de current ratio. Thesaurie ratio 6190636 − 5269014 = 0.14 6616321 Indien alle vorderingen niet meer ge¨ınd zouden kunnen worden, en Forest & Bold zijn leveranciers moet betalen met de liquide middelen die het heeft (bank & kas), dan kan slecht 14% van de verschuldigde som aan de leveranciers worden betaald.
3.1.3
Omlooptijden & omloopsnelheden
Voorraadrotatie 8534334 =/ (0 + 0)/2 Daar dit een dienstenverlenend bedrijf is, en geen voorraden heeft, kan de voorraadrotatie niet berekend worden. Hetzelfde geldt voor de omlooptijden van de voorraad. Klantenrotatie Brutowinst In de balans staat:
7794333 Omzet Aankopen
12905369 -5111036
Men trekt hier een aantal aankopen van de omzet af, ik ben echter van mening dat deze net zo goed opbrengsten zijn, dus ik neem 12905369 als (70-74) opbrengstencijfer. 12905369 5261659+2338210 2·1.21
= 4.11
De noemer is het gemiddelde van de handelsvorderingen van de boekjaren 2000 en 1999. Dit betekent dat er gemiddeld in een boekjaar 4.11 keer alle vorderingen ge¨ınd worden.
HOOFDSTUK 3. BALANSANALYSE
10
Omlooptijd klanten 365 = 88.8 4.11 Forest & Bold kent een gemiddeld betalingsuitstel van 89 dagen toe. Gezien hun zeer lage current ratio zou het aan te raden zijn om een strikter betalingsbeleid te gaan voeren of met discontokrediet te gaan werken. Als men discontokrediet gebruikt, dan draagt de bank het risico van de vordering en stijgen de liquide middelen en aldus ook de liquiditeitsratio’s. Leveranciersrotatie 5111036 + 5124237 6616321+6926331 2·1.21
= 1.83
Forest & Bold betaalt bijna 2 keer per jaar de schulden aan de leveranciers. Omlooptijden leveranciers 365 = 199.45 1.83
Forest & Bold krijgt een gemiddeld betalingsuitstel van 6.5 maanden. Vergelijking omlooptijden Als men de omlooptijden van klanten & leveranciers bekijkt lijkt er geen vuiltje aan de lucht de zijn. De klanten betalen bijna 3x zo snel als zij de leveranciers moeten betalen: kijkt men echter naar de verhouding tussen de vorderingen en de schulden,dan ziet men een ander beeld. De gemiddelde schuld (1999-2000) was 1.7 keer groter dan de gemiddelde vordering. Als men de evolutie van 1999 naar 2000 bekijkt is het positiever: de vorderingen verdubbelen bijna (x1.86). Daar Forest & Bold hoofdzakelijk bedrijven als klant heeft is de kans op dubieuze debiteuren minder groot dan bij hoofdzakelijk particuliere klanten. Zie ook de grafieken BA3 en BA4 op pagina 17.
HOOFDSTUK 3. BALANSANALYSE
3.1.4
11
Solvabiliteit
Schuldgraad 9968762 = 0.922 10814504 Meer dan 92% van het totaal vermogen wordt uitgemaakt door schulden, de norm is hier 50%. De reden dat Forest & Bold zo diep in de schulden zit is omdat het een zeer jong bedrijf is dat een trage groei kent. Ook zit het in een branche waar de concurrentie moordend is en de winstmarges relatief laag. Financi¨ ele zelfstandigheid 1 − 0.922 = 0.078 Forest & Bold is voor 7.8% financi¨eel zelfstandig. Conclusie In 2000 bestond Forest & Bold nog maar 6 jaar en hadden dus nog niet echt grote naam gemaakt, hun schuldgraad is met +- 90% zeer hoog. Dit is echter niet ongewoon voor jonge bedrijven of bedrijven die in een nieuwe branche naam moeten maken.
3.1.5
Rentabiliteit
Rentabiliteit op het eigen vermogen −649421 = −0.76 845742 Forest & Bold maken een verlies van 76% op hun eigen vermogen. Dit hoge cijfer valt mede te verklaren door het feit dat hun eigen vermogen slechts 10% van het totaal vermogen bedraagt. Rentabiliteit op het totaal vermogen −648671 + 175394 = −0.043 10814504 Omdat het vreemd vermogen meer dan 90% van het passiva vertegenwoordigt is het logisch dat deze waarde lager ligt dan de rentabiliteit op het eigen vermogen. Ook hier maakt Forest & Bold verlies, en dit zelfs zonder rekening te houden met het verlies dat nog overgedragen moet worden.
I 750000 II 0 III 0 IV 1525000 V -870075 VI 0 VII 0 VIII 2155725 IX 8378023 X 12544 TOTAAL 10814504
4091338 7859879
VA VlA
EV 1404925 VVLT 2155725 VVKT 8390567
34.2% 65.8%
VA VlA
EV 11.8% VVLT 18.0% VVKT 70.2% 100%
100%
Zie ook de grafieken op pagina 16
3.2.2
Liquiditeit
Current ratio 7859879 = 0.93 8390567
Deze ratio is hetzelfde gebleven in vergelijking met vorig jaar. Hij zou nog iets omhoog moeten om de norm 1 te halen. Quick ratio Daar er geen voorraden zijn is deze ratio dezelfde als de Current ratio. Thesaurie ratio 3174465 = 0.37 830567
Een zeer sterke stijging van het thesaurie ratio tegenover het vorige jaar, te verklaren door veel grotere geldvoorraad. Dit stelt hen in staat om onmiddellijk, zonder klanten om te zetten in geld, 37% van de leveranciersschuld te betalen.
HOOFDSTUK 3. BALANSANALYSE
13
Vergelijking ratio’s Current : De current ratio is van 1999 naar 2000 sterk gestegen door een toename in handelsdebiteuren, deze is constant gebleven van 2000 naar 2001 ondanks dat de thesaurie ratio wel gestegen is. Thesaurie : De thesaurie ratio daalt lichtjes van 1999 naar 2000 omdat de geldvoorraden slinken, echter deze stijgen substantieel van 2000 naar 2001 zonder dat de current ratio daalt! Dwz dat als x klanten betaald hebben ze er nog eens x bijgekregen hebben. Deze ratio gaat de goede kant op en zal hopelijk snel de norm van 75% halen. Zie ook de grafiek BA5 op pagina 18
3.2.3
Omlooptijden & omloopsnelheden
Voorraadrotatie Daar er geen voorraad is kan deze omloopsnelheid niet berekend worden. Hetzelfde geldt voor de omlooptijd van de voorraad. Klantenrotatie 18058523 4530929+5261659 2·1.21
= 4.46
Een lichte stijging tegenover 2000, om hun liquiditeit op te krikken heeft Forest & Bold blijkbaar een strikter betalingsbeleid gevoerd of een aantal klanten heeft sneller betaald. De omzet is met 40% gestegen, dit jaar wordt er ook voor het eerst winst gemaakt (in de periode 1999-2001). Omlooptijd klanten 365 = 81.83 4.46
De klanten krijgen nu een gemiddeld betalingsuitstel van 80 dagen, dit zou nog iets verder omlaag gebracht kunnen worden om de schuldgraad te verbeteren.
Waarschijnlijk door de snellere klantenrotatie heeft Forest & Bold beslist om hun leveranciers iets sneller te betalen, dit resulteert in een stijging van 14% rotatiesnelheid. Het sneller betalen van de leveranciers is gunstig voor het rendement (EV). Omlooptijden leveranciers 365 = 211 1.73
Gemiddeld worden nu om de 7 maanden alle leveranciers uitbetaald.
3.2.4
Solvabiliteit
Schuldgraad 10546292 = 0.88 = 88% 11951217
Forest & Bold’s Passiva is voor 88% vreemd vermogen, schulden dus. Dit valt te verklaren doordat het een jong bedrijf is dat door zware concurrentie met verlies loopt. Financi¨ ele zelfstandigheid 1404925 = 0.12 = 12% 11951217 Conclusie Net zoals bij het thesaurie ratio neemt in 2000 de financi¨ele zelfstandigheid een dip, dit kan misschien verklaard worden door de .com & Y2k crisis die het vertrouwen in een reclamebureau enigszins kunnen doen dalen. Zie ook de grafiek op pagina 18.
HOOFDSTUK 3. BALANSANALYSE
3.2.5
15
Rentabiliteit
Rentabiliteit op het eigen vermogen 559183 = 0.4 1404925
Forest & Bold heeft een rendement van 40% op het eigen vermogen, echter het eigen vermogen geeft nogal extreme getallen omdat de schuldgraad enorm hoog ligt. Rentabiliteit op het totaal vermogen 560133 + 251868 = 0.07 11951217
Een zeer laag rentabiliteit ratio, maar toch een kleine maar positieve verbetering tegenover 2000, dat niet echt een goed jaar was.
3.3
Conclusie
Forest & Bold voldoet niet aan de hoofdfinancieringsregel want ze hebben 4.4% van hun Vast actief gekocht met vreemd vermogen op korte termijn: VA>EV+VVLT Ze zullen hiervoor een krediet bij de bank moeten aanvragen, of het betalen met liquide middelen. Dit is goed mogelijk aangezien ze zeer veel geldvoorraad hebben. Ze voldoen ook niet aan de liquiditeitsregel, maw, Forest & Bold is overliquide. Dit komt door een massale hoeveelheid aan handelsdebiteurs. Ook aan de solvabiliteitsregel wordt niet voldaan, het VVKT is 4.4% groter dan alle liquide middelen waar ook dubieuze debiteuren in kunnen zitten. Al met al zijn er geen grote rampen te zien op deze balans, Forest & Bold zit diep in de schulden en kan net het hoofd boven water houden, maar ze maken winst en van zodra ze alle overgedragen verliezen hebben goedgemaakt kan dit bedrijf flink beginnen te renderen.
HOOFDSTUK 3. BALANSANALYSE EDNOTE: Replace by BA1 & BA2
16
HOOFDSTUK 3. BALANSANALYSE EDNOTE: Peplace by BA3 & BA4
17
HOOFDSTUK 3. BALANSANALYSE EDNOTE : Replace by BA5 & BA6
18
Hoofdstuk 4 Sims 0.2 4.1
API0 (module)
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : API0.bas * ’* OBJECT : API0 * ’* DESCRIPTION : Function definitions of Windows GDI API calls * ’* * ’********************************************************************************** Public Public Public Public
Public Const HWND_NOTOPMOST = -2 Declare Function SetWindowPos Lib "user32" _ (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal cx As Long, _ ByVal cy As Long, _ ByVal wFlags As Long) As Long ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : SetTopMostWindow * ’* SCOPE : Public * ’* DESCRIPTION : Make windows Always on Top * ’********************************************************* Public Function SetTopMostWindow(F As Form, Topmost As Boolean) As Long SyS.DBG.enterFunction "API{SetTopMostWindow}" If Topmost = True Then ’Make the window topmost SetTopMostWindow = SetWindowPos(F.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS) Else SetTopMostWindow = SetWindowPos(F.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS) ’SetTopMostWindow = False End If SyS.DBG.leaveFunction "API{SetTopMostWindow}" End Function
HOOFDSTUK 4. SIMS 0.2
4.2
21
CFG CLASS (class)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : CFG_CLASS.cls * ’* OBJECT : CFG_CLASS * ’* DESCRIPTION : Manages the configuration file * ’* * ’********************************************************************************** ’ Private vars Private Const C_INPUT As Integer = 0 Private Const C_OUTPUT As Integer = 1 Private fn As Integer ’ Public vars Public loadSucces As Boolean
HOOFDSTUK 4. SIMS 0.2 Private Sub Class_Initialize() SyS.DBG.enterFunction "Class_Initialise" Dim fo As Boolean SyS.DBG.makeLogEntry "Loading config..." fn = FreeFile fo = openConfig(C_INPUT) If fo = False Then loadSucces = False SyS.DBG.makeLogEntry "ERROR- Config file couldn’t be read" SyS.DBG.leaveFunction "Class_Initialize (indirect)" Exit Sub End If loadSucces = True ’ Loaded OK loadConfig SyS.DBG.leaveFunction "Class_Initialise" End Sub ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : openConfig * ’* SCOPE : Private * ’* DESCRIPTION : Opens the configuration file * ’********************************************************* Private Function openConfig(mode As Integer) As Boolean SyS.DBG.enterFunction "openConfig" On Error GoTo badConfigOpen If mode = C_INPUT Then Open App.Path & "\config.cfg" For Input As fn ElseIf mode = C_OUTPUT Then Open App.Path & "\config.cfg" For Output As fn End If openConfig = True SyS.DBG.leaveFunction "openConfig" Exit Function
22
HOOFDSTUK 4. SIMS 0.2
23
badConfigOpen: SyS.DBG.enterFunction "openConfig-badConfigOpen" openConfig = False SyS.DBG.makeLogEntry "Config /open failed, type " & _ IIf(mode = 0, "INPUT", "OUPUT") SyS.DBG.makeLogEntry "Reason : " & Err.Description & _ " (" & Str(Err.Number) & ")" SyS.DBG.leaveFunction "openConfig-badConfigOpen" SyS.DBG.leaveFunction "openConfig (indirect)" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : loadConfig * ’* SCOPE : Private * ’* DESCRIPTION : Loads config in global * ’* SyS.Config.* * ’********************************************************* Private Function loadConfig() SyS.DBG.enterFunction "loadConfig" Dim l As String Dim CMD As String, ARG As String Dim ipos As Integer setDefaultConfig Do While Not (EOF(fn)) Input #fn, l l = Trim(l) If Not (Left(l, 1) = "#" Or InStr(1, l, "=") <= 1) Then SyS.DBG.makeLogEntry "Found value :" & l ipos = InStr(1, l, "=") CMD = Left(l, ipos - 1) ARG = Right(l, Len(l) - (ipos)) SyS.DBG.makeLogEntry "CMD: " & CMD SyS.DBG.makeLogEntry "ARG: " & ARG processCA CMD, ARG Else If Not (l = "" Or Left(l, 1) = "#") _ Then SyS.DBG.makeLogEntry "Comment/Invalid statement ignored : " & l End If
HOOFDSTUK 4. SIMS 0.2 Loop SyS.DBG.makeLogEntry "Closing I/Config file" Close #fn SyS.DBG.leaveFunction "loadConfig" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : processCA * ’* SCOPE : private * ’* DESCRIPTION : Processes settings * ’********************************************************* Private Function processCA(CMD As String, ARG As String) SyS.DBG.enterFunction "processCA" Select Case LCase(CMD) Case "caption" SyS.Config.appCaption = ARG Case "database" SyS.Config.dbaseFileName = ARG Case "showpartonboot" SyS.Config.bShowPart = IIf(LCase(ARG) = "false", False, True) Case "showcustomersonboot" SyS.Config.bShowCust = IIf(LCase(ARG) = "false", False, True) Case "showpcsonboot" SyS.Config.bShowPC = IIf(LCase(ARG) = "false", False, True) Case "showinvoiceonboot" SyS.Config.bShowInvoice = IIf(LCase(ARG) = "false", False, True) Case "fieldNA" SyS.Config.emptyString = ARG Case "defaultCurrency" SyS.Config.defCurrency = ARG Case Else SyS.DBG.makeLogEntry "Invalid entry : " & CMD & ":" & ARG
24
HOOFDSTUK 4. SIMS 0.2 End Select SyS.DBG.leaveFunction "processCA" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : setDefaultConfig * ’* SCOPE : Private * ’* DESCRIPTION : Sets default values * ’********************************************************* Private Function setDefaultConfig() SyS.DBG.enterFunction "setDefaultConfig" With SyS.Config .appCaption = "Unconfigered" .dbaseFileName = App.Path & "\core.mdb" .bShowCust = False .bShowPart = False .bShowPC = False .bShowInvoice = False .emptyString = "NONE" .defCurrency = "EUR" End With SyS.DBG.leaveFunction "setDefaultConfig" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : saveConfig * ’* SCOPE : Private * ’* DESCRIPTION : function that saves the conf * ’********************************************************* Private Function saveConfig() SyS.DBG.enterFunction "saveConfig" If loadSucces = False Then setDefaultConfig ’ If no config found we want a valid one :) << obs ? no! Print #fn, "# Sims 0.1" Print #fn, "# Configuration file: see the manual for details." Print #fn, "# Sims falls under the GNU Public License." & vbCrLf
HOOFDSTUK 4. SIMS 0.2 End If SyS.DBG.leaveFunction "Class_Terminate" End Sub
27
HOOFDSTUK 4. SIMS 0.2
4.3
28
Customers ADDEDF (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : Customers_ADDEDF.bas * ’* OBJECT : Customers_ADDEDF * ’* DESCRIPTION : Provides functions for Customers_ADDEDEV (& validations) * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Cust_fillFields(UIN) * ’* SCOPE : Public * ’* DESCRIPTION : Fills the txtFields * ’********************************************************* Public Function Cust_fillFields(UIN As Long) SyS.DBG.enterFunction "Cust_fillFields" SyS.DBS.Customer_PEEK (UIN) With SyS.DbBuf.Customer SyS.FRM.Customers_ADDED.txtCity = .City SyS.FRM.Customers_ADDED.txtEmail = .EMail SyS.FRM.Customers_ADDED.txtFax = .Fax
HOOFDSTUK 4. SIMS 0.2 SyS.FRM.Customers_ADDED.txtFirstName = .Surname SyS.FRM.Customers_ADDED.txtName = .Name SyS.FRM.Customers_ADDED.txtPCode = .Postnumber SyS.FRM.Customers_ADDED.txtPhone = .Phone SyS.FRM.Customers_ADDED.txtStreet = .Adress End With SyS.DBG.leaveFunction "Cust_fillFields" End Function
29
HOOFDSTUK 4. SIMS 0.2
4.4
30
Customers ADDEDEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : Customers_ADDEDEV.bas * ’* OBJECT : Customers_ADDEDEV * ’* DESCRIPTION : Event handler for Sys.FRM.Customers_ADDED * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : CustomersADDED_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads the form * ’********************************************************* Public Function CustomersADDED_Load() SyS.DBG.enterFunction "CustomersADD_Load" SyS.FRM.Customers_ADDED.Show SyS.SysBuf.Cust_saveOK = True ’ WARNING << FOR DEBUGGING ONLY !!! ’^^ obsolete by locking ?? If SyS.SysBuf.Cust_AddEdit > -1 Then SyS.FRM.Customers_ADDED.Caption = "Edit " & _ SyS.iOBJ.Cust_LV.ListItems(curSelLV _
HOOFDSTUK 4. SIMS 0.2 (SyS.iOBJ.Cust_LV)).SubItems(1) & _ " " & SyS.iOBJ.Cust_LV.ListItems(curSelLV(SyS.iOBJ.Cust_LV)).Text SyS.FRM.Customers_ADDED.cmdAdd.Caption = "Change" ’Cust_fillFields (CLng(SyS.iOBJ.Cust_LV. _ ListItems(curSelLV(SyS.iOBJ.Cust_LV)).Tag)) Cust_fillFields (SyS.SysBuf.Cust_AddEdit_UIN) SyS.FRM.Customers_ADDED.chkCAdd.Value = 2 SyS.FRM.Customers_ADDED.chkCAdd.enabled = False SyS.FRM.Customers_ADDED.chkClAdd.Value = 2 SyS.FRM.Customers_ADDED.chkClAdd.enabled = False End If SetTopMostWindow SyS.FRM.Customers_ADDED, True SyS.lOBJ.Customers_ADDED = True SyS.DBG.leaveFunction "Customers_ADDED_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : CustomersADDED_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads the form * ’********************************************************* Public Function CustomersADDED_QUnload() SyS.DBG.enterFunction "Customers_QUnload" SyS.FRM.Customers.cmdAdd.enabled = True SyS.lOBJ.Customers_ADDED = False SyS.DBG.leaveFunction "Customers_QUnload" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : CustomersAddED_Cancel_Click * ’* SCOPE : Public * ’* DESCRIPTION : Cancels the operation * ’********************************************************* Public Function CustomersAddED_Cancel_Click() SyS.DBG.enterFunction "Customers_ADDED_Cancel_Click"
31
HOOFDSTUK 4. SIMS 0.2
Unload SyS.FRM.Customers_ADDED SyS.DBG.leaveFunction "Customers_ADDED_Cancel_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : CustomersAddED_Add_Click * ’* SCOPE : Public * ’* DESCRIPTION : Adds the record * ’********************************************************* Public Function CustomersAddED_Add_Click() SyS.DBG.enterFunction "CustomersAddED_Add_Click" Dim Tobj As Object If SyS.SysBuf.Cust_saveOK Then SyS.DBS.Customer_PEEK (SyS.SysBuf.Cust_AddEdit_UIN) With SyS.DbBuf.Customer .Adress = frmCustomers_ADDED.txtStreet If Not SyS.SysBuf.Cust_AddEdit = -1 Then .Date = Now .EMail = frmCustomers_ADDED.txtEmail .Fax = frmCustomers_ADDED.txtFax .City = frmCustomers_ADDED.txtCity .Customer_UIN = 0 ’?? .Name = frmCustomers_ADDED.txtName .Postnumber = frmCustomers_ADDED.txtPCode .Phone = frmCustomers_ADDED.txtPhone .Surname = frmCustomers_ADDED.txtFirstName End With If SyS.SysBuf.Cust_AddEdit = -1 Then SyS.DBS.Customer_POKE If SyS.FRM.Customers_ADDED.chkCAdd.Value = 1 Then CustomersAddED_Cancel_Click Else If SyS.FRM.Customers_ADDED.chkClAdd.Value = 1 Then For Each Tobj In SyS.FRM.Customers_ADDED If TypeName(Tobj) = "TextBox" Then Tobj.Text = "" End If
32
HOOFDSTUK 4. SIMS 0.2 Next Tobj End If End If Else SyS.DBS.Customer_EDIT (SyS.SysBuf.Cust_AddEdit_UIN) CustomersAddED_Cancel_Click End If Customers_fillList Else SyS.DBG.makeLogEntry "Badsave" End If SyS.DBG.leaveFunction "CustomersAddED_Add_Click" End Function
33
HOOFDSTUK 4. SIMS 0.2
4.5
34
CustomersEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : CustomersEV.bas * ’* OBJECT : CustomersEV * ’* DESCRIPTION : Event handler for Sys.FRM.Customers * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_Load * ’* SCOPE : Public * ’* DESCRIPTION : Load sys.frm.Customers * ’********************************************************* Public Function Customers_Load() SyS.DBG.enterFunction "Customers_Load" SyS.FRM.Main.mnuCustomers.Checked = True SyS.FRM.Customers.Show 0 SyS.Config.bShowCust = True SyS.FRM.Customers.LV.Left = PixelsToTwipsX(4) SyS.DBG.makeLogEntry "Ok marker" SyS.iOBJ.Cust_SBar.Panels.Clear
HOOFDSTUK 4. SIMS 0.2
35
SyS.iOBJ.Cust_SBar.Panels.Add 1, "P1", "Recordcount : " & SyS.DBS.numCustomers SyS.iOBJ.Cust_SBar.Panels(1).Width = SyS.iOBJ.Cust_SBar.Panels(1).Width + 300 SyS.iOBJ.Cust_SBar.Panels.Add 2, "P2", "Results found : (no search)" SyS.iOBJ.Cust_SBar.Panels(2).Width = SyS.iOBJ.Cust_SBar.Panels(2).Width + 800 Customers_setList doUpdate Customers_fillList SyS.iOBJ.Cust_CBar.Bands.Add 1, "std", , , , frmCustomers.cbHolderSTD SyS.iOBJ.Cust_CBar.Bands.Add 2, "search", , , True, frmCustomers.cbHolderSRC SyS.lOBJ.Customers = True SyS.DBG.leaveFunction "Customers_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : UnLoad sys.frm.Customers * ’********************************************************* Public Function Customers_QUnload() SyS.DBG.enterFunction "Customers_QUnload" SyS.FRM.Main.mnuCustomers.Checked = False SyS.Config.bShowCust = False SyS.lOBJ.Customers = False SyS.DBG.leaveFunction "Customers_QUnload" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_Resize * ’* SCOPE : Public * ’* DESCRIPTION : Adjusts contents to size * ’********************************************************* Public Function Customers_Resize() ’ Explicit no debug entry (flood)
’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_cBar_Resize * ’* SCOPE : Public * ’* DESCRIPTION : Adjust LV to cBar * ’********************************************************* Public Function Customers_cBar_Resize() SyS.DBG.enterFunction "Customers_cBar_Resize" STDW_CRF SyS.FRM.Customers, SyS.iOBJ.Cust_LV, SyS.iOBJ.Cust_CBar, _ SyS.iOBJ.Cust_SBar SyS.DBG.leaveFunction "Customers_cBar_Resize" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_cmdAdd_Click * ’* SCOPE : Public * ’* DESCRIPTION : Event Add record * ’********************************************************* Public Function Customers_cmdAdd_Click() SyS.DBG.enterFunction "Customers_cmdAdd_Click" SyS.FRM.Customers.cmdAdd.enabled = False SyS.SysBuf.Cust_AddEdit = -1 ’ New customer Load SyS.FRM.Customers_ADDED SyS.DBG.leaveFunction "Customers_cmdAdd_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_cmdDel_Click * ’* SCOPE : Public * ’* DESCRIPTION : Event delete record button * ’*********************************************************
HOOFDSTUK 4. SIMS 0.2
37
Public Function Customers_cmdDel_Click() SyS.DBG.enterFunction "Customers_cmdDel_Click" Dim c As Integer c = curSelLV(SyS.iOBJ.Cust_LV) SyS.DBG.makeLogEntry "DelNLV=" & c If Not c = -1 Then SyS.DBS.Customer_DEL (SyS.iOBJ.Cust_LV.ListItems(c).Tag) Customers_fillList
_
SyS.DBG.leaveFunction "Customers_cmdDel_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_cmdEdit_Click * ’* SCOPE : Public * ’* DESCRIPTION : Event to change record * ’********************************************************* Public Function Customers_cmdEdit_Click() SyS.DBG.enterFunction "Customers_cmdEdit_Click" If SyS.iOBJ.Cust_LV.ListItems.Count = 0 Then Exit Function SyS.SysBuf.Cust_AddEdit = curSelLV(SyS.iOBJ.Cust_LV) SyS.SysBuf.Cust_AddEdit_UIN = SyS.iOBJ.Cust_LV.ListItems _ (SyS.SysBuf.Cust_AddEdit).Tag Load SyS.FRM.Customers_ADDED SyS.DBG.leaveFunction "Customers_cmdEdit_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_cmdSearch_Click * ’* SCOPE : Public * ’* DESCRIPTION : Quick search * ’********************************************************* Public Function Customers_cmdSearch_Click() SyS.DBG.enterFunction "Customers_cmdSearch_Click"
HOOFDSTUK 4. SIMS 0.2 If SyS.FRM.Customers.chkInRes.Value = 0 Then Customers_fillList Customers_QSearch (SyS.FRM.Customers.txtSearch.Text) SyS.DBG.leaveFunction "Customers_cmdSearch_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_ShowAll_Click * ’* SCOPE : Public * ’* DESCRIPTION : Refreshes the list no search * ’********************************************************* Public Function Customers_ShowAll_Click() SyS.DBG.enterFunction "Customers_ShowAll_Click" Customers_fillList SyS.DBG.leaveFunction "Customers_ShowAll_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : iOBJ_Cust_LV_Column_Click * ’* SCOPE : Public * ’* DESCRIPTION : Resorts the columns * ’********************************************************* Public Function iOBJ_Cust_LV_Column_Click(columnIndex As Integer) SyS.DBG.enterFunction "iOBJ_Cust_LV_Column_Click" SyS.iOBJ.Cust_LV.SortKey = columnIndex - 1 SyS.iOBJ.Cust_LV.Sorted = True SyS.DBG.leaveFunction "iOBJ_Cust_LV_Column_Click" End Function
38
HOOFDSTUK 4. SIMS 0.2
4.6
39
CustomersF (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : CustomersF.bas * ’* OBJECT : CustomersF * ’* DESCRIPTION : Provides functions for frmCustomers * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_fillList * ’* SCOPE : Public * ’* DESCRIPTION : Fills the LV * ’********************************************************* Public Function Customers_fillList() SyS.DBG.enterFunction "Customers_FillList" Dim c As Long Dim LV As ListView Set LV = SyS.FRM.Customers.LV LV.ListItems.Clear For c = 1 To SyS.DBS.numCustomers
HOOFDSTUK 4. SIMS 0.2
SyS.DBS.clearBuf SyS.DBS.Customer_PEEK , c ’SyS.DBG.makeLogEntry "Got klant ’" & Str(c) & "’" LV.ListItems.Add c, , SyS.DbBuf.Customer.Name ’ Primary item LV.ListItems(c).Tag = SyS.DbBuf.Customer.Customer_UIN ’ Tuck away UIN With LV.ListItems(c) .SubItems(1) = SyS.DbBuf.Customer.Surname .SubItems(2) = SyS.DbBuf.Customer.Adress .SubItems(3) = SyS.DbBuf.Customer.City .SubItems(4) = SyS.DbBuf.Customer.Postnumber .SubItems(5) = SyS.DbBuf.Customer.Fax .SubItems(6) = SyS.DbBuf.Customer.Phone .SubItems(7) = SyS.DbBuf.Customer.EMail .SubItems(8) = SyS.DbBuf.Customer.Date End With Next c SyS.iOBJ.Cust_SBar.Panels(1).Text = "Recordcount : " & SyS.DBS.numCustomers SyS.iOBJ.Cust_SBar.Panels(2).Text = "Results found : (no search)" SyS.DBG.leaveFunction "Customers_FillList" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_setList * ’* SCOPE : Public * ’* DESCRIPTION : Sets the LV * ’********************************************************* Public Function Customers_setList() SyS.DBG.enterFunction "Customers_setList" Dim LV As ListView Set LV = SyS.FRM.Customers.LV LV.ListItems.Clear LV.ColumnHeaders.Clear LV.View = 3 LV.ColumnHeaders.Add 1, "Naam", "Name" LV.ColumnHeaders.Add 2, "Voornaam", "First name"
SyS.DBG.leaveFunction "Customers_setList" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customers_QSearch * ’* SCOPE : Public * ’* DESCRIPTION : Quicksearches the LV * ’********************************************************* Public Function Customers_QSearch(SearchTerm As String) SyS.DBG.enterFunction "Custumors_QSearch" Dim x As Long, y As Long Dim doDel As Boolean x = 1: doDel = True SyS.DBG.makeLogEntry "QSearch : LC=" & SyS.iOBJ.Cust_LV.ListItems.Count Do While x <= SyS.iOBJ.Cust_LV.ListItems.Count If InStr(SyS.iOBJ.Cust_LV.ListItems(x).Text, SearchTerm) >= 1 Then doDel = False For y = 1 To 8
_
If InStr(SyS.iOBJ.Cust_LV.ListItems(x).SubItems(y), SearchTerm) _ >= 1 Then doDel = False Next y If doDel = True Then SyS.iOBJ.Cust_LV.ListItems.Remove x If doDel = False Then x = x + 1 doDel = True End If Loop
HOOFDSTUK 4. SIMS 0.2
SyS.iOBJ.Cust_SBar.Panels(2).Text = "Results found : " & _ SyS.iOBJ.Cust_LV.ListItems.Count SyS.DBG.leaveFunction "Custumors_QSearch" End Function
42
HOOFDSTUK 4. SIMS 0.2
4.7
43
DBG CLASS (class)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : DBG_CLASS.cls * ’* OBJECT : DBG_CLASS * ’* DESCRIPTION : Provides debugging services * ’* * ’********************************************************************************** ’ Private variables Private Private Private Private
fn As Integer ’Filenumber filename As String ns As Integer ’Number of spc() to print Const spacing As Integer = 5
’public variables Public loadSucces As Boolean Public enabled As Boolean ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Class_Initialize * ’* SCOPE : Private * ’* DESCRIPTION : CONSTRUCTOR * ’*********************************************************
HOOFDSTUK 4. SIMS 0.2
Private Sub Class_Initialize() On Error GoTo badInit Dim T As String fn = FreeFile ns = 0 T = IIf(Right(App.Path, 1) = "\", "DEBUG ", "\DEBUG ") filename = App.Path & T & Format(Now, "yymmdd - HhNn ") If Dir(filename & ".DBG") <> "" Then Do filename = filename & "X" Loop Until Dir(filename & ".DBG") = "" End If filename = filename & ".DBG" Open filename For Output As fn writeHeader loadSucces = True enabled = True Exit Sub badInit: loadSucces = False End Sub ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : writeHeader * ’* SCOPE : Private * ’* DESCRIPTION : Writes file header * ’********************************************************* Private Function writeHeader() Print #fn, "Sims 0.1 - DEBUG FILE" Print #fn, "=====================" & vbCr Print #fn, "Logging started : " & Format(Now, "dddddd ttttt") & vbCr
44
HOOFDSTUK 4. SIMS 0.2
45
DoEvents End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Class_Terminate * ’* SCOPE : Private * ’* DESCRIPTION : DESTRUCTOR * ’********************************************************* Private Sub Class_Terminate() Close fn DoEvents End Sub ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : enterFunction * ’* SCOPE : Public * ’* DESCRIPTION : Called when entering f() * ’********************************************************* Public Function enterFunction(fname As String) If enabled = False Then Exit Function Print #fn, writeTime Print #fn, dFill(ns); "[[[ ns = ns + spacing ’Print #fn, DoEvents
" & fname & "
[[["
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : writeTime * ’* SCOPE : Private * ’* DESCRIPTION : Called before logentry * ’********************************************************* Private Function writeTime() If enabled = False Then Exit Function
HOOFDSTUK 4. SIMS 0.2
46
Print #fn, "(" & Format(Now, "HhNnSs") & ")" & vbTab; DoEvents End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : leaveFunction * ’* SCOPE : Public * ’* DESCRIPTION : Called when leaving f() * ’********************************************************* Public Function leaveFunction(fname As String) If enabled = False Then Exit Function writeTime ns = ns - spacing Print #fn, dFill(ns); "]]] Print #fn,
" & fname & "
]]]"
DoEvents
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : makeLogEntry * ’* SCOPE : Public * ’* DESCRIPTION : For debugging messages * ’********************************************************* Public Function makeLogEntry(message As String) If enabled = False Then Exit Function writeTime Print #fn, dFill(ns); message DoEvents End Function
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : dFill * ’* SCOPE : Private * ’* DESCRIPTION : For filling regions * ’********************************************************* Private Function dFill(n As Integer) Dim c As Integer For c = 1 To n dFill = dFill & "~" Next c End Function
47
HOOFDSTUK 4. SIMS 0.2
4.8
48
DBS CLASS (class)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : DBS_CLASS.cls * ’* OBJECT : DBS_CLASS * ’* DESCRIPTION : This class is a highlevel API for the Database * ’* * ’********************************************************************************** ’ Private variables Private RCRDS As RCRDS_TP Private DB As Database ’ Public variables Public loadSucces As Boolean ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : initDB * ’* SCOPE : Private * ’* DESCRIPTION : Inits LOCKED/STATUS’s * ’********************************************************* Private Function initDB()
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.enterFunction "initDB" ’ NOTE: rewrite this function using an array of pointers, ’ = nested 2x for to clear it all. ESTH +4 If Not RCRDS.Customers.RecordCount = 0 Then RCRDS.Customers.MoveFirst Do Until RCRDS.Customers.EOF RCRDS.Customers.Edit RCRDS.Customers.Fields("LOCKED") = 0 RCRDS.Customers.Update RCRDS.Customers.MoveNext Loop End If If Not RCRDS.Parts.RecordCount = 0 Then RCRDS.Parts.MoveFirst Do Until RCRDS.Parts.EOF RCRDS.Parts.Edit RCRDS.Parts.Fields("LOCKED") = 0 RCRDS.Parts.Fields("WQ") = RCRDS.Parts.Fields("Quantity") ’OMFG RCRDS.Parts.Update RCRDS.Parts.MoveNext Loop End If If Not RCRDS.Invoices.RecordCount = 0 Then RCRDS.Invoices.MoveFirst Do Until RCRDS.Invoices.EOF RCRDS.Invoices.Edit RCRDS.Invoices.Fields("LOCKED") = 0 RCRDS.Invoices.Update RCRDS.Invoices.MoveNext Loop End If If Not RCRDS.PART_IV.RecordCount = 0 Then RCRDS.PART_IV.MoveFirst Do Until RCRDS.PART_IV.EOF RCRDS.PART_IV.Edit RCRDS.PART_IV.Fields("LOCKED") = 0 RCRDS.PART_IV.Update RCRDS.PART_IV.MoveNext Loop End If If Not RCRDS.Part_Pc.RecordCount = 0 Then RCRDS.Part_Pc.MoveFirst Do Until RCRDS.Part_Pc.EOF
49
HOOFDSTUK 4. SIMS 0.2 RCRDS.Part_Pc.Edit RCRDS.Part_Pc.Fields("LOCKED") = 0 RCRDS.Part_Pc.Update RCRDS.Part_Pc.MoveNext Loop End If If Not RCRDS.Part_type.RecordCount = 0 Then RCRDS.Part_type.MoveFirst Do Until RCRDS.Part_type.EOF RCRDS.Part_type.Edit RCRDS.Part_type.Fields("LOCKED") = 0 RCRDS.Part_type.Update RCRDS.Part_type.MoveNext Loop End If If Not RCRDS.Pc.RecordCount = 0 Then RCRDS.Pc.MoveFirst Do Until RCRDS.Pc.EOF RCRDS.Pc.Edit RCRDS.Pc.Fields("LOCKED") = 0 RCRDS.Pc.Update RCRDS.Pc.MoveNext Loop End If If Not RCRDS.PC_IV.RecordCount = 0 Then RCRDS.PC_IV.MoveFirst Do Until RCRDS.PC_IV.EOF RCRDS.PC_IV.Edit RCRDS.PC_IV.Fields("LOCKED") = 0 RCRDS.PC_IV.Update RCRDS.PC_IV.MoveNext Loop End If SyS.DBG.leaveFunction "initDB" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Class_Initialize * ’* SCOPE : Private * ’* DESCRIPTION : CONSTRUCTOR * ’********************************************************* Private Sub Class_Initialize()
50
HOOFDSTUK 4. SIMS 0.2
SyS.DBG.enterFunction "Class_Initialize (DBS)" On Error GoTo loadError Set Set Set Set Set Set Set Set Set
initDB ’ Reset Locked/Status loadSucces = True SyS.DBG.leaveFunction "Class_Initialize (DBS)" Exit Sub loadError: SyS.DBG.enterFunction "Class_Initialize (DBS)_loadError:" loadSucces = False Set DB = Nothing SyS.DBG.makeLogEntry "Err:" & Err.Description & " (" & Err.Number & ")" SyS.DBG.leaveFunction "Class_Initialize (DBS)_loadError:" SyS.DBG.leaveFunction "Class_Initialize (DBS)>ERROR" End Sub ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Class_Terminate * ’* SCOPE : Private * ’* DESCRIPTION : DESTRUCTOR * ’********************************************************* Private Sub Class_Terminate() SyS.DBG.enterFunction "Class_Terminate (DBS)" If loaded(DB) Then With RCRDS .Customers.Close ’ Flushing Set .Customers = Nothing ’ Clearing pointer
51
HOOFDSTUK 4. SIMS 0.2
52
.Part_Pc.Close Set .Part_Pc = Nothing .PART_IV.Close Set .PART_IV = Nothing .Parts.Close Set .Parts = Nothing .Pc.Close Set .Pc = Nothing .PC_IV.Close Set .PC_IV = Nothing .Part_type.Close Set .Part_type = Nothing .Invoices.Close Set .Invoices = Nothing End With End If SyS.DBG.makeLogEntry "Nullified RCRDS" If loaded(DB) Then DB.Close Set DB = Nothing SyS.DBG.makeLogEntry "Database completely closed" SyS.DBG.leaveFunction "Class_Terminate (DBS)" End Sub ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customer_POKE * ’* SCOPE : Public * ’* DESCRIPTION : Adds customer * ’********************************************************* Public Function Customer_POKE() SyS.DBG.enterFunction "Customer_POKE" On Error GoTo CustBadPoke With SyS.DbBuf.Customer RCRDS.Customers.AddNew RCRDS.Customers.Fields("Name") = IIf(.Name = "", RCRDS.Customers.Fields("Surname") = IIf(.Surname RCRDS.Customers.Fields("Adress") = IIf(.Adress = RCRDS.Customers.Fields("City") = IIf(.City = "", RCRDS.Customers.Fields("Postnumber") = _
IIf(.Postnumber = "", "N/A", .Postnumber) RCRDS.Customers.Fields("Fax") = IIf(.Fax = "", "N/A", .Fax) RCRDS.Customers.Fields("Phone") = IIf(.Phone = "", "N/A", .Phone) RCRDS.Customers.Fields("Email") = IIf(.EMail = "", "N/A", .EMail) RCRDS.Customers.Fields("Date") = Now SyS.DbBuf.Customer.Customer_UIN = RCRDS.Customers.Fields("Customers_UIN") RCRDS.Customers.Update End With SyS.DBG.leaveFunction "Customer_POKE" Exit Function CustBadPoke: SyS.DBG.makeLogEntry "ERROR: CustBadPoke::" & Err.Number & "::" _ & Err.Description SyS.DBG.leaveFunction "Customer_POKE" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customer_EDIT * ’* SCOPE : Public * ’* DESCRIPTION : Changes cust field * ’********************************************************* Public Function Customer_EDIT(UIN As Long) SyS.DBG.enterFunction "Customer_EDIT" If goPOS(RCRDS.Customers, UIN) Then RCRDS.Customers.Edit With SyS.DbBuf.Customer RCRDS.Customers.Fields("Adress") = IIf(.Adress = "", "N/A", .Adress) RCRDS.Customers.Fields("City") = IIf(.City = "", "N/A", .City) RCRDS.Customers.Fields("EMail") = IIf(.EMail = "", "N/A", .EMail) RCRDS.Customers.Fields("Fax") = IIf(.Fax = "", "N/A", .Fax) RCRDS.Customers.Fields("Name") = IIf(.Name = "", "N/A", .Name) RCRDS.Customers.Fields("Phone") = IIf(.Phone = "", "N/A", .Phone) RCRDS.Customers.Fields("Postnumber") =_ IIf(.Postnumber = "", "N/A", .Postnumber) RCRDS.Customers.Fields("Surname") = IIf(.Surname = "", "N/A", .Surname) End With RCRDS.Customers.Update Else
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.makeLogEntry "BAD EDIT -> goPos ret False" End If SyS.DBG.leaveFunction "Customer_EDIT" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customer_DEL * ’* SCOPE : Public * ’* DESCRIPTION : Dels customer * ’********************************************************* Public Function Customer_DEL(UIN As Long) SyS.DBG.enterFunction "Customer_DEL" If goPOS(RCRDS.Customers, UIN) Then If RCRDS.Customers.Fields("LOCKED") = 0 Then RCRDS.Customers.Delete Else SyS.DBG.makeLogEntry "Did not delete locked field : " & UIN End If End If SyS.DBG.leaveFunction "Customer_DEL" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Customer_PEEK * ’* SCOPE : Public * ’* DESCRIPTION : Reads customer * ’********************************************************* Public Function Customer_PEEK(Optional UIN As Long = -1, _ Optional ABSP As Long = -1) As Boolean SyS.DBG.enterFunction "Customer_PEEK" Customer_PEEK = True If (UIN = -1 And ABSP = -1) Or (UIN <> -1 And ABSP <> -1) Then Customer_PEEK = False SyS.DBG.makeLogEntry "Internal Syntax error ;)" End If
54
HOOFDSTUK 4. SIMS 0.2 If UIN <> -1 Then If Not goPOS(RCRDS.Customers, UIN) Then Customer_PEEK = False End If Else If Not goPOS(RCRDS.Customers, , ABSP) Then Customer_PEEK = False End If End If If Customer_PEEK Then With SyS.DbBuf.Customer .Adress = RCRDS.Customers.Fields("Adress") .City = RCRDS.Customers.Fields("City") .Customer_UIN = RCRDS.Customers.Fields("Customers_UIN") .Date = RCRDS.Customers.Fields("Date") .EMail = RCRDS.Customers.Fields("EMail") .Fax = RCRDS.Customers.Fields("Fax") .Name = RCRDS.Customers.Fields("Name") .Phone = RCRDS.Customers.Fields("Phone") .Postnumber = RCRDS.Customers.Fields("Postnumber") .Surname = RCRDS.Customers.Fields("Surname") End With Else SyS.DBG.makeLogEntry "Failed to read (" & UIN & "," & ABSP & ")" End If SyS.DBG.leaveFunction "Customer_PEEK" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_PEEK * ’* SCOPE : Public * ’* DESCRIPTION : Reads part * ’********************************************************* Public Function Parts_PEEK(Optional UIN As Long = -1, _ Optional ABSP As Long = -1) As Boolean SyS.DBG.enterFunction "Parts_PEEK"
55
HOOFDSTUK 4. SIMS 0.2
Parts_PEEK = True If (UIN = -1 And ABSP = -1) Or (UIN <> -1 And ABSP <> -1) Then Parts_PEEK = False SyS.DBG.makeLogEntry "Internal Syntax error ;)" End If If UIN <> -1 Then If Not goPOS(RCRDS.Parts, UIN) Then Parts_PEEK = False End If Else If Not goPOS(RCRDS.Parts, , ABSP) Then Parts_PEEK = False End If End If If Parts_PEEK Then With SyS.DbBuf.Parts .Manufacturer = RCRDS.Parts.Fields("Manufacturer") .Note = RCRDS.Parts.Fields("Note") .PART_UIN = RCRDS.Parts.Fields("PART_UIN") .PartName = RCRDS.Parts.Fields("Name") .Price = RCRDS.Parts.Fields("Price") .Stock = RCRDS.Parts.Fields("Quantity") .TStock = RCRDS.Parts.Fields("WQ") .TYPE_REF = IIf(IsNull(RCRDS.Parts.Fields("Type_REF")),_ -1, RCRDS.Parts.Fields("Type_REF")) End With Else SyS.DBG.makeLogEntry "Failed to read (" & UIN & "," & ABSP & ")" End If SyS.DBG.leaveFunction "Parts_PEEK" End Function
56
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_POKE * ’* SCOPE : Public * ’* DESCRIPTION : Addz part * ’********************************************************* Public Function Parts_POKE() SyS.DBG.enterFunction "Parts_POKE" On Error GoTo badPartsPoke RCRDS.Parts.AddNew With SyS.DbBuf.Parts RCRDS.Parts.Fields("Manufacturer") =_ IIf(.Manufacturer = "", "N/A", .Manufacturer) RCRDS.Parts.Fields("Note") = IIf(.Note = "", "N/A", .Note) RCRDS.Parts.Fields("Name") = IIf(.PartName = "", "N/A", .PartName) RCRDS.Parts.Fields("Price") = IIf(.Price = "", "N/A", .Price) RCRDS.Parts.Fields("Quantity") = .Stock RCRDS.Parts.Fields("WQ") = .Stock ’ Auto mode for now RCRDS.Parts.Fields("Type_REF") = IIf(.TYPE_REF <= 0, -1, .TYPE_REF) RCRDS.Parts.Fields("LOCKED") = 0 .PART_UIN = RCRDS.Parts.Fields("Part_UIN") End With RCRDS.Parts.Update SyS.DBG.leaveFunction "Parts_POKE" Exit Function badPartsPoke: SyS.DBG.makeLogEntry "badPartsPoke::" & Err.Number & "::" & Err.Description SyS.DBG.leaveFunction "Parts_POKE(ERR)" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_DEL * ’* SCOPE : Public * ’* DESCRIPTION : Deletes part * ’********************************************************* Public Function Parts_DEL(UIN As Long)
57
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.enterFunction "Parts_DEL" SyS.DBG.makeLogEntry "Request delete : " & UIN If goPOS(RCRDS.Parts, UIN) Then If RCRDS.Parts.Fields("LOCKED") = 0 Then RCRDS.Parts.Delete End If Else SyS.DBG.makeLogEntry "Delete parts failed, (not found ?)" End If SyS.DBG.leaveFunction "Parts_DEL" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_EDIT * ’* SCOPE : Public * ’* DESCRIPTION : Edits part * ’********************************************************* Public Function Parts_EDIT(UIN As Long) SyS.DBG.enterFunction "Parts_EDIT" If goPOS(RCRDS.Parts, UIN) Then SyS.DBG.makeLogEntry RCRDS.Parts.Fields("LOCKED") If RCRDS.Parts.Fields("LOCKED") = 0 Then RCRDS.Parts.Edit With SyS.DbBuf.Parts RCRDS.Parts.Fields("Type_REF") = .TYPE_REF RCRDS.Parts.Fields("Manufacturer") = .Manufacturer RCRDS.Parts.Fields("Name") = .PartName RCRDS.Parts.Fields("Note") = .Note RCRDS.Parts.Fields("Price") = .Price RCRDS.Parts.Fields("WQ") = .TStock RCRDS.Parts.Fields("Quantity") = .Stock ’ Aaah sync End With RCRDS.Parts.Update Else SyS.DBG.makeLogEntry "Cant write to prtected field : " & Str(UIN) End If Else SyS.DBG.makeLogEntry "Hm, not found : " & Str(UIN) End If
58
HOOFDSTUK 4. SIMS 0.2
SyS.DBG.leaveFunction "Parts_EDIT" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_PEEK * ’* SCOPE : Public * ’* DESCRIPTION : Read PC * ’********************************************************* Public Function PC_PEEK(Optional UIN As Long = -1,_ Optional ABSP As Long = -1) As Boolean SyS.DBG.enterFunction "PC_PEEK" PC_PEEK = True If (UIN = -1 And ABSP = -1) Or (UIN <> -1 And ABSP <> -1) Then PC_PEEK = False SyS.DBG.makeLogEntry "Internal Syntax error ;)" End If If UIN <> -1 Then If Not goPOS(RCRDS.Pc, UIN) Then PC_PEEK = False End If Else If Not goPOS(RCRDS.Pc, , ABSP) Then PC_PEEK = False End If End If If PC_PEEK Then With SyS.DbBuf.Pc .Description = RCRDS.Pc.Fields("Description") .PC_UIN = RCRDS.Pc.Fields("PC_UIN") .Price = RCRDS.Pc.Fields("Price") End With Else SyS.DBG.makeLogEntry "Failed to read (" & UIN & "," & ABSP & ")"
59
HOOFDSTUK 4. SIMS 0.2 End If SyS.DBG.leaveFunction "PC_PEEK" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_POKE * ’* SCOPE : Public * ’* DESCRIPTION : Addz PC * ’********************************************************* Public Function PC_POKE() SyS.DBG.enterFunction "PC_POKE" On Error GoTo badPcPoke RCRDS.Pc.AddNew With SyS.DbBuf.Pc RCRDS.Pc.Fields("Description") = .Description RCRDS.Pc.Fields("Price") = .Price .PC_UIN = RCRDS.Pc.Fields("PC_UIN") End With RCRDS.Pc.Update SyS.DBG.leaveFunction "PC_POKE" Exit Function badPcPoke: SyS.DBG.makeLogEntry "BadpcPoke::" & Err.Number & "::" & Err.Description SyS.DBG.leaveFunction "PC_POKE" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PART_PC_POKE * ’* SCOPE : Public * ’* DESCRIPTION : Links Pa2Pc * ’********************************************************* Public Function PART_PC_POKE() SyS.DBG.enterFunction "PART_PC_POKE"
60
HOOFDSTUK 4. SIMS 0.2
On Error GoTo badpartpcpoke RCRDS.Part_Pc.AddNew With SyS.DbBuf.Part_Pc RCRDS.Part_Pc.Fields("PART_REF") = .Part_REF RCRDS.Part_Pc.Fields("PC_REF") = .PC_REF RCRDS.Part_Pc.Fields("Quantity") = .Quantity RCRDS.Part_Pc.Fields("cPrice") = .cPrice .Part_PC_UIN = RCRDS.Part_Pc.Fields("PART_PC_UIN") End With RCRDS.Part_Pc.Update SyS.DBG.leaveFunction "PART_PC_POKE" Exit Function badpartpcpoke: SyS.DBG.makeLogEntry "BadPartPcPoke::" & _ Err.Number & "::" & Err.Description SyS.DBG.leaveFunction "PART_PC_POKE" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PART_PC_PEEK * ’* SCOPE : Public * ’* DESCRIPTION : Reads link pa2pc * ’********************************************************* Public Function PART_PC_PEEK(Optional UIN As Long = -1,_ Optional ABSP As Long = -1) As Boolean SyS.DBG.enterFunction "PART_PC_PEEK" PART_PC_PEEK = True If (UIN = -1 And ABSP = -1) Or (UIN <> -1 And ABSP <> -1) Then PART_PC_PEEK = False SyS.DBG.makeLogEntry "Internal Syntax error ;)" End If If UIN <> -1 Then If Not goPOS(RCRDS.Part_Pc, UIN) Then PART_PC_PEEK = False End If Else If Not goPOS(RCRDS.Part_Pc, , ABSP) Then
61
HOOFDSTUK 4. SIMS 0.2 PART_PC_PEEK = False End If End If If PART_PC_PEEK Then With SyS.DbBuf.Part_Pc .cPrice = RCRDS.Part_Pc.Fields("cPrice") .Part_PC_UIN = RCRDS.Part_Pc.Fields("PART_PC_UIN") .Part_REF = RCRDS.Part_Pc.Fields("Part_REF") .PC_REF = RCRDS.Part_Pc.Fields("PC_REF") .Quantity = RCRDS.Part_Pc.Fields("Quantity") End With Else SyS.DBG.makeLogEntry "Failed to read (" & UIN & "," & ABSP & ")" End If SyS.DBG.leaveFunction "PART_PC_PEEK" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PART_PC_DEL * ’* SCOPE : Public * ’* DESCRIPTION : Dels Part_PC * ’********************************************************* Public Function PART_PC_DEL(UIN As Long) ’ Useless ? SyS.DBG.enterFunction "PART_PC_DEL" If Not goPOS(RCRDS.Part_Pc, UIN) Then SyS.DBG.makeLogEntry "Request delete :: " & Str(UIN)_ & ":: fail: not found: FIXME" Else If RCRDS.Part_Pc.Fields("LOCKED") = 0 Then RCRDS.Part_Pc.Delete Else SyS.DBG.makeLogEntry "Cannot del locked field" End If End If SyS.DBG.leaveFunction "PART_PC_DEL" End Function
62
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PART_PC_CLEARREF * ’* SCOPE : Public * ’* DESCRIPTION : Clears refs 2 pc * ’********************************************************* Public Function PART_PC_CLEARREF(pcUIN As Long) SyS.DBG.enterFunction "PART_PC_CLEARREF" If RCRDS.Part_Pc.RecordCount = 0 Then Exit Function RCRDS.Part_Pc.MoveFirst Do Until RCRDS.Part_Pc.EOF If RCRDS.Part_Pc.Fields("PC_REF") = pcUIN Then RCRDS.Part_Pc.Delete If RCRDS.Part_Pc.RecordCount = 0 Then SyS.DBG.leaveFunction "PART_PC_CLEARREF" Exit Function End If RCRDS.Part_Pc.MoveFirst Else RCRDS.Part_Pc.MoveNext End If Loop SyS.DBG.leaveFunction "PART_PC_CLEARREF" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : goPOS * ’* SCOPE : Public * ’* DESCRIPTION : Recordset mover ;) * ’********************************************************* Private Function goPOS(x As Recordset, Optional UIN As Long = _ -1, Optional ABSP As Long = -1) As Boolean SyS.DBG.enterFunction "goPOS" On Error GoTo DBS_badGoPos Dim c As Long If x.RecordCount <= 0 Then
63
HOOFDSTUK 4. SIMS 0.2
64
SyS.DBG.leaveFunction "goPOS/empty" goPOS = False Exit Function End If If UIN <> -1 Then x.MoveFirst Do Until (x.EOF) = True If x.Fields(0) = UIN Then ’ WARNING :: UIN __ALWAYS__ on first POS !!! ’ If not u fall in a bucket of pain ;) Exit Do End If x.MoveNext Loop goPOS = Not x.EOF Else If ABSP > x.RecordCount Then ’ ABSP uses C style counting goPOS = False Else x.MoveFirst SyS.DBG.makeLogEntry "Req=" & ABSP Do Until c = ABSP - 1 x.MoveNext c = c + 1 SyS.DBG.makeLogEntry "EDBG//*->ABSP_LOOP(" & c & ")" Loop goPOS = True End If End If SyS.DBG.leaveFunction "goPOS" Exit Function DBS_badGoPos: SyS.DBG.makeLogEntry "ERR::badGoPos::" & Err.Number & "::" & Err.Description SyS.DBG.leaveFunction "goPOS" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : clearBuf * ’* SCOPE : Public * ’* DESCRIPTION : Clears SyS.DbBuf * ’*********************************************************
HOOFDSTUK 4. SIMS 0.2 Public Function clearBuf() Dim TMP As DBS_BUF_TP SyS.DbBuf = TMP ’ XOR SyS.DBBuf,SyS.DBBuf :) End Function
’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : makeNewDBase * ’* SCOPE : Public * ’* DESCRIPTION : Creates new CoreDB * ’********************************************************* Public Function makeNewDBase(fname As String) As Boolean SyS.DBG.enterFunction "makeNewDBase" On Error GoTo baddbcreate Dim nDB As Database Dim T_Customers As TableDef Dim I_Customers As Index Dim F_Customers_UIN As Field Dim F_Cust_Name As Field Dim F_Cust_Surname As Field Dim F_Cust_Adress As Field Dim F_Cust_City As Field Dim F_Cust_PostNumber As Field Dim F_Cust_Fax As Field Dim F_Cust_Phone As Field Dim F_Cust_Email As Field Dim F_Cust_Date As Field Dim F_Cust_LOCKED As Field Dim F_Cust_STATUS As Field Dim T_PART_PC As TableDef Dim I_PART_PC As Index Dim F_PART_PC_UIN As Field Dim F_PPC_PART_REF As Field Dim F_PPC_PC_REF As Field Dim F_PPC_Quantity As Field Dim F_PPC_cPrice As Field Dim F_PPC_LOCKED As Field Dim F_PPC_STATUS As Field Dim T_PART_IV As TableDef
65
HOOFDSTUK 4. SIMS 0.2 Dim Dim Dim Dim Dim Dim Dim Dim
I_PART_IV As Index F_PART_IV_UIN As Field F_PIV_PART_REF As Field F_PIV_Invoice_REF As Field F_PIV_Quantity As Field F_PIV_cPrice As Field F_PIV_LOCKED As Field F_PIV_STATUS As Field
Dim T_PART As TableDef Dim I_PART As Index Dim F_PART_UIN As Field Dim F_PART_Type_REF As Field Dim F_PART_Manufacturer As Field Dim F_PART_Name As Field Dim F_PART_Note As Field Dim F_PART_Price As Field Dim F_PART_Quantity As Field Dim F_PART_TQuant As Field Dim F_PART_LOCKED As Field Dim F_PART_STATUS As Field Dim T_PC As TableDef Dim I_PC As Index Dim F_PC_UIN As Field Dim F_PC_Description As Field Dim F_PC_Price As Field Dim F_PC_LOCKED As Field Dim F_PC_STATUS As Field Dim T_PC_IV As TableDef Dim I_PC_IV As Index Dim F_PC_IV_UIN As Field Dim F_PCIV_PC_REF As Field Dim F_PCIV_Invoice_REF As Field Dim F_PCIV_LOCKED As Field Dim F_PCIV_STATUS As Field Dim T_PART_TYPE As TableDef Dim I_PART_TYPE As Index Dim F_PT_Type_UIN As Field Dim F_PT_Name As Field Dim F_PT_LOCKED As Field Dim F_PT_STATUS As Field Dim T_Invoice As TableDef Dim I_Invoice As Index Dim F_INV_Invoice_UIN As Field Dim F_INV_Cust_REF As Field
66
HOOFDSTUK 4. SIMS 0.2 Dim Dim Dim Dim Dim
F_INV_Date As Field F_INV_TPrice As Field F_INV_Reduc As Field F_INV_LOCKED As Field F_INV_STATUS As Field
Set nDB = DBEngine.CreateDatabase(fname, dbLangGeneral) Set T_Customers = nDB.CreateTableDef("Customers") Set F_Customers_UIN = T_Customers.CreateField("Customers_UIN", dbLong) F_Customers_UIN.Attributes = dbAutoIncrField T_Customers.Fields.Append F_Customers_UIN Set F_Cust_Name = T_Customers.CreateField("Name", dbText) T_Customers.Fields.Append F_Cust_Name Set F_Cust_Surname = T_Customers.CreateField("Surname", dbText) T_Customers.Fields.Append F_Cust_Surname Set F_Cust_Adress = T_Customers.CreateField("Adress", dbText) T_Customers.Fields.Append F_Cust_Adress Set F_Cust_City = T_Customers.CreateField("City", dbText) T_Customers.Fields.Append F_Cust_City Set F_Cust_PostNumber = T_Customers.CreateField("Postnumber", dbText) T_Customers.Fields.Append F_Cust_PostNumber Set F_Cust_Fax = T_Customers.CreateField("Fax", dbText) T_Customers.Fields.Append F_Cust_Fax Set F_Cust_Phone = T_Customers.CreateField("Phone", dbText) T_Customers.Fields.Append F_Cust_Phone Set F_Cust_Email = T_Customers.CreateField("Email", dbText) T_Customers.Fields.Append F_Cust_Email Set F_Cust_Date = T_Customers.CreateField("Date", dbDate) T_Customers.Fields.Append F_Cust_Date Set F_Cust_STATUS = T_Customers.CreateField("STATUS", dbLong) T_Customers.Fields.Append F_Cust_STATUS Set F_Cust_LOCKED = T_Customers.CreateField("LOCKED", dbLong) T_Customers.Fields.Append F_Cust_LOCKED Set I_Customers = T_Customers.CreateIndex I_Customers.Name = "PrimaryKey" I_Customers.Primary = True I_Customers.Unique = True Set F_Customers_UIN = I_Customers.CreateField("Customers_UIN") I_Customers.Fields.Append F_Customers_UIN T_Customers.Indexes.Append I_Customers nDB.TableDefs.Append T_Customers Set T_PART_PC = nDB.CreateTableDef("PART_PC") Set F_PART_PC_UIN = T_PART_PC.CreateField("PART_PC_UIN", dbLong) F_PART_PC_UIN.Attributes = dbAutoIncrField T_PART_PC.Fields.Append F_PART_PC_UIN Set F_PPC_PART_REF = T_PART_PC.CreateField("PART_REF", dbLong)
67
HOOFDSTUK 4. SIMS 0.2 T_PART_PC.Fields.Append F_PPC_PART_REF Set F_PPC_PC_REF = T_PART_PC.CreateField("PC_REF", dbLong) T_PART_PC.Fields.Append F_PPC_PC_REF Set F_PPC_Quantity = T_PART_PC.CreateField("Quantity", dbLong) T_PART_PC.Fields.Append F_PPC_Quantity Set F_PPC_cPrice = T_PART_PC.CreateField("cPrice", dbText) T_PART_PC.Fields.Append F_PPC_cPrice Set F_PPC_STATUS = T_PART_PC.CreateField("STATUS", dbLong) T_PART_PC.Fields.Append F_PPC_STATUS Set F_PPC_LOCKED = T_PART_PC.CreateField("LOCKED", dbLong) T_PART_PC.Fields.Append F_PPC_LOCKED Set I_PART_PC = T_PART_PC.CreateIndex I_PART_PC.Name = "PrimaryKey" I_PART_PC.Primary = True I_PART_PC.Unique = True Set F_PART_PC_UIN = I_PART_PC.CreateField("PART_PC_UIN") I_PART_PC.Fields.Append F_PART_PC_UIN T_PART_PC.Indexes.Append I_PART_PC nDB.TableDefs.Append T_PART_PC Set T_PART_IV = nDB.CreateTableDef("PART_IV") Set F_PART_IV_UIN = T_PART_IV.CreateField("PART_IV_UIN", dbLong) F_PART_IV_UIN.Attributes = dbAutoIncrField T_PART_IV.Fields.Append F_PART_IV_UIN Set F_PIV_PART_REF = T_PART_IV.CreateField("PART_REF", dbLong) T_PART_IV.Fields.Append F_PIV_PART_REF Set F_PIV_Invoice_REF = T_PART_IV.CreateField("Invoice_REF", dbLong) T_PART_IV.Fields.Append F_PIV_Invoice_REF Set F_PIV_Quantity = T_PART_IV.CreateField("Quantity", dbLong) T_PART_IV.Fields.Append F_PIV_Quantity Set F_PIV_cPrice = T_PART_IV.CreateField("cPrice", dbText) T_PART_IV.Fields.Append F_PIV_cPrice Set F_PIV_STATUS = T_PART_IV.CreateField("STATUS", dbLong) T_PART_IV.Fields.Append F_PIV_STATUS Set F_PIV_LOCKED = T_PART_IV.CreateField("LOCKED", dbLong) T_PART_IV.Fields.Append F_PIV_LOCKED Set I_PART_IV = T_PART_IV.CreateIndex I_PART_IV.Name = "PrimaryKey" I_PART_IV.Primary = True I_PART_IV.Unique = True Set F_PART_IV_UIN = I_PART_IV.CreateField("PART_IV_UIN") I_PART_IV.Fields.Append F_PART_IV_UIN T_PART_IV.Indexes.Append I_PART_IV nDB.TableDefs.Append T_PART_IV Set T_PART = nDB.CreateTableDef("PART") Set F_PART_UIN = T_PART.CreateField("PART_UIN", dbLong)
68
HOOFDSTUK 4. SIMS 0.2 F_PART_UIN.Attributes = dbAutoIncrField T_PART.Fields.Append F_PART_UIN Set F_PART_Type_REF = T_PART.CreateField("Type_REF", dbLong) T_PART.Fields.Append F_PART_Type_REF Set F_PART_Manufacturer = T_PART.CreateField("Manufacturer", dbText) T_PART.Fields.Append F_PART_Manufacturer Set F_PART_Name = T_PART.CreateField("Name", dbText) T_PART.Fields.Append F_PART_Name Set F_PART_Note = T_PART.CreateField("Note", dbText) T_PART.Fields.Append F_PART_Note Set F_PART_Price = T_PART.CreateField("Price", dbText) T_PART.Fields.Append F_PART_Price Set F_PART_Quantity = T_PART.CreateField("Quantity", dbLong) T_PART.Fields.Append F_PART_Quantity Set F_PART_TQuant = T_PART.CreateField("WQ", dbLong) T_PART.Fields.Append F_PART_TQuant Set F_PART_LOCKED = T_PART.CreateField("LOCKED", dbLong) T_PART.Fields.Append F_PART_LOCKED Set F_PART_STATUS = T_PART.CreateField("STATUS", dbLong) T_PART.Fields.Append F_PART_STATUS Set I_PART = T_PART.CreateIndex I_PART.Name = "PrimaryKey" I_PART.Primary = True I_PART.Unique = True Set F_PART_UIN = I_PART.CreateField("PART_UIN") I_PART.Fields.Append F_PART_UIN T_PART.Indexes.Append I_PART nDB.TableDefs.Append T_PART Set T_PC = nDB.CreateTableDef("PC") Set F_PC_UIN = T_PC.CreateField("PC_UIN", dbLong) F_PC_UIN.Attributes = dbAutoIncrField T_PC.Fields.Append F_PC_UIN Set F_PC_Description = T_PC.CreateField("Description", dbMemo) T_PC.Fields.Append F_PC_Description Set F_PC_Price = T_PC.CreateField("Price", dbText) T_PC.Fields.Append F_PC_Price Set F_PC_LOCKED = T_PC.CreateField("LOCKED", dbLong) T_PC.Fields.Append F_PC_LOCKED Set F_PC_STATUS = T_PC.CreateField("STATUS", dbLong) T_PC.Fields.Append F_PC_STATUS Set I_PC = T_PC.CreateIndex I_PC.Name = "PrimaryKey" I_PC.Primary = True I_PC.Unique = True Set F_PC_UIN = I_PC.CreateField("PC_UIN") I_PC.Fields.Append F_PC_UIN
69
HOOFDSTUK 4. SIMS 0.2 T_PC.Indexes.Append I_PC nDB.TableDefs.Append T_PC Set T_PC_IV = nDB.CreateTableDef("PC_IV") Set F_PC_IV_UIN = T_PC_IV.CreateField("PC_IV_UIN", dbLong) F_PC_IV_UIN.Attributes = dbAutoIncrField T_PC_IV.Fields.Append F_PC_IV_UIN Set F_PCIV_PC_REF = T_PC_IV.CreateField("PC_REF", dbLong) T_PC_IV.Fields.Append F_PCIV_PC_REF Set F_PCIV_Invoice_REF = T_PC_IV.CreateField("Invoice_REF", dbLong) T_PC_IV.Fields.Append F_PCIV_Invoice_REF Set F_PCIV_LOCKED = T_PC_IV.CreateField("LOCKED", dbLong) T_PC_IV.Fields.Append F_PCIV_LOCKED Set F_PCIV_STATUS = T_PC_IV.CreateField("STATUS", dbLong) T_PC_IV.Fields.Append F_PCIV_STATUS Set I_PC_IV = T_PC_IV.CreateIndex I_PC_IV.Name = "PrimaryKey" I_PC_IV.Primary = True I_PC_IV.Unique = True Set F_PC_IV_UIN = I_PC_IV.CreateField("PC_IV_UIN") I_PC_IV.Fields.Append F_PC_IV_UIN T_PC_IV.Indexes.Append I_PC_IV nDB.TableDefs.Append T_PC_IV Set T_PART_TYPE = nDB.CreateTableDef("PART_TYPE") Set F_PT_Type_UIN = T_PART_TYPE.CreateField("PART_Type_UIN", dbLong) F_PT_Type_UIN.Attributes = dbAutoIncrField T_PART_TYPE.Fields.Append F_PT_Type_UIN Set F_PT_Name = T_PART_TYPE.CreateField("Name", dbText) T_PART_TYPE.Fields.Append F_PT_Name Set F_PT_LOCKED = T_PART_TYPE.CreateField("LOCKED", dbLong) T_PART_TYPE.Fields.Append F_PT_LOCKED Set F_PT_STATUS = T_PART_TYPE.CreateField("STATUS", dbLong) T_PART_TYPE.Fields.Append F_PT_STATUS Set I_PART_TYPE = T_PART_TYPE.CreateIndex I_PART_TYPE.Name = "PrimaryKey" I_PART_TYPE.Primary = True I_PART_TYPE.Unique = True Set F_PT_Type_UIN = I_PART_TYPE.CreateField("PART_Type_UIN") I_PART_TYPE.Fields.Append F_PT_Type_UIN T_PART_TYPE.Indexes.Append I_PART_TYPE nDB.TableDefs.Append T_PART_TYPE Set T_Invoice = nDB.CreateTableDef("Invoice") Set F_INV_Invoice_UIN = T_Invoice.CreateField("Invoice_UIN", dbLong) F_INV_Invoice_UIN.Attributes = dbAutoIncrField T_Invoice.Fields.Append F_INV_Invoice_UIN
70
HOOFDSTUK 4. SIMS 0.2 Set F_INV_Cust_REF = T_Invoice.CreateField("Cust_REF", dbLong) T_Invoice.Fields.Append F_INV_Cust_REF Set F_INV_Date = T_Invoice.CreateField("Date", dbText) T_Invoice.Fields.Append F_INV_Date Set F_INV_TPrice = T_Invoice.CreateField("TPrice", dbText) T_Invoice.Fields.Append F_INV_TPrice Set F_INV_Reduc = T_Invoice.CreateField("Reduc", dbText) T_Invoice.Fields.Append F_INV_Reduc Set F_INV_LOCKED = T_Invoice.CreateField("LOCKED", dbLong) T_Invoice.Fields.Append F_INV_LOCKED Set F_INV_STATUS = T_Invoice.CreateField("STATUS", dbLong) T_Invoice.Fields.Append F_INV_STATUS Set I_Invoice = T_Invoice.CreateIndex I_Invoice.Name = "PrimaryKey" I_Invoice.Primary = True I_Invoice.Unique = True Set F_INV_Invoice_UIN = I_Invoice.CreateField("Invoice_UIN") I_Invoice.Fields.Append F_INV_Invoice_UIN T_Invoice.Indexes.Append I_Invoice nDB.TableDefs.Append T_Invoice makeNewDBase = True SyS.DBG.leaveFunction "makeNewDBase" Exit Function baddbcreate: SyS.DBG.enterFunction "makeNewDBase: ERROR:" makeNewDBase = False SyS.DBG.makeLogEntry Err.Description SyS.DBG.leaveFunction "makeNewDBase: ERROR:" SyS.DBG.leaveFunction "makeNewDBase" Exit Function End Function Public Function numCustomers() As Long numCustomers = RCRDS.Customers.RecordCount End Function Public Function numParts() As Long
71
HOOFDSTUK 4. SIMS 0.2
numParts = RCRDS.Parts.RecordCount End Function Public Function numPCs() As Long numPCs = RCRDS.Pc.RecordCount End Function Public Function numInvoices() As Long numInvoices = RCRDS.Invoices.RecordCount End Function Public Function numPC_IV() As Long numPC_IV = RCRDS.PC_IV.RecordCount End Function Public Function numPart_pc() As Long numPart_pc = RCRDS.Part_Pc.RecordCount End Function Public Function numPartType() As Long numPartType = RCRDS.Part_type.RecordCount End Function Public Function numPart_IV() As Long numPart_IV = RCRDS.PART_IV.RecordCount End Function
72
HOOFDSTUK 4. SIMS 0.2
4.9
73
FLIB DBG (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : FLIB_DBG.bas * ’* OBJECT : FLIB_DBG * ’* DESCRIPTION : Common function library w/ debugging * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : doUpdate * ’* SCOPE : Public * ’* DESCRIPTION : Processes background events * ’********************************************************* Public Function doUpdate(Optional T As Integer = 100) SyS.DBG.enterFunction "doUpdate" Dim c As Integer For c = 1 To T DoEvents Next c SyS.DBG.leaveFunction "doUpdate"
HOOFDSTUK 4. SIMS 0.2
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : curSelLV * ’* SCOPE : Public * ’* DESCRIPTION : Returns the first sel obj LV * ’********************************************************* Public Function curSelLV(LV As ListView) As Long SyS.DBG.enterFunction "curSelLV" Dim c As Long For c = 1 To LV.ListItems.Count If LV.ListItems(c).Selected Then curSelLV = c SyS.DBG.leaveFunction "cueSelLV" Exit Function End If Next c curSelLV = -1 SyS.DBG.leaveFunction "cueSelLV" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : SEDT_ASM * ’* SCOPE : Public * ’* DESCRIPTION : Assembles UIN and Type * ’********************************************************* Public Function SEDT_ASM(UIN As Long, dtype As String) As String SyS.DBG.enterFunction "SEDT_ASM" Do Until Len(dtype) >= 2 dtype = dtype & " " Loop SEDT_ASM = Left(dtype, 2) & Str(UIN)
74
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.leaveFunction "SEDT_ASM" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : SEDT_UIN * ’* SCOPE : Public * ’* DESCRIPTION : Extracts UIN from ASM * ’********************************************************* Public Function SEDT_UIN(ASM As String) As Long SyS.DBG.enterFunction "SEDT_UIN" SEDT_UIN = CLng(Right(ASM, Len(ASM) - 2)) SyS.DBG.leaveFunction "SEDT_UIN" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : SEDT_DTYPE * ’* SCOPE : Public * ’* DESCRIPTION : Extracts DType from ASM * ’********************************************************* Public Function SEDT_DTYPE(ASM As String) As String SyS.DBG.enterFunction "SEDT_DTYPE" SEDT_DTYPE = Left(ASM, 2) SyS.DBG.leaveFunction "SEDT_DTYPE" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : DD_goodType * ’* SCOPE : Public * ’* DESCRIPTION : Checks for Syntax on ASM * ’********************************************************* Public Function DD_goodType(D As MSComctlLib.DataObject) SyS.DBG.enterFunction "DD_goodType"
75
HOOFDSTUK 4. SIMS 0.2 DD_goodType = D.GetFormat(1) ’Add check s/format Sims s SyS.DBG.leaveFunction "DD_goodType" End Function
76
HOOFDSTUK 4. SIMS 0.2
4.10
77
FLIB NDBG (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : FLIB_NDBG.bas * ’* OBJECT : FLIB_NDBG * ’* DESCRIPTION : Common Function Library w/o debugging * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : loaded * ’* SCOPE : Public * ’* DESCRIPTION : Checks if an object is set * ’********************************************************* Public Function loaded(x As Object) As Boolean On Error GoTo E91 ’ Run to hell :( Dim T As String T = x.Name loaded = True Exit Function
HOOFDSTUK 4. SIMS 0.2
E91: If Err.Number = 91 Then loaded = False Else loaded = True Exit Function End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : TwipsToPixelsX * ’* SCOPE : Public * ’* DESCRIPTION : T->P(X) * ’********************************************************* Public Function TwipsToPixelsX(Twips As Long) As Long TwipsToPixelsX = Twips / Screen.TwipsPerPixelX End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PixelsToTwipsX * ’* SCOPE : Public * ’* DESCRIPTION : P->T(X) * ’********************************************************* Public Function PixelsToTwipsX(Pixels As Long) As Long PixelsToTwipsX = Pixels * Screen.TwipsPerPixelX End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : TwipsToPixelsY * ’* SCOPE : Public * ’* DESCRIPTION : T->P(Y) * ’********************************************************* Public Function TwipsToPixelsY(Twips As Long) As Long TwipsToPixelsY = Twips / Screen.TwipsPerPixelY End Function
78
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PixelsToTwipsY * ’* SCOPE : Public * ’* DESCRIPTION : P->T(Y) * ’********************************************************* Public Function PixelsToTwipsY(Pixels As Long) As Long PixelsToTwipsY = Pixels * Screen.TwipsPerPixelY End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : STDW_CRF * ’* SCOPE : Public * ’* DESCRIPTION : Common Resize Function * ’********************************************************* Public Function STDW_CRF(F As Form, LV As ListView, _ CB As CoolBar, SB As StatusBar) If F.WindowState = vbMinimized Then Exit Function LV.Top = CB.Top + CB.Height If F.Width < 3000 Then F.Width = 3000 If F.Height < 3000 Then F.Height = 3000
LV.Width = F.Width - PixelsToTwipsX(15) LV.Height = F.Height - (SB.Height + LV.Top + 400) CB.Width = F.Width - PixelsToTwipsX(15) End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : TLVW_CRF * ’* SCOPE : Public * ’* DESCRIPTION : Resizes STDW w/ 2 LV’s * ’********************************************************* Public Function TLVW_CRF(F As Form, LV1 As ListView, LV2 As ListView, _ CB As CoolBar, SB As StatusBar, P As Integer) Dim T As Long
79
HOOFDSTUK 4. SIMS 0.2 If F.WindowState = vbMinimized Then Exit Function T = F.Height - (CB.Top + CB.Height + SB.Height + 30) ’ Total space for 2 LV’s If F.Width < 3000 Then F.Width = 3000 Exit Function End If If F.Height < 3000 Then F.Height = 3000 Exit Function End If LV1.Top = CB.Top + CB.Height LV1.Height = (T / 100) * P LV1.Width = F.Width - PixelsToTwipsX(15) LV1.Left = PixelsToTwipsX(4) LV2.Top = LV1.Top + LV1.Height + PixelsToTwipsY(5) LV2.Width = LV1.Width LV2.Height = T - LV1.Height - CB.Height ’ Sort of beauty error LV2.Left = PixelsToTwipsX(4) CB.Width = F.Width - PixelsToTwipsX(15) End Function
80
HOOFDSTUK 4. SIMS 0.2
4.11
81
frmCustomers (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmCustomers.frm * ’* OBJECT : frmCustomers * ’* DESCRIPTION : Customerlist :: MDI child * ’* * ’********************************************************************************** Private Sub Form_Load() Customers_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Customers_QUnload End Sub Private Sub Form_Resize() Customers_Resize End Sub
HOOFDSTUK 4. SIMS 0.2 Private Sub cBar_HeightChanged(ByVal NewHeight As Single) Customers_cBar_Resize End Sub Private Sub cmdAdd_Click() Customers_cmdAdd_Click End Sub Private Sub cmdDel_Click() Customers_cmdDel_Click End Sub Private Sub cmdEdit_Click() Customers_cmdEdit_Click End Sub Private Sub cmdSearch_Click() Customers_cmdSearch_Click End Sub Private Sub cmdShowAll_Click() Customers_ShowAll_Click End Sub Private Sub LV_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) iOBJ_Cust_LV_Column_Click (ColumnHeader.Index) End Sub
82
HOOFDSTUK 4. SIMS 0.2
4.12
83
frmCustomersADDED (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmCustomers_ADDED.frm * ’* OBJECT : frmCustomers_ADDED * ’* DESCRIPTION : LForm to add customer (put/exist) * ’* * ’********************************************************************************** Private Sub cmdAdd_Click() CustomersAddED_Add_Click End Sub Private Sub Form_Load() CustomersADDED_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) CustomersADDED_QUnload End Sub Private Sub cmdCancel_Click()
HOOFDSTUK 4. SIMS 0.2
CustomersAddED_Cancel_Click End Sub
84
HOOFDSTUK 4. SIMS 0.2
4.13
85
frmInvoices (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmInvoices.frm * ’* OBJECT : frmInvoices * ’* DESCRIPTION : Invoice list :: MDI child * ’* * ’********************************************************************************** Private Sub Form_Load() Invoice_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Invoice_QUnload End Sub
HOOFDSTUK 4. SIMS 0.2
4.14
86
frmMain (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmMain.frm * ’* OBJECT : frmMain * ’* DESCRIPTION : Main form :: MDI parent * ’* * ’**********************************************************************************
Private Sub MDIForm_Load() Main_Load End Sub Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) Main_QUnload End Sub Private Sub mnuCustomers_Click() Main_mnuCustomers_Click End Sub
HOOFDSTUK 4. SIMS 0.2
Private Sub mnuInvoices_Click() Main_mnuInvoices_Click End Sub Private Sub mnuParts_Click() Main_mnuParts_Click End Sub Private Sub mnuPC_Click() Main_mnuPC_Click End Sub Private Sub mnuQuit_Click() Main_mnuQuit_Click End Sub
87
HOOFDSTUK 4. SIMS 0.2
4.15
88
frmParts (formcode)
Option Explicit
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmParts.frm * ’* OBJECT : frmParts * ’* DESCRIPTION : Show parts list :: MDI child * ’* * ’********************************************************************************** Private Sub Form_Load() Parts_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Parts_QUnload End Sub Private Sub Form_Resize() Parts_Resize End Sub
HOOFDSTUK 4. SIMS 0.2 Private Sub cBar_HeightChanged(ByVal NewHeight As Single) Parts_cBar_HeightChanged End Sub Private Sub cmdAdd_Click() Parts_cmdAdd_Click End Sub Private Sub cmdDel_Click() Parts_cmdDel_Click End Sub Private Sub LV_OLEStartDrag(Data As MSComctlLib.DataObject, _ AllowedEffects As Long) Parts_DragDrop_Out Data End Sub
89
HOOFDSTUK 4. SIMS 0.2
4.16
90
frmPartsADDED (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmParts_ADDED.frm * ’* OBJECT : frmParts_ADDED * ’* DESCRIPTION : Allows to add/edit a part record * ’* * ’********************************************************************************** Private Sub Form_Load() Parts_ADDED_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Parts_ADDED_QUnLoad End Sub Private Sub cmdAdd_Click() PartsAE_cmdAdd_Click End Sub Private Sub cmdCancel_Click()
HOOFDSTUK 4. SIMS 0.2
PartsAE_cmdCancel_Click End Sub
91
HOOFDSTUK 4. SIMS 0.2
4.17
92
frmPC (formcode)
Option Explicit
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmPC.frm * ’* OBJECT : frmPC * ’* DESCRIPTION : List of assembled PC’s :: MDI child * ’* * ’********************************************************************************** Private Sub Form_Load() PC_Load End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) PC_QUnload End Sub Private Sub Form_Resize() PC_Resize End Sub
HOOFDSTUK 4. SIMS 0.2
Private Sub cmdAdd_Click() PC_cmdAdd_Click End Sub Private Sub LVpc_ItemClick(ByVal Item As MSComctlLib.ListItem) PC_LVpc_ItemClick Item End Sub Private Sub cmdEdit_Click() PC_cmdEdit_Click End Sub
93
HOOFDSTUK 4. SIMS 0.2
4.18
94
frmPCADDED (formcode)
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmPC_ADDED.frm * ’* OBJECT : frmPC_ADDED * ’* DESCRIPTION : Assembles PC’s D&D * ’* * ’********************************************************************************** Private Sub cmdAdd_Click() PCAE_cmdAdd_Click End Sub Private Sub cmdCancel_Click() PC_AE_Cancel End Sub Private Sub Form_Load() PC_AE_Load End Sub Private Sub Form_Unload(Cancel As Integer)
HOOFDSTUK 4. SIMS 0.2 PC_AE_QUnload End Sub Private Sub LVpart_OLEDragDrop(Data As MSComctlLib.DataObject,_ Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single) PC_AE_DragDrop_In Data End Sub
95
HOOFDSTUK 4. SIMS 0.2
4.19
96
frmSplash (formcode)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : frmSplash.frm * ’* OBJECT : frmSplash * ’* DESCRIPTION : Splash form that loads the system * ’* * ’********************************************************************************** Private Sub Form_Load() Splash_Load End Sub Private Sub pctStart_DblClick() shutDownSys End Sub Private Sub tmrALL_Timer() Splash_tmrALL_Timer End Sub Private Sub tmrCFG_Timer()
HOOFDSTUK 4. SIMS 0.2
Splash_tmrCFG_Timer End Sub Private Sub tmrDBG_Timer() Splash_tmrDBG_Timer End Sub Private Sub tmrDBS_Timer() Splash_tmrDBS_Timer End Sub Private Sub CmdNewDB_Click() Splash_cmdNewDB_Click End Sub Private Sub cmdOpenDB_Click() Splash_cmdOpenDB_Click End Sub
97
HOOFDSTUK 4. SIMS 0.2
4.20
98
INIT (coremodule)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : INIT.bas * ’* OBJECT : INIT * ’* DESCRIPTION : Basic boot/shutdownsystem * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : main * ’* SCOPE : Private * ’* DESCRIPTION : Boot function() * ’********************************************************* Private Sub Main() On Error GoTo badEarlyInit Set Set Set Set Set Set Set
With SyS.lOBJ .Customers = False .Customers_ADDED = False .Invoices = False .Main = False .Parts = False .Pc = False .Splash = False .Customers_ADDED = False .Parts_ADDED = False .Pc_ADDED = False End With Load SyS.FRM.Splash Exit Sub badEarlyInit: MsgBox "An early initialisation error occured, this should not happen and _ indicates a serious (bug?) soft/hardware problem" _ & vbCrLf & "Please report the following number to your supplier _ : " & "001-" & Err.Number, vbCritical, "Fatal error" End Sub
’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : shutDownSys * ’* SCOPE : Public * ’* DESCRIPTION : Brings the system down * ’*********************************************************
99
HOOFDSTUK 4. SIMS 0.2 Public Function shutDownSys() SyS.DBG.enterFunction "shutDownSys" ’ Possible bug when QUnload still needs db/dbg... ’ Force close windows ? Set SyS.DBS = Nothing Set SyS.CFG = Nothing SyS.DBG.leaveFunction "shutDownSys" SyS.DBG.leaveFunction "SIMS" Set SyS.DBG = Nothing End End Function
100
HOOFDSTUK 4. SIMS 0.2
4.21
101
InvoiceEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : InvoiceEV.bas * ’* OBJECT : InvoiceEV * ’* DESCRIPTION : Event Handler for frmInvoice * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Invoice_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads frmInvoices * ’********************************************************* Public Function Invoice_Load() SyS.DBG.enterFunction "Invoice_Load" SyS.FRM.Main.mnuInvoices.Checked = True SyS.Config.bShowInvoice = True SyS.FRM.Invoices.Show SyS.lOBJ.Invoices = True SyS.DBG.leaveFunction "Invoice_Load"
HOOFDSTUK 4. SIMS 0.2
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Invoice_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads frmInvoices * ’********************************************************* Public Function Invoice_QUnload() SyS.DBG.enterFunction "Invoice_QUnload" SyS.FRM.Main.mnuInvoices.Checked = False SyS.Config.bShowInvoice = False SyS.lOBJ.Invoices = False SyS.DBG.leaveFunction "Invoice_QUnload" End Function
102
HOOFDSTUK 4. SIMS 0.2
4.22
103
MainEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : mainEV.bas * ’* OBJECT : mainEV * ’* DESCRIPTION : MDI Parent Event Handler (MPEH) * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_Load * ’* SCOPE : Public * ’* DESCRIPTION : Handels sys.frm.main_Load * ’********************************************************* Public Function Main_Load() SyS.DBG.enterFunction "Main_Load" SyS.FRM.Main.Caption = SyS.Config.appCaption SyS.FRM.Main.Visible = True If SyS.Config.bShowCust Then Load SyS.FRM.Customers End If
HOOFDSTUK 4. SIMS 0.2
104
If SyS.Config.bShowPart Then Load SyS.FRM.Parts End If If SyS.Config.bShowInvoice Then Load SyS.FRM.Invoices End If If SyS.Config.bShowPC Then Load SyS.FRM.PCs End If SyS.FRM.Main.mnuCustomers.Checked = SyS.Config.bShowCust SyS.FRM.Main.mnuParts.Checked = SyS.Config.bShowPart SyS.FRM.Main.mnuPC.Checked = SyS.Config.bShowPC SyS.FRM.Main.mnuInvoices.Checked = SyS.Config.bShowInvoice SyS.lOBJ.Main = True SyS.DBG.leaveFunction "Main_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads the Main form * ’********************************************************* Public Function Main_QUnload() SyS.DBG.enterFunction "Main_QUnload" ’Ltrz d00dz SyS.lOBJ.Main = False
’ Hmmm, it never gets the chance to unload (shutdownsys)
SyS.DBG.leaveFunction "Main_QUnload>shutDownSys" shutDownSys End Function
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_mnuQuit_Click * ’* SCOPE : Public * ’* DESCRIPTION : Call to exit * ’********************************************************* Public Function Main_mnuQuit_Click() SyS.DBG.enterFunction "Main_mnuQuit_Click" SyS.DBG.leaveFunction "Main_mnuQuit_Click>shutDownSys" shutDownSys End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_mnuParts_Click * ’* SCOPE : Public * ’* DESCRIPTION : Switches Parts on/off * ’********************************************************* Public Function Main_mnuParts_Click() SyS.DBG.enterFunction "Main_mnuParts_Click" If SyS.FRM.Main.mnuParts.Checked Then Unload SyS.FRM.Parts Else ’ << asking for probs, add err_h Load SyS.FRM.Parts End If SyS.DBG.leaveFunction "Main_mnuParts_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_mnuCustomers_Click * ’* SCOPE : Public * ’* DESCRIPTION : Switches Parts on/off * ’********************************************************* Public Function Main_mnuCustomers_Click() SyS.DBG.enterFunction "Main_mnuCustomers_Click"
105
HOOFDSTUK 4. SIMS 0.2 If SyS.FRM.Main.mnuCustomers.Checked Then Unload SyS.FRM.Customers Else ’<< Dito as above Load SyS.FRM.Customers End If SyS.DBG.leaveFunction "Main_mnuCustomers_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_mnuInvoices_Click * ’* SCOPE : Public * ’* DESCRIPTION : Switch * ’********************************************************* Public Function Main_mnuInvoices_Click() SyS.DBG.enterFunction "Main_mnuInvoices_Click" If SyS.FRM.Main.mnuInvoices.Checked Then Unload SyS.FRM.Invoices Else Load SyS.FRM.Invoices End If SyS.DBG.leaveFunction "Main_mnuInvoices_Click" End Function
’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Main_mnuPC_Click * ’* SCOPE : Public * ’* DESCRIPTION : Switch * ’********************************************************* Public Function Main_mnuPC_Click() SyS.DBG.enterFunction "Main_mnuPC_Click" If SyS.FRM.Main.mnuPC.Checked Then Unload SyS.FRM.PCs Else Load SyS.FRM.PCs End If
106
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.leaveFunction "Main_mnuPC_Click" End Function
107
HOOFDSTUK 4. SIMS 0.2
4.23
108
MEMCORE (coremodule)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : MEMCORE.bas * ’* OBJECT : MEMCORE * ’* DESCRIPTION : Contains all data types * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : CONFIG_TP * ’* PARENT : SYS_TP * ’* DESCRIPTION : Configuration buffer * ’********************************************************* Public Type CONFIG_TP appCaption As String dbaseFileName As String bShowCust As Boolean ’Show form @ boot ? bShowPart As Boolean bShowPC As Boolean bShowInvoice As Boolean emptyString As String
HOOFDSTUK 4. SIMS 0.2 defCurrency As String
End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : DTA_TP * ’* Parent : SyS * ’* Description : General Data buffer (sys) * ’********************************************************* Public Type DTA_TP Cust_saveOK As Boolean Cust_AddEdit As Long Cust_AddEdit_UIN As Long Part_AddEdit As Boolean Part_AddEdit_UIN As Long PC_AE As Boolean ’ false = add :: true = edit PC_AE_UIN As Long ’ :? End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : IOBJ_TP * ’* Parent : SyS * ’* Description : General Important objects * ’********************************************************* Public Type IOBJ_TP Cust_LV As ListView Cust_SBar As StatusBar Cust_CBar As CoolBar ’ << Stupid bug in M$ JUNK program Part_LV As ListView Part_SBar As StatusBar Part_CBar As CoolBar PC_LVpc As ListView PC_LVpart As ListView PC_SB As StatusBar PC_CB As CoolBar PCAE_LV As ListView
109
HOOFDSTUK 4. SIMS 0.2
End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : OBJ_LOAD_TP * ’* Parent : SyS * ’* Description : Cross Reference Load Status’s* ’********************************************************* Public Type OBJ_LOAD_TP Customers As Boolean Customers_ADDED As Boolean Invoices As Boolean Main As Boolean Parts As Boolean Parts_ADDED As Boolean Pc As Boolean Pc_ADDED As Boolean Splash As Boolean End Type ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : FRM_TP * ’* PARENT : SyS * ’* DESCRIPTION : Holds pointers to forms * ’********************************************************* Public Type FRM_TP Main As MDIForm Splash As Form Customers As Form Parts As Form Invoices As Form PCs As Form Customers_ADDED As Form Parts_ADDED As Form PCs_ADDED As Form End Type
110
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : RCRDS_TP * ’* PARENT : Private member of DBS_CLASS * ’* DESCRIPTION : Recordset container * ’********************************************************* Public Type RCRDS_TP Customers As Recordset Part_Pc As Recordset PART_IV As Recordset Parts As Recordset Pc As Recordset PC_IV As Recordset Part_type As Recordset Invoices As Recordset End Type ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : Klant_TP * ’* PARENT : DBS_BUF_TP * ’* DESCRIPTION : Klant table buffer * ’********************************************************* Public Type Customer_TP Customer_UIN As Long Name As String Surname As String Adress As String City As String Postnumber As String Fax As String Phone As String EMail As String Date As Date End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : Parts_TP * ’* Parent : DBS_BUF_TP * ’* Description : Parts table buffer * ’*********************************************************
111
HOOFDSTUK 4. SIMS 0.2 Public Type Parts_TP PART_UIN As Long TYPE_REF As Long Manufacturer As String PartName As String Note As String Price As String Stock As Long TStock As Long End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : Invoice_TP * ’* Parent : DBS_BUF_TP * ’* Description : Invoices * ’********************************************************* Public Type Invoice_TP Invoice_UIN As Long Cust_REF As Long Date As String TPrice As String Reduction As String End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : Part_IV_TP * ’* Parent : DBS_BUF_TP * ’* Description : Links Parts 2 invoices * ’********************************************************* Public Type Part_IV_TP Part_IV_UIN As Long Part_REF As Long Invoice_REF As Long Quantity As Long cPrice As String End Type
112
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* Type Name : Part_PC_TP * ’* Parent : DBS_BUF_TP * ’* Description : Links parts 2 PC’s * ’********************************************************* Public Type Part_PC_TP Part_PC_UIN As Long Part_REF As Long PC_REF As Long Quantity As Long cPrice As String End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : Part_Type_TP * ’* Parent : DBS_BUF_TP * ’* Description : Descripes HW type * ’********************************************************* Public Type Part_Type_TP Part_Type_UIN As Long Name As String End Type ’********************************************************* ’* Sims 0.1 * ’* Type Name : PC_TP * ’* Parent : DBS_BUF_TP * ’* Description : PC’s * ’********************************************************* Public Type PC_TP PC_UIN As Long Description As String Price As String End Type
113
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* Type Name : PC_IV_TP * ’* Parent : DBS_BUF_TP * ’* Description : Links pc’s to invoices * ’********************************************************* Public Type PC_IV_TP PC_IV_UIN As Long PC_REF As Long Invoice_REF As Long End Type ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : DBS_BUF_TP * ’* PARENT : SyS_TP * ’* DESCRIPTION : Table buffer parent * ’********************************************************* Public Type DBS_BUF_TP Customer As Customer_TP Parts As Parts_TP Invoice As Invoice_TP Part_Invoice As Part_IV_TP Part_Pc As Part_PC_TP Part_type As Part_Type_TP Pc As PC_TP Pc_Invoice As PC_IV_TP End Type ’********************************************************* ’* Sims 0.1 * ’* TYPE NAME : SYS_TP * ’* PARENT : NONE, SYS=ROOT STRUCT * ’* DESCRIPTION : PARENT DATA CONTAINER * ’********************************************************* Public Type SYS_TP Config As CONFIG_TP DbBuf As DBS_BUF_TP ’ The global Data Transfer Buffer (DTB) SysBuf As DTA_TP FRM As FRM_TP iOBJ As IOBJ_TP
114
HOOFDSTUK 4. SIMS 0.2 lOBJ As OBJ_LOAD_TP DBG As DBG_CLASS CFG As CFG_CLASS DBS As DBS_CLASS End Type ’ Declarations ******************************************* Public SyS As SYS_TP ’ <- One very important memory eating, big fat ’ super root type :D
115
HOOFDSTUK 4. SIMS 0.2
4.24
116
PartsADDEDEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : Parts_ADDEDEV.bas * ’* OBJECT : Parts_ADDEDEV * ’* DESCRIPTION : Event handle for frmParts_ADDED * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_ADDED_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads PADDED * ’********************************************************* Public Function Parts_ADDED_Load() SyS.DBG.enterFunction "Parts_ADDED_Load" SyS.lOBJ.Parts_ADDED = True If SyS.SysBuf.Part_AddEdit = True Then SyS.FRM.Parts_ADDED.Caption = "Edit " SyS.FRM.Parts_ADDED.cmdAdd.Caption = "Change" Else SyS.FRM.Parts_ADDED.Caption = "Add new part"
HOOFDSTUK 4. SIMS 0.2
117
SyS.FRM.Parts_ADDED.cmdAdd.Caption = "Add" End If ’ Expermental : make non req MDI, MDI to prevent hide bug SetTopMostWindow frmParts_ADDED, True SyS.DBG.leaveFunction "Parts_ADDED_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_ADDED_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads PADDED * ’********************************************************* Public Function Parts_ADDED_QUnLoad() SyS.DBG.enterFunction "Parts_ADDED_QUnLoad" SyS.lOBJ.Parts_ADDED = False SyS.DBG.leaveFunction "Parts_ADDED_QUnLoad" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PartsAE_cmdAdd_Click * ’* SCOPE : Public * ’* DESCRIPTION : Adds a new part * ’********************************************************* Public Function PartsAE_cmdAdd_Click() SyS.DBG.enterFunction "PartsAE_cmdAdd_Click" With SyS.DbBuf.Parts .Manufacturer = frmParts_ADDED.txtManufact .Note = frmParts_ADDED.txtNote .PartName = frmParts_ADDED.txtName .Price = frmParts_ADDED.txtPrice .Stock = IIf(frmParts_ADDED.txtStock = "", 0, _ IIf(IsNumeric(frmParts_ADDED.txtStock), Val(frmParts_ADDED.txtStock), 0)) End With SyS.DBS.Parts_POKE
HOOFDSTUK 4. SIMS 0.2
Parts_FillList SyS.DBG.leaveFunction "PartsAE_cmdAdd_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PartsAE_cmdCancel_Click * ’* SCOPE : Public * ’* DESCRIPTION : Cancels adding part * ’********************************************************* Public Function PartsAE_cmdCancel_Click() SyS.DBG.enterFunction "PartsAE_cmdCancel_Click" Unload SyS.FRM.Parts_ADDED SyS.DBG.leaveFunction "PartsAE_cmdCancel_Click" End Function
118
HOOFDSTUK 4. SIMS 0.2
4.25
119
PartsEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PartsEV.bas * ’* OBJECT : PartsEV * ’* DESCRIPTION : Event handler for SyS.FRM.Parts * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads sys.frm.parts * ’********************************************************* Public Function Parts_Load() SyS.DBG.enterFunction "Parts_Load" SyS.FRM.Parts.Show 0 SyS.FRM.Main.mnuParts.Checked = True SyS.FRM.Parts.Visible = True SyS.Config.bShowPart = True SyS.iOBJ.Part_LV.Left = PixelsToTwipsX(4)
HOOFDSTUK 4. SIMS 0.2
120
SyS.iOBJ.Part_CBar.Bands.Add 1, "std", , , , frmParts.cbHolderSTD SyS.iOBJ.Part_CBar.Bands.Add 2, "search", , , True, frmParts.cbHolderSRC SyS.iOBJ.Part_SBar.Panels.Add 1, "P1", "Recordcount : " & SyS.DBS.numParts SyS.iOBJ.Part_SBar.Panels.Add 2, "P2", "Results found : (no search)" SyS.iOBJ.Part_SBar.Panels(1).Width = SyS.iOBJ.Part_SBar.Panels(1).Width + 300 SyS.iOBJ.Part_SBar.Panels(2).Width = SyS.iOBJ.Part_SBar.Panels(2).Width + 800 Parts_SetList Parts_FillList SyS.lOBJ.Parts = True SyS.DBG.leaveFunction "Parts_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : UnLoad sys.frm.parts * ’********************************************************* Public Function Parts_QUnload() SyS.DBG.enterFunction "Parts_QUnload" SyS.FRM.Main.mnuParts.Checked = False SyS.Config.bShowPart = False SyS.lOBJ.Parts = False SyS.DBG.leaveFunction "Parts_QUnload" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_Resize * ’* SCOPE : Public * ’* DESCRIPTION : Resizes sys.frm.parts * ’********************************************************* Public Function Parts_Resize() ’ Explicit no DBG STDW_CRF SyS.FRM.Parts, SyS.iOBJ.Part_LV, SyS.iOBJ.Part_CBar, _
HOOFDSTUK 4. SIMS 0.2 SyS.iOBJ.Part_SBar
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_cBar_HeightChanged * ’* SCOPE : Public * ’* DESCRIPTION : Calls resize cuz bar changed * ’********************************************************* Public Function Parts_cBar_HeightChanged() SyS.DBG.enterFunction "Parts_cBar_HeightChanged" STDW_CRF SyS.FRM.Parts, SyS.iOBJ.Part_LV, SyS.iOBJ.Part_CBar, _ SyS.iOBJ.Part_SBar SyS.DBG.leaveFunction "Parts_cBar_HeightChanged" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_cmdAdd_Click * ’* SCOPE : Public * ’* DESCRIPTION : Loads form to add part * ’********************************************************* Public Function Parts_cmdAdd_Click() SyS.DBG.enterFunction "Parts_cmdAdd_Click" SyS.SysBuf.Part_AddEdit = False ’ FALSE=ADD,TRUE=EDIT Load SyS.FRM.Parts_ADDED SyS.FRM.Parts_ADDED.Show 0 SyS.DBG.leaveFunction "Parts_cmdAdd_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_cmdDel_Click * ’* SCOPE : Public * ’* DESCRIPTION : Deletes a Parts * ’*********************************************************
121
HOOFDSTUK 4. SIMS 0.2 Public Function Parts_cmdDel_Click() SyS.DBG.enterFunction "Parts_cmdDel_Click" If SyS.iOBJ.Part_LV.ListItems.Count = 0 Then Exit Function SyS.DBS.Parts_DEL (SyS.iOBJ.Part_LV.SelectedItem.Tag) Parts_FillList SyS.DBG.leaveFunction "Parts_cmdDel_Click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_DragDrop_Out * ’* SCOPE : Public * ’* DESCRIPTION : Assemble ID str and transmits* ’********************************************************* Public Function Parts_DragDrop_Out(ByRef Data As MSComctlLib.DataObject) SyS.DBG.enterFunction "Parts_DragDrop_Out" Data.SetData SEDT_ASM(Val(SyS.iOBJ.Part_LV.SelectedItem.Tag), "AA") SyS.DBG.leaveFunction "Parts_DragDrop_Out" End Function
122
HOOFDSTUK 4. SIMS 0.2
4.26
123
PartsF (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PartsF.bas * ’* OBJECT : PartsF * ’* DESCRIPTION : Provides function for SyS.FRM.Parts * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_FillList * ’* SCOPE : Public * ’* DESCRIPTION : Fills the LV * ’********************************************************* Public Function Parts_FillList() SyS.DBG.enterFunction "Parts_FillList" Dim c As Long SyS.iOBJ.Part_LV.ListItems.Clear For c = 1 To SyS.DBS.numParts SyS.DBS.clearBuf
HOOFDSTUK 4. SIMS 0.2
124
SyS.DBS.Parts_PEEK , c SyS.iOBJ.Part_LV.ListItems.Add c, , SyS.DbBuf.Parts.PartName With SyS.iOBJ.Part_LV.ListItems(c) .SubItems(1) = SyS.DbBuf.Parts.Manufacturer .SubItems(2) = "UNIP" .SubItems(3) = SyS.DbBuf.Parts.Price & " EUR" .SubItems(4) = SyS.DbBuf.Parts.Note .SubItems(5) = SyS.DbBuf.Parts.Stock End With SyS.iOBJ.Part_LV.ListItems(c).Tag = SyS.DbBuf.Parts.PART_UIN SyS.DBG.makeLogEntry "Wrote to tag(" & c & ")::" & SyS.DbBuf.Parts.PART_UIN Next c SyS.DBG.leaveFunction "Parts_FillList" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_SetList * ’* SCOPE : Public * ’* DESCRIPTION : Inits the P_LV * ’********************************************************* Public Function Parts_SetList() SyS.DBG.enterFunction "Parts_SetList" With SyS.iOBJ.Part_LV .View = 3 .ColumnHeaders.Clear With .ColumnHeaders .Add .Add .Add .Add .Add .Add
End With End With SyS.DBG.leaveFunction "Parts_SetList"
HOOFDSTUK 4. SIMS 0.2 End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Parts_StockChange * ’* SCOPE : Public * ’* DESCRIPTION : Changes stock in LV * ’********************************************************* Public Function Parts_StockChange(UIN As Long, corr As Long) As Boolean SyS.DBG.enterFunction "Parts_StockChange" Dim c As Long For c = 1 To SyS.iOBJ.Part_LV.ListItems.Count If Val(SyS.iOBJ.Part_LV.ListItems(c).Tag) = UIN Then Exit For End If Next c If UIN <> Val(SyS.iOBJ.Part_LV.ListItems(c).Tag) Then Parts_StockChange = False ’ Not found UIN SyS.DBG.makeLogEntry "Fixme : bad UIN" SyS.DBG.leaveFunction "Parts_StockChange" Exit Function End If SyS.iOBJ.Part_LV.ListItems(c).SubItems(5) = _ Trim(Str(Val(SyS.iOBJ.Part_LV.ListItems(c).SubItems(5)) + corr)) Parts_StockChange = True SyS.DBG.leaveFunction "Parts_StockChange" End Function
125
HOOFDSTUK 4. SIMS 0.2
4.27
126
PC ADDEDEV (module)
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PC_ADDEDEV.bas * ’* OBJECT : PC_ADDEDEV * ’* DESCRIPTION : Event handler for the PC assembly form * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_AE_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads the pc edit window * ’********************************************************* Public Function PC_AE_Load() SyS.DBG.enterFunction "PC_AE_Load" SetTopMostWindow SyS.FRM.PCs_ADDED, True PCAE_InitLV SyS.lOBJ.Pc_ADDED = True SyS.FRM.PCs_ADDED.Show 0 SyS.DBG.leaveFunction "PC_AE_Load"
HOOFDSTUK 4. SIMS 0.2 End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_AE_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads the PCAE edit window * ’********************************************************* Public Function PC_AE_QUnload() SyS.DBG.enterFunction "PC_AE_QUnload" SyS.lOBJ.Pc_ADDED = False SyS.DBG.leaveFunction "PC_AE_QUnload" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_AE_Cancel * ’* SCOPE : Public * ’* DESCRIPTION : Cancels a PC adding/edit * ’********************************************************* Public Function PC_AE_Cancel() SyS.DBG.enterFunction "PC_AE_Cancel" ’ We reset the parts Parts_FillList ’ Euh ??? Unload SyS.FRM.PCs_ADDED ’ When cancelling, return the items in stock ! ’ Obsolete ? nice 4 dbg SyS.DBG.leaveFunction "PC_AE_Cancel" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_AE_DragDrop_In * ’* SCOPE : Public * ’* DESCRIPTION : Handles incoming object * ’********************************************************* Public Function PC_AE_DragDrop_In(Data As MSComctlLib.DataObject)
127
HOOFDSTUK 4. SIMS 0.2
SyS.DBG.enterFunction "PC_AE_DragDrop_In" Dim UIN As Long, dtype As String, c As Integer If Not DD_goodType(Data) Then SyS.DBG.makeLogEntry "Invalid object dropped in PC_AE_LV" Exit Function End If UIN = SEDT_UIN(Data.GetData(1)) dtype = SEDT_DTYPE(Data.GetData(1)) SyS.DBG.makeLogEntry "DD0: " & UIN & "::" & dtype Select Case SEDT_DTYPE(Data.GetData(1)) Case "AA" ’First we get tha thing SyS.DBS.Parts_PEEK UIN If Not (SyS.DbBuf.Parts.Stock <= 0 Or SyS.DbBuf.Parts.TStock_ <= 0) Then SyS.DBG.makeLogEntry "TStock = " &_ SyS.DbBuf.Parts.TStock & "::Stock = " & SyS.DbBuf.Parts.Stock ’ Okay, so stock is fine for reduction ’ So we reduce, not real, but temp stock SyS.DbBuf.Parts.TStock = SyS.DbBuf.Parts.TStock - 1 ’ and we flush right away SyS.DBS.Parts_EDIT (UIN) ’ flushed.... okay what now ’ Now, we show user stock gone Parts_StockChange UIN, -1 ’ Okay, done ’ Now we add it to the new basket... ’ We still didn’t waste Parts so why not save DBS call ? If PCAE_UINnew(UIN) Then c = SyS.iOBJ.PCAE_LV.ListItems.Count + 1 SyS.iOBJ.PCAE_LV.ListItems.Add c, , "1" SyS.iOBJ.PCAE_LV.ListItems(c).Tag = Str(UIN) SyS.iOBJ.PCAE_LV.ListItems(c).SubItems(1) = _ SyS.DbBuf.Parts.PartName SyS.iOBJ.PCAE_LV.ListItems(c).SubItems(2) = _ SyS.DbBuf.Parts.Manufacturer SyS.iOBJ.PCAE_LV.ListItems(c).SubItems(3) = _ SyS.DbBuf.Parts.TYPE_REF SyS.iOBJ.PCAE_LV.ListItems(c).SubItems(4) = _ SyS.DbBuf.Parts.Price SyS.iOBJ.PCAE_LV.ListItems(c).SubItems(5) = _ SyS.DbBuf.Parts.Note Else
128
HOOFDSTUK 4. SIMS 0.2 PCAE_ChangeStock UIN, 1 End If ’Kayz, thingie is added, the universe saved. End If Case Else SyS.DBG.makeLogEntry "Invalid dType : "_ & SEDT_DTYPE(Data.GetData(1)) End Select SyS.DBG.leaveFunction "PC_AE_DragDrop_In" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PCAE_cmdAdd_Click * ’* SCOPE : Public * ’* DESCRIPTION : Adds new pc * ’********************************************************* Public Function PCAE_cmdAdd_Click() SyS.DBG.enterFunction "PCAE_cmdAdd_Click" ’ loop around the elements in LV ’ edit parts Dim c As Long, UIN As Long, q As Long, pcnuin As Long With SyS.DbBuf.Pc .Description = frmPC_ADDED.txtDescr .Price = Str(frmPC_ADDED.txtPrice) End With SyS.DBS.PC_POKE pcnuin = SyS.DbBuf.Pc.PC_UIN SyS.DBG.makeLogEntry "Okay, made new pc, uin = " & pcnuin For c = 1 To SyS.iOBJ.PCAE_LV.ListItems.Count UIN = SyS.iOBJ.PCAE_LV.ListItems(c).Tag q = CDbl(SyS.iOBJ.PCAE_LV.ListItems(c).Text) SyS.DBS.Parts_PEEK UIN SyS.DbBuf.Parts.Stock = SyS.DbBuf.Parts.TStock
129
HOOFDSTUK 4. SIMS 0.2 ’ This *should* be righto not ? SyS.DBS.Parts_EDIT UIN ’ Updated the stock With SyS.DbBuf.Part_Pc .cPrice = .Part_REF .PC_REF = .Quantity
End With ’ and made the link SyS.DBS.PART_PC_POKE Next c PC_FillLVpc SyS.DBG.leaveFunction "PCAE_cmdAdd_Click" End Function
130
HOOFDSTUK 4. SIMS 0.2
4.28
131
PC ADDEDF (module)
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PC_ADDEDF.bas * ’* OBJECT : PC_ADDEDF * ’* DESCRIPTION : Provide functions for PC_ADDEDF * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PCAE_InitLV * ’* SCOPE : Public * ’* DESCRIPTION : Creates LV headers * ’********************************************************* Public Function PCAE_InitLV() SyS.DBG.enterFunction "PCAE_InitLV" With frmPC_ADDED.LVpart .View = 3 With .ColumnHeaders .Add 1, , "Number" .Add 2, , "Name" .Add 3, , "Manufacturer" .Add 4, , "Type" .Add 5, , "Price" .Add 6, , "Note"
HOOFDSTUK 4. SIMS 0.2 End With End With SyS.DBG.leaveFunction "PCAE_InitLV" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PCAE_UINnew * ’* SCOPE : Public * ’* DESCRIPTION : Checks if a part is new in LV* ’********************************************************* Public Function PCAE_UINnew(UIN As Long) As Boolean SyS.DBG.enterFunction "PCAE_UINnew" Dim c As Long For c = 1 To SyS.iOBJ.PCAE_LV.ListItems.Count If UIN = Val(SyS.iOBJ.PCAE_LV.ListItems(c).Tag) Then PCAE_UINnew = False SyS.DBG.leaveFunction "PCAE_UINnew(false)" Exit Function End If Next c PCAE_UINnew = True SyS.DBG.leaveFunction "PCAE_UINnew(true)" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PCAE_ChangeStock * ’* SCOPE : Public * ’* DESCRIPTION : Changes stock of P in PAELV * ’********************************************************* Public Function PCAE_ChangeStock(UIN As Long, corr As Long) As Boolean SyS.DBG.enterFunction "PCAE_ChangeStock" Dim c As Long For c = 1 To SyS.iOBJ.PCAE_LV.ListItems.Count
132
HOOFDSTUK 4. SIMS 0.2 If UIN = Val(SyS.iOBJ.PCAE_LV.ListItems(c).Tag) Then SyS.iOBJ.PCAE_LV.ListItems(c).Text = _ Trim(Str(Val(SyS.iOBJ.PCAE_LV.ListItems(c)) + corr)) Exit For End If Next c PCAE_ChangeStock = True If Not UIN = Val(SyS.iOBJ.PCAE_LV.ListItems(c).Tag) Then PCAE_ChangeStock = False ’ not found SyS.DBG.makeLogEntry "Fixme : UIN not found" End If SyS.DBG.leaveFunction "PCAE_ChangeStock" End Function
133
HOOFDSTUK 4. SIMS 0.2
4.29
134
PCsEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PCsEV.bas * ’* OBJECT : PCsEV * ’* DESCRIPTION : Event Handler for frmPC * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_Load * ’* SCOPE : Public * ’* DESCRIPTION : Loads frmPC * ’********************************************************* Public Function PC_Load() SyS.DBG.enterFunction "PC_Load" SyS.iOBJ.PC_CB.Bands.Add 1, "STD", , , False, frmPC.cbHolderSTD SyS.iOBJ.PC_CB.Top = PixelsToTwipsY(2) SyS.iOBJ.PC_CB.Left = PixelsToTwipsX(2) SyS.iOBJ.PC_SB.Panels.Add 1, , "Recordcount : " PC_InitLV PC_FillLVpc
HOOFDSTUK 4. SIMS 0.2
SyS.FRM.PCs.Show 0 SyS.FRM.Main.mnuPC.Checked = True SyS.Config.bShowPC = True SyS.lOBJ.Pc = True SyS.DBG.leaveFunction "PC_Load" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_QUnload * ’* SCOPE : Public * ’* DESCRIPTION : Unloads frmPC * ’********************************************************* Public Function PC_QUnload() SyS.DBG.enterFunction "PC_QUnload" SyS.FRM.Main.mnuPC.Checked = False SyS.Config.bShowPC = False SyS.lOBJ.Pc = False SyS.DBG.leaveFunction "PC_QUnload" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_Resize * ’* SCOPE : Public * ’* DESCRIPTION : Resizes PC window * ’********************************************************* Public Function PC_Resize() Dim fP As CoolBar Set fP = SyS.FRM.PCs.CB ’ Pointer bug workaround ’<< im nuts pointer2pointer ??? TLVW_CRF SyS.FRM.PCs, SyS.FRM.PCs.LVpc, SyS.FRM.PCs.LVpart, _ fP, SyS.FRM.PCs.SB, 32 End Function
135
HOOFDSTUK 4. SIMS 0.2
’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_cmdAdd_Click * ’* SCOPE : Public * ’* DESCRIPTION : Opens PCAE window * ’********************************************************* Public Function PC_cmdAdd_Click() SyS.DBG.enterFunction "PC_cmdAdd_click" SyS.SysBuf.PC_AE = False SyS.SysBuf.PC_AE_UIN = -1 ’:? Load SyS.FRM.PCs_ADDED SyS.DBG.leaveFunction "PC_cmdAdd_click" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_cmdEdit_Click * ’* SCOPE : Public * ’* DESCRIPTION : Opens edit window for PC * ’********************************************************* Public Function PC_cmdEdit_Click() SyS.DBG.enterFunction "PC_cmdEdit_Click" If SyS.iOBJ.PC_LVpc.ListItems.Count <= 0 Then SyS.DBG.leaveFunction "PC_cmdEdit_Click >empty LV" Exit Function End If SyS.SysBuf.PC_AE = True SyS.SysBuf.PC_AE_UIN = SyS.iOBJ.PC_LVpc.SelectedItem.Tag ’ Err check for non sel Load SyS.FRM.PCs_ADDED ’ One UIN to unite them all SyS.DBG.leaveFunction "PC_cmdEdit_Click" End Function
136
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_LVpc_ItemClick * ’* SCOPE : Public * ’* DESCRIPTION : Fills parts when click item * ’********************************************************* Public Function PC_LVpc_ItemClick(ByVal Item As MSComctlLib.ListItem) SyS.DBG.enterFunction "PC_LVpc_ItemClick" PC_FillLVPart Item.Tag SyS.DBG.leaveFunction "PC_LVpc_ItemClick" End Function
137
HOOFDSTUK 4. SIMS 0.2
4.30
138
PCsF (module)
’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : PCsF.bas * ’* OBJECT : PCsF * ’* DESCRIPTION : Provides funtions for PCsEV * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_InitLV * ’* SCOPE : Public * ’* DESCRIPTION : Inits PC headers LV * ’********************************************************* Public Function PC_InitLV() SyS.DBG.enterFunction "PC_InitLV" With SyS.iOBJ.PC_LVpc .ColumnHeaders.Add 1, , "PC Description" .ColumnHeaders.Add 2, , "Total price" End With With SyS.iOBJ.PC_LVpart.ColumnHeaders
End With SyS.DBG.leaveFunction "PC_InitLV" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_FillLV * ’* SCOPE : Public * ’* DESCRIPTION : Fills the LV * ’********************************************************* Public Function PC_FillLVpc() SyS.DBG.enterFunction "PC_FillLVpc" Dim c As Long SyS.iOBJ.PC_LVpc.ListItems.Clear For c = 1 To SyS.DBS.numPCs SyS.DBS.PC_PEEK , c With SyS.iOBJ.PC_LVpc .ListItems.Add c, , SyS.DbBuf.Pc.Description .ListItems(c).Tag = SyS.DbBuf.Pc.PC_UIN .ListItems(c).SubItems(1) = SyS.DbBuf.Pc.Price End With Next c SyS.iOBJ.PC_SB.Panels(1).Text = "Recordcount : " & Str(SyS.DBS.numPCs) SyS.DBG.leaveFunction "PC_FillLVpc" End Function
139
HOOFDSTUK 4. SIMS 0.2 ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : PC_FillLVPart * ’* SCOPE : Public * ’* DESCRIPTION : Fills parts for UIN pc * ’********************************************************* Public Function PC_FillLVPart(UIN As Long) SyS.DBG.enterFunction "PC_FillLVPart" ’Kayz, we got the UIN... now we gotta go get the parts... Dim c As Long, n As Long SyS.iOBJ.PC_LVpart.ListItems.Clear For c = 1 To SyS.DBS.numPart_pc SyS.DBG.makeLogEntry "Read ok ???:::" & SyS.DBS.PART_PC_PEEK(, c) SyS.DBG.makeLogEntry "Compare (" & c & "):" & UIN & "<-->" _ & SyS.DbBuf.Part_Pc.PC_REF If SyS.DbBuf.Part_Pc.PC_REF = UIN Then SyS.DBG.makeLogEntry "n=" & n n = n + 1 SyS.DBS.Parts_PEEK SyS.DbBuf.Part_Pc.Part_REF With SyS.iOBJ.PC_LVpart .ListItems.Add n, , SyS.DbBuf.Parts.PartName .ListItems(n).SubItems(1) = SyS.DbBuf.Parts.Manufacturer .ListItems(n).SubItems(2) = SyS.DbBuf.Parts.TYPE_REF .ListItems(n).SubItems(3) = SyS.DbBuf.Parts.Price & "EUR" .ListItems(n).SubItems(4) = SyS.DbBuf.Parts.Note .ListItems(n).SubItems(5) = SyS.DbBuf.Part_Pc.Quantity End With End If Next c SyS.DBG.leaveFunction "PC_FillLVPart" End Function
140
HOOFDSTUK 4. SIMS 0.2
4.31
141
SplashEV (module)
Option Explicit ’********************************************************************************** ’* * * ’* JDP Sims 0.1 - Stock & Invoice Management System. * ’* Copyright (C) 2002 Lennart Yseboodt. * ’* * ’* =================================================== * ’* * ’* This program is free software; you can redistribute it and/or * ’* modify it under the terms of the GNU General Public License * ’* as published by the Free Software Foundation; either version 2 * ’* of the License, or (at your option) any later version. * ’* * ’* This program is distributed in the hope that it will be useful, * ’* but WITHOUT ANY WARRANTY; without even the implied warranty of * ’* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * ’* GNU General Public License for more details. * ’* * ’* You should have received a copy of the GNU General Public License * ’* along with this program; if not, write to the Free Software * ’* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ’* * ’* FILENAME : SplashEV.bas * ’* OBJECT : SplashEV * ’* DESCRIPTION : Event Handler for SyS.FRM.Splash * ’* * ’********************************************************************************** ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_Load * ’* SCOPE : Public * ’* DESCRIPTION : Handles sys.frm.splash_Load()* ’********************************************************* Public Function Splash_Load() If Dir(App.Path & "\logo.jpg") <> "" Then SyS.FRM.Splash.pctStart.Picture = LoadPicture(App.Path & "\logo.jpg") SyS.FRM.Splash.Width = SyS.FRM.Splash.pctStart.Width SyS.FRM.Splash.Height = SyS.FRM.Splash.pctStart.Height End If SyS.FRM.Splash.Visible = True ’ Debugger ->
HOOFDSTUK 4. SIMS 0.2
Set SyS.DBG = New DBG_CLASS SyS.FRM.Splash.tmrDBG.enabled = True End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_tmrDBG_Timer * ’* SCOPE : Public * ’* DESCRIPTION : Handels the Debugger load * ’********************************************************* Public Function Splash_tmrDBG_Timer() If loaded(SyS.DBG) Then With SyS.FRM.Splash .tmrDBG.enabled = False If SyS.DBG.loadSucces Then SyS.DBG.enterFunction "SIMS" SyS.DBG.enterFunction "Splash_tmrDBG_Timer::DBG LOAD SUCCESS" .lblSdebug.Caption = "DONE :)" .lblSdebug.ForeColor = vbGreen .pbarStart.Value = .pbarStart.Value + 25 SyS.DBG.makeLogEntry "DBG LOAD OK" Set SyS.CFG = New CFG_CLASS .tmrCFG.enabled = True SyS.DBG.leaveFunction "Splash_tmrDBG_Timer::DBG LOAD SUCCESS" Else .lblSdebug.Caption = "FAILED :(" .lblSdebug.ForeColor = vbRed ’ Halting execution (CFG needs DBG) End If End With End If End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_tmrCFG_Timer * ’* SCOPE : Public * ’* DESCRIPTION : Handels the Configger load * ’********************************************************* Public Function Splash_tmrCFG_Timer() SyS.DBG.enterFunction "Splash_tmrCFG_Timer"
142
HOOFDSTUK 4. SIMS 0.2
143
Static fail As Boolean SyS.DBG.makeLogEntry "CFG_Load :: fail :: " & IIf(fail, "TRUE", "FALSE") If loaded(SyS.CFG) Then With SyS.FRM.Splash .tmrCFG.enabled = False If SyS.CFG.loadSucces Then .lblSconfig.Caption = "DONE :)" .lblSconfig.ForeColor = vbGreen SyS.DBG.makeLogEntry "CFG LOAD OK" .pbarStart.Value = .pbarStart.Value + 25 Set SyS.DBS = New DBS_CLASS .tmrDBS.enabled = True Else If fail Then .lblSconfig.Caption = "FAILED :(" .lblSconfig.ForeColor = vbRed SyS.DBG.makeLogEntry "CFG LOAD FAIL" Else SyS.DBG.makeLogEntry "Trying to make new config on the fly" Set SyS.CFG = Nothing DoEvents Set SyS.CFG = New CFG_CLASS ’ Retry DoEvents fail = True .tmrCFG.enabled = True End If ’Halting execution (No config, no defaults...) << Change, imp f already !!! End If End With End If SyS.DBG.leaveFunction "Splash_tmrCFG_Timer" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_tmrDBS_Timer * ’* SCOPE : Public * ’* DESCRIPTION : Handels the Database load * ’********************************************************* Public Function Splash_tmrDBS_Timer()
HOOFDSTUK 4. SIMS 0.2 SyS.DBG.enterFunction "Splash_tmrDBS_Timer" If loaded(SyS.DBS) Then With SyS.FRM.Splash .tmrDBS.enabled = False If SyS.DBS.loadSucces Then .lblSdatabase.Caption = "DONE :)" .lblSdatabase.ForeColor = vbGreen SyS.DBG.makeLogEntry "DBS LOAD OK" .pbarStart.Value = .pbarStart.Value + 40 .tmrALL.enabled = True Else .lblSdatabase.Caption = "FAILED :(" .lblSdatabase.ForeColor = vbRed SyS.DBG.makeLogEntry "DBS LOAD FAIL" frmSplash.tmrDBS.enabled = False frmSplash.CmdNewDB.Visible = True frmSplash.cmdOpenDB.Visible = True End If End With End If SyS.DBG.leaveFunction "Splash_tmrDBS_Timer" End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_tmrALL_Timer * ’* SCOPE : Public * ’* DESCRIPTION : Finalisez load * ’********************************************************* Public Function Splash_tmrALL_Timer() ’ If we got here, tha core should be fine. Static NT As Integer SyS.DBG.enterFunction "Splash_tmrALL_Timer" SyS.FRM.Splash.pbarStart.Value = 100 SyS.FRM.Splash.lblSStartup.ForeColor = vbGreen SyS.FRM.Splash.lblSStartup.Caption = "DONE :)" doUpdate (1000) NT = NT + 1
144
HOOFDSTUK 4. SIMS 0.2 If NT = 1 Then SyS.DBG.leaveFunction "Splash_tmrALL_Timer*" Exit Function End If SyS.FRM.Splash.tmrALL.enabled = False SyS.DBG.makeLogEntry "Unload splash..." Unload SyS.FRM.Splash doUpdate (1000) ’Do Until Not loaded(sys.frm.splash) ’ DoEvents ’Loop SyS.DBG.leaveFunction "Splash_tmrALL_Timer>sys.frm.main_Load" Load SyS.FRM.Main End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_cmdNewDB_Click * ’* SCOPE : Public * ’* DESCRIPTION : Button for new DBase * ’********************************************************* Public Function Splash_cmdNewDB_Click() SyS.DBG.enterFunction "Splash_cmdNewDB_Click" frmSplash.lblSdatabase.Caption = "New..." frmSplash.lblSdatabase.ForeColor = vbWhite With frmSplash.cdgDBase .DefaultExt = "mdb" .DialogTitle = "Please select where to save the new database" .InitDir = App.Path .filename = "Core" .ShowSave End With SyS.DBG.makeLogEntry "SelFN=" & frmSplash.cdgDBase.filename If frmSplash.cdgDBase.filename = "" Or Dir(frmSplash.cdgDBase.filename)_ <> "" Then Exit Function
145
HOOFDSTUK 4. SIMS 0.2
SyS.DBG.makeLogEntry "Survived filenamecheck" SyS.DBG.makeLogEntry "Going to create the database..." frmSplash.CmdNewDB.Visible = False frmSplash.cmdOpenDB.Visible = False If SyS.DBS.makeNewDBase(frmSplash.cdgDBase.filename) Then SyS.Config.dbaseFileName = frmSplash.cdgDBase.filename Set SyS.DBS = Nothing Set SyS.DBS = New DBS_CLASS ’ Retry :) frmSplash.tmrDBS.enabled = True Else MsgBox "Database creation failed, refer to Debug logs", vbCritical End If SyS.DBG.leaveFunction "Splash_cmdNewDB_Click"
End Function ’********************************************************* ’* Sims 0.1 * ’* FUNCTION/SUB NAME : Splash_cmdOpenDB_Click * ’* SCOPE : Public * ’* DESCRIPTION : Button to search DBase * ’********************************************************* Public Function Splash_cmdOpenDB_Click() SyS.DBG.enterFunction "Splash_cmdOpenDB_Click" frmSplash.lblSdatabase.Caption = "Open..." frmSplash.lblSdatabase.ForeColor = vbWhite With frmSplash.cdgDBase .DefaultExt = "mdb" .DialogTitle = "Locate database" .InitDir = App.Path .ShowOpen End With If frmSplash.cdgDBase.filename = "" Or Dir(frmSplash.cdgDBase.filename) _ = "" Then Exit Function
146
HOOFDSTUK 4. SIMS 0.2
SyS.Config.dbaseFileName = frmSplash.cdgDBase.filename Set SyS.DBS = Nothing Set SyS.DBS = New DBS_CLASS frmSplash.tmrDBS.enabled = True SyS.DBG.leaveFunction "Splash_cmdOpenDB_Click" End Function
147
Deel II Overige deeltaken
148
Hoofdstuk 5 Bevestiging medewerking EDNOTE: Replace by letter
149
Hoofdstuk 6 Probleemdefinitie 6.1
Het bedrijf
Mijn (virtueel) GIP bedrijf voor Informatica is een relatief kleine computerwinkel. Deze winkel heeft een zeer ruime voorraad 2de hands en oudere hardware. Momenteel ligt deze ordeloos opgeslagen in het magazijn. De uiteindelijk bedoeling is om van al deze hardware zoveel mogelijk goede 2de hands computers te maken die dan voor een zacht prijsje de deur uit gaan.
6.2
Doel van het programma
Het is de bedoeling dat alle onderdelen worden ingegeven en opgeslagen in een database. Als men met de assemblage begint, selecteert men alle onderdelen die in de computer zitten, de onderdelen verdwijnen uit de stock en een nieuwe record wordt aangemaakt in een andere tabel, waar de volledige computer worden opgeslagen. Onderdelen kunnen ook afzonderlijk verkocht worden en ook hiervoor kan een factuur worden afgedrukt. Bij verkoop van een computer, komen de onderdelen in een tabel waar alle verkochte onderdelen worden opgeslagen, uiteraard met een referentie naar de klant en dus de computer waar ze inzitten. Men kan ook een factuur laten afdrukken met daarop de informatie over de winkel en de klant, de onderdelen die in de computer zitten en de totaalprijs wordt berekend. Wordt er een computer binnengebracht, kan men meteen zien of deze nog in garantie is en welke onderdelen erin zitten. Dan controleert het programma of dergelijk onderdeel nog in stock is. Met deze manier van gecentraliseerde opslag vermijdt men het tijdrovende zoeken in het (rommelige) magazijn, men wint niet alleen tijd voor zichzelf, maar de klant moet ook minder lang wachten.
150
Hoofdstuk 7 Algemeen beeld van het bedrijf (Frans) Forest & Bold est une jeune entreprise, elle a 9 ans. L’entreprise a ´et´e ´etablie en 1992 par M K. Meeuwels, qui voulait cr´eer une agence publicitaire. Maintenant F&B a une grande client`ele vari´ee, le chiffre d’affaires augmente constamment. F&B est sp´ecialis´e en de grandes campagnes pour des moyennes et grandes entreprises. Ils font des affiches ´etonnantes, des bannir pour l’Internet ou une page branch´ee dans un magazine. Les cr´eateurs utilisent Photoshop, Flash et Quark, ¸ca assure des pages tr`es soign´ees et attractives. En 1992 M Meeuwels d´ecidait de cr´eer une agence publicitaire, la BVBA Forest & Bold ´etait n´ee. Il r´enovait la maison ou il a grandi. Les chiffres d’affaires et le nombre d’employ´ers ont grandi constamment. Maintenant F&B emploient 7 personnes. Pendant les vacances ils engagent des ´etudiants. Forest & Bold est une entreprise en bonne sant´e, la crise ”.com” a d´etruit beaucoup d’entreprises, mais Forest & Bold n’ont pas eu de probl`emes. Le total de transactions est de plus de 150.000.000 BEF, il est donc clair qu’ils ont un bon management, et un bilan stable. Pour l’avenir ils voient un avancement poursuivi, ils n’ont pas l’intention de faire des changements majeurs. Ils progressent avec la technologie d’aujourd’hui sans se plonger dans une aventure dangereuse. Je ne vais pas ´ecrire un programme pour cette entreprise parce qu’ils utilisent des Macs. Donc j’ai d´ecide d’ ´ecrire un programme pour le magasin o` u j’ai travaill´e. Ils ont une grande r´eserve de parts qui doit ˆetre sauv´e dans un data base. Si un client veut acheter une pi`ece, le vendeur peut voir imm´ediatement si la pi`ece est encore de stock, sans devoir chercher dans le magasin. S’ils assemblent un ordinateur, le programme sait que certaines parts sont utilis´ees, quand une part ne marche plus, le vendeur peut voir (sans ouvrir l’ordinateur!), si la pi`ece est encore en stock pour ˆetre remplac´ee, si non, le programme fait la suggestion pour une autre pi`ece qui est compatible. 151
Hoofdstuk 8 Analyse van een arbeidsovereenkomst 8.1
Situering
Ik zal een arbeidsovereenkomst bespreken voor een handelsvertegenwoordiger in de telecommunicatie en reclame sector. De overeenkomst bestaat uit 3 paginas met 13 artikels, waarvan 1 artikel verwijderd werd, de overeenkomst werd ook anoniem gemaakt.
8.2
Algemeen
De overeenkomst is een contract tussen Koen Meekels, de oprichter en algemeen directeur van Forest & Bold, en de handelsvertegenwoordiger. De overeenkomst begint op 16 augustus 1999, voor onbepaalde duur. Er staat een referentie naar de wet van 3 juli 1978 betreffende de arbeidsovereenkomsten. Dit contract is dus een aan Forest & Bold aangepaste versie van het standaard contract dat de wet voorziet.
8.3
Artikel 1
De eerste 6 maanden worden als proeftijd beschouwd.een verlenging is niet mogelijk (handelsvertegenwoordiger), dus na 6 maanden wordt het een verbintenis van onbepaalde duur.
152
HOOFDSTUK 8. ANALYSE VAN EEN ARBEIDSOVEREENKOMST
8.4
153
Artikel 2
Dit artikel omschrijft algemeen het werk dat de handelsvertegenwoordiger moet uitvoeren. De vertegenwoordiger moet de diensten en producten die Forest & Bold aanbiedt, vertegenwoordigen bij klanten en proberen te verkopen. Door deze overeenkomst verliest hij het recht om zelfstandig dit soort diensten of producten aan te bieden of te verkopen, bij de klanten van de onderneming of in de sector. Dit is een normale stap: gezien de informatie waarover de vertegenwoordiger beschikt zou hij op oneerlijke wijze kunnen concurreren met de onderneming. De duur van de verbodsperiode is 1 jaar, zoals vermeld in artikel 11.
8.5
Artikel 3
In dit artikel staan de werkuren vermeld. Van maandag tot donderdag is dit van 9 uur tot 17.45, met 1 uur pauze tussen 12.30 en 13.30. Op vrijdag eindigt de werkdag om 16.45. Het is dus een werkweek van 37 uur en 45 minuten. Het maximum van 38 uur wordt dus niet overschreden. De uren zullen wel vrij onregelmatig zijn daar het begin van de werkdag overeenstemt met het bezoeken van de eerste klant en het einde met het bezoeken van de laatste klant.
8.6
Artikel 4
De handelsvertegenwoordiger moet zich om 9 uur aanmelden bij de hoofdzetel van de onderneming voor instructies (tenzij anders afgesproken). Hij moet zich houden aan de afspraken van de werknemer inzake de klanten die bezocht worden, de aangeboden artikelen en de verkoopsvoorwaarden. De handelsvertegenwoordiger moet dagelijks de bestellingen aan de werkgever overmaken in de vorm van bestelbons waarop de aard van het werk of de hoeveelheid goederen staan alsmede de overeengekomen prijs van deze goederen. Er moet ook een dagelijks rapport afgegeven worden waarop de naam en het adres van de klanten staan die de vertegenwoordiger bezocht heeft alsmede de tijd bij elk van hen besteed. Zo kan de werkgever de prestaties van de vertegenwoordiger evalueren.
8.7
Artikel 5
De vaste brutowedde is 58.000 BEF, dit wordt echter aangevuld met een commissieloon : Hij krijgt 5% op alle bestellingen van klanten die door hem zijn geworven, dit voor 1 jaar vanaf facturatiedatum van de eerste factuur. (Dit na aftrek van kosten, en creditnota’s). Wordt de order niet uitgevoerd, buiten de schuld van de
HOOFDSTUK 8. ANALYSE VAN EEN ARBEIDSOVEREENKOMST
154
vertegenwoordiger, dan krijgt hij 5% van de prijs die op de bestelbon vermeld staat. De werkgever heeft 8 dagen tijd om bezwaar aan te tekenen tegen een bestelbon. De bezoldiging (en het commissieloon, indien van toepassing) wordt giraal gestort op de bankrekening van de vertegenwoordiger.
8.8
Artikel 6
Voordelen zoals 13de maand en productiepremie dienen beschouwd te worden als vrijgevigheid van de werkgever m.a.w de vertegenwoordiger heeft er geen recht op, omdat deze voordelen niet gewaarborgd worden met een Koninklijk Besluit in de CAO van het bevoegd paritair comit´e.
8.9
Artikel 7
Alles wat de vertegenwoordiger cre¨eert tijdens de uitvoering van zijn werk wordt overgedragen aan de werkgever, die deze werken mag exploiteren, zelfs op manieren die op het ogenblik van het afsluiten van het contract nog niet bekend zijn.
8.10
Artikel 8
De handelsvertegenwoordiger moet controleren of de klanten die hij aanbrengt voldoende kredietwaardig zijn. Indien hij dit niet doet kan de werkgever bij niet betalen van de klant van de vertegenwoordigereen vergoeding eisen die het commissieloon niet overschrijdt, tenzij bij grove fouten of nalatigheid.
8.11
Artikel 9
Indien de vertegenwoordiger niet in staat is klanten te bezoeken, heeft de werkgever het recht om dit zelf te doen of dit te laten doen door een door hem gekozen vertegenwoordiger. De plaatsvervanger heeft dan recht op het commissieloon van de door hem afgesloten contracten. Indien er een betwisting bestaat beslist de klant door wie hij zich heeft laten overhalen om met Forest & Bold een contract af te sluiten.
8.12
Artikel 10
Tijdens en na de duur van zijn arbeid bij Forest & Bold is de vertegenwoordiger gehouden tot geheimhouding inzake de fabricatiegeheimen en proc´ed´es, de klanten en de verkoopsvoorwaarden, die gebruikelijk zijn bij de onderneming. Alle informatie
HOOFDSTUK 8. ANALYSE VAN EEN ARBEIDSOVEREENKOMST
155
die hij van de werkgever ontvangt dient teruggegeven te worden bij het be¨eindigen van het contract.
8.13
Artikel 11
Het is de vertegenwoordiger verboden om gedurende zijn werkzaamheid bij Forest & Bold, en 1 jaar daarna, arbeid te verrichten voor derden die concurrentie vormen voor de onderneming. Hij mag tot 1 jaar na het be¨eindigen van zijn contract niet opnieuw werkzaam zijn in een onderneming in dezelfde sector. Artikel 12 werd verwijderd
8.14
Artikel 13
De vertegenwoordiger bevestigt hiermee een kopie van het arbeidsreglement te hebben ontvangen.
8.15
Artikel 14
Na de proefperiode ontvangt de vertegenwoordiger een bedrijfswagen bestemd voor professioneel gebruik. De vertegenwoordiger dient de wagen goed te behandelen en er alle zorg voor te dragen dat de wagen de staat bewaart waarin hij zich bevindt. Indien de wagen de normale onderhoudsbeurten ondergaat zijn alle kosten voor de werkgever, dit uitgezonderd voor boetes die ten laste van de werknemer vallen.
8.16
Artikel 15
De vertegenwoordiger en de werkgever aanvaarden de lijst die bij het contract zit. Deze lijst bevat de klanten van de onderneming in de sector aan de handelsvertegenwoordiger toegewezen. Hij kan deze lijst niet gebruiken voor priv´e-doeleinden, noch overdragen aan derden, omdat de lijst eigendom van de onderneming blijft.
Hoofdstuk 9 Gebruikershandleiding Sims Deze handleiding is bedoelt voor personen die Sims willen gebruiken om hun stock te beheren. Indien U aanpassingen wenst te maken aan Sims, kan U best ook de Programmeurshandleiding lezen, deze geeft een overzicht van de in Sims aanwezige klassen en hun functies.
9.1
Systeemvereisten
De minimum systeemvereisten van het besturingssysteem dat U draait volstaan. Een systeem waar Sims gegarandeerd op draait : • Intel/AMD/VIA/Cyrix x86 compatibele CPU met 300 MhZ kloksnelheid • 64 Mb SDRAM/EDORAM • 10 Mb hardeschijf ruimte (meer is vereist voor de database) • Een VGA scherm met een resolutie van 800x600. 1280x1024 is aanbevolen. • Muis
9.2 9.2.1
Sims downloaden Hoe downloaden
U kan de laatste versie van Sims vinden op http://users.skynet.be/bk317723/Sims.zip Dit bestand bevat zowel de broncode als de uitvoerbare vorm van Sims. U klikt op de link hierboven, er zal een venster verschijnen : Klik op save. Daarna kiest u waar u het bestand wil opslaan en het downloaden begint.
156
HOOFDSTUK 9. GEBRUIKERSHANDLEIDING SIMS
9.2.2
157
Sims uitpakken
Nadat u Sims hebt gesaved, zal u het moeten uitpakken, u kan dit met het programma winzip 8.0 doen, te vinden op www.winzip.com. Als u niet weet hoe u een zip bestand kan uitpakken, moet u eerst de Winzip handleiding lezen.
9.3
Sims installeren
9.3.1
Bestanden
Nadat u het programma hebt uitgepakt wordt er een map ”Sims” gemaakt met volgende inhoud : • Bas • Bin • Cls • Doc • Frm • Prj • Var Indien u Sims enkel wil gebruiken zijn enkel de onderlijnde mappen van belang. In Bin vindt u het uitvoerbare bestand (Sims.exe) en de bestanden die nodig zijn om Sims te laten werken. In Doc bevindt zich de gebruikershandleiding voor Sims, die u nu aan het lezen bent, alsook de programmeerhandleiding, die enkel van belang is als u Sims wil aanpassen.
9.3.2
Sims opstarten
Nu moet u de executable van Sims zoeken waar u deze ge¨ınstalleerd heeft, zie hier voor de bijgevoegde schermafdruk, deze staat op pagina 161. De eerste keer dat Sims opstart moet het een database aanmaken. Dit is een eenmalige procedure. Om Sims te starten dubbelklikt u op Sims.exe (zie p. 161) U ziet dan het opstartlogo van Sims, dat stopt bij het openen van de database (schermafdruk UM2, p161) Bij opening database staat een rood ”Failed”. Dit is normaal als u de eerste keer opstart. U kan nu een nieuwe database aanmaken door op ’new’ te klikken, en op
HOOFDSTUK 9. GEBRUIKERSHANDLEIDING SIMS
158
’save’ te klikken in het ”save as”dialoogvenster. U mag de database zelf een naam geven of de standaardnaam gebruiken. Nota: Als u op ”open” klikt dan kan u een al bestaande database openen. Dit kan van pas komen als u de map van Sims verplaatst hebt. Na deze stap start Sims gewoon verder op.
9.3.3
Mogelijke fouten
Er kunnen een aantal fouten optreden als u start : • Het laden van de debugger faalt : waarschijnlijk start u Sims van een CDROM op, kopieer het programma naar de harde schijf, en zorg ervoor dat er schrijftoegang in de map van Sims is. Dit doet u door op de map van Sims te rechtsklikken → ”properties”, en dan het attribuut ”read-only”uit te zetten. Dit vakje ”Alleen lezen”moet uitgeschakeld zijn.( zie figuur UM3 op pagina 163) • Het laden van het configuratiebestand faalt : Dit kan enkel en alleen als het bestand config.cfg in die map reeds bestaat en er lees, noch schrijfrechten op zijn. Dit kan bijna niet onopzettelijk voorkomen, mocht dit toch gebeuren, verwijder dan config.cfg, Sims zal dit bestand dan opnieuw aanmaken. • Het laden van de database faalt, ondanks dat deze bestaat,dit kan veroorzaakt worden door vrij veel zaken : - Geen leestoegang op het bestand. - Het bestand is corrupt. - Het bestand is reeds geopend. Nu komt u in het hoofdscherm van Sims terecht. Voor een beeldafdruk hiervan kijk op pagina 163, UM4.
9.4
Configuratie
Sims is een complex programma dat zeer veel mogelijkheden heeft. De snelste manier om Sims aan uw wensen aan te passen is het configuratiebestand aan te passen. U kan het configuratiebestand met eender welke text editor aanpassen, bijvoorbeeld notepad. Het configuratiebestand bevindt zich in de directory van Sims en heet config.cfg.
HOOFDSTUK 9. GEBRUIKERSHANDLEIDING SIMS
9.4.1
159
Config.cfg
Regels die met ”#”beginnen zijn commentaar en worden genegeerd. Caption De titel van het hoofdformulier Database Het pad naar de database. ShowPartOnBoot Of het scherm met de onderdelen moet getoond worden bij het opstarten. Dit mag enkel de waarde ’TRUE’ of ’FALSE’ hebben. ShowCustomersOnBoot Hetzelfde voor het scherm met de klantenlijst ShowPCsOnBoot Hetzelfde voor het scherm met de Computers ShowInvoiceOnBoot Hetzelfde voor het scherm met facturen FieldNA Een woord waarmee u wilt aanduiden dat een veld leeg is. DefaultCurrency De ISO code van de munt waarmee u wil werken.
9.5
De klantenlijst
In dit scherm, dat u kan openen door in het hoofdscherm op Windows en dan op Customers te klikken, beheert u uw klantenbestand. Centraal is een lijst van al uw klanten, onderaan ziet u hoeveel klanten er in de lijst zijn, en indien u op een klant gezocht hebt, hoeveel resultaten gevonden werden. De 2 balken bovenaan zijn voor het beheren van de klanten.
9.5.1
Klanten toevoegen
Om een nieuwe klant te maken, klikt u op ’add’, er verschijnt dan een venster : Alle velden zijn optioneel, u mag invullen wat u wil. Indien u wilt aangeven dat een veld niet bestaat typt u het woord dat u in het configuratiebestand hebt gedefinie¨erd als zijnde ”fieldNA”. Dit is echter optioneel. Indien u meerdere klanten wil toevoegen, zet dan ”close on add” af, dan blijft het scherm open na het toevoegen van de klant; zodat u meteen een nieuwe kan bijvoegen. Indien u ”Clear on add” aanzet, dan worden de velden leeggemaakt, dit is nuttig als het om een compleet andere klant betreft, laat u het echter uitstaan dan blijven de velden behouden.
9.5.2
Klanten verwijderen
Om een klant te verwijderen, klikt u op deze in de lijst en daarna op delete, de klant wordt dan verwijderd. Deze mogelijkheid is niet beschikbaar als u op die moment de klant aan het bewerken bent.
HOOFDSTUK 9. GEBRUIKERSHANDLEIDING SIMS
9.5.3
160
Klantgegevens wijzigen
Indien u de gegevens van een klant wil wijzigen, dan klikt u op de klant en daarna op ”edit”, u kan dan de foutieve velden wijzigen en daarna de klant terug toevoegen, analoog met het maken van een nieuwe klant.
9.5.4
Zoeken
Het kan nodig zijn om op een bepaald criteria klanten te zoeken indien de lijst uitgebreider wordt. Dan typt u gewoon in het tekstveld naast de knop ”search” de term die u wilt zoeken. Daarna klikt op search en in de lijst verschijnen enkel nog de klanten die ergens in hun gegevens die term bevatten. Wenst u opnieuw te zoeken dan kan U deze procedure herhalen. Indien u terug alle velden wil klikt u op ”show all”. Het vakje ”in result” is voor geavanceerde zoekopdrachten, stel u wenst een lijst van alle klanten die Janssens heten, en die in Antwerpen wonen. Dan zoekt u eerst op Janssens : alle klanten met de naam Janssens blijven dan over. Indien u dan het vakje ”in result” aankruist en zoekt op Antwerpen, dan blijven slechts degenen over die in Antwerpen wonen.
Dit document is bedoelt voor redelijk ervaren VB programmeurs die aanpassingen willen doen aan Sims, bijvoorbeeld om het programma aan te passen aan hun eigen noden, of fouten willen verbeteren. Voor U dit doet is het aan te raden om de licentie-overeenkomst door te lezen. Indien U simpelweg Sims wil leren gebruiken moet u de Gebruikershandleiding lezen, en niet deze Programmeurshandleiding.
10.2
Licentieovereenkomst
Deze handleidingen zijn onderworpen aan de bepalingen gesteld in de GNU General Free Documentation License (verie 2).
10.3
Licentieovereenkomst van Sims
Dit Programma is vrije software; u kan het verspreiden en/of wijzigen onder de bepalingen van de GNU Algemene Publieke Licentie, zoals uitgegeven door de Free Software Foundation; oftewel versie 2 van de Licentie,of (naar vrije keuze) een latere versie. Dit Programma is verspreid met de hoop dat het nuttig zal zijn maar ZONDER EENDER WELKE GARANTIE; zelfs zonder de impliciete garantie van VERKOOPBAARHEID of GESCHIKTHEID VOOR EEN BEPAALD DOEL. Zie de GNU Algemene Publieke Licentie voor meer details.
164
HOOFDSTUK 10. PROGRAMMEURSHANDLEIDING SIMS
10.4
165
Software vereisten voor Sims
Als U aanpassingen aan de broncode van Sims wil brengen hebt U eerst en vooral de broncode nodig die bij het pakket zit. • Windows 95 of hoger (voor Windows NT4 is Service Pack 5 vereist) • Visual Basic 6.0 Professional of Enterprise. • Service Pack 5.0 voor Visual Basic 6.01
10.5
De broncode
10.5.1
Directory structuur van de bronbestanden
Als U de bestanden uitgepakt hebt uit het Winzip bestand, komen deze in een map met de naam ”Sims” en daarachter het versienummer. In deze map zitten de volgende subdirectorys: BAS In deze map zitten alle standaardmodule bestanden van Sims. BIN In deze map zit een pregecompileerde versie van Sims. CLS In deze map bevinden zich de klasse bestanden van Sims. FRM Hier staan alle formulier-definitie bestanden. PRJ In deze map zit het project bestand en het VB configuratie bestand voor Sims. VAR In deze map vindt u de PSD versies van de logos alsmede alle tekstbestanden zoals de Readme en het Changelog.
10.5.2
Objecten & Functies
SyS Het hoofdobject dat alle andere objecten bevat heet SyS, en wordt publiek gedeclareerd in de module MEMCORE. Het is een type dat alle andere objecten bevat. 1
U kan dit verkrijgen op www.microsoft.com
HOOFDSTUK 10. PROGRAMMEURSHANDLEIDING SIMS
166
DBG DBG is van het type DBG CLASS, deze klasse dient om het debuggen van het Programma te vergemakkelijken. In het begin van het programma wordt dit object ge¨ınitialiseerd, het opent dan een bestand voor schrijven en schrijft daar de datum en het uur naar weg. De bestandsnaam is DEBUG en daarna de datum en het uur. Als het DBG niet lukt om een bestand te openen, zet het zijn publieke boolean ’loadsucces’ op ’false’, anders op ’true’. Indien U functies aanroept als loadSucces op ’false’ staat, worden deze genegeerd. Er is geen controle voorzien als u manueel loadSucces wijzigt en daarna functies aanroept. Indien het object vernietigd wordt, dan sluit het zijn debugbestand.
enterFunction Elke functie van Sims begint met de regel SyS.DBG.enterFunction(functienaam) Deze functie schrijft dan weg in het debugbestand dat de functie werd aangeroepen, en verhoogt dan het aantal tabs voor een lijn geschreven wordt.
leaveFunction Voor U een functie be¨eindigt moet u Leavefuntion aanroepen met dezelfde functie naam, het aantal tabs vermindert dan terug. Als u met een foutenafhandelaar werkt, moet U ervoor zorgen dat ook daar leaveFunction wordt aangeroepen, anders klopt de structuur van het Debugbestand niet meer.
makeLogEntry Met deze functie kan u een string naar keuze wegschrijven, deze bevindt zich dan onder de aanroep van de laatste functie.
Maken en vernietigen van een Debugobject Het standaardobject SyS.DBG wordt gemaakt en vernietigd in Main() en shutDownSys() respectievelijk, indien u om een uitzonderlijke reden een nieuw object wil maken, kan u dit op volgende wijze : Dim as DBG_CLASS Set = new DBG_CLASS Door dit te doen wordt een DBG object gemaakt en zijn constructor aangeroepen die het bestand maakt. Vernietig voor het be¨eindigen van het programma zelfgemaakte objecten met :
HOOFDSTUK 10. PROGRAMMEURSHANDLEIDING SIMS
167
Set = Nothing CFG CFG is het object dat het configuratiebestand regelt. Het configuratiebestand is zeer belangrijk omdat er erg veel opties in opgeslagen zitten. Ik heb gekozen om te werken met een configuratiebestand en niet met het register omdat dit prettiger is voor geavanceerde gebruikers die graag zelf de configuratiebestanden aanpassen. Het configuratie bestand heet config.cfg, u kan een andere naam kiezen als u daarvoor de broncode aanpast.
Constructie Bij het initialiseren van het configuratiebestand wordt eerst gecontroleerd of het bestand bestaat en of er leestoegang op is. Als dit niet het geval is, wordt net zoals bij DBG de publieke boolean loadsucces op false gezet. Is het bestand leesbaar dan wordt het lijn per lijn ingelezen. Regels die beginnen met een hekje (#) worden genegeerd, andere regels worden behandeld. Een regel bestaat altijd uit een woord, daarna een ’=’ en daarna een waarde of weer een woord. Regels zonder ’=’ zijn ongeldig en worden genegeerd. Indien het eerste woord herkend wordt, dan wordt de waarde achter het ’=’ teken in de correcte variable opgeslagen. Deze variablen bevinden zich in SyS.Config
SyS.Config SyS.Config, is een type dat de variabelen bevat die worden ingevult door CFG bij het starten van het Programma. Bij het afsluiten worden deze waarden weggeschreven in het configuratiebestand. SyS.Config wordt gedefin¨eerd als een CONFIG TP in Memcore.bas.
Destructie Bij destructie wordt het configuratiebestand weggeschreven. Indien er hierbij een fout optreedt, wordt dit weggeschreven in de debugbestanden.
On the fly aanmaken van de config file Indien bij het laden van Sims het configuratiebestand niet gevonden wordt, wordt het object vernietigd waardoor de standaardwaarden worden weggeschreven, daarna wordt nog ´e´en maal geprobeerd om het terug aan te maken, indien dit lukt wordt er gewoon voortgegaan met het laden.
HOOFDSTUK 10. PROGRAMMEURSHANDLEIDING SIMS
168
DBS DBS is de klasse die met de database communiceert. Ik heb gekozen om de reeds zeer abstracte JET-engine nogmaals te omwikkelen met een API (DBS), omdat men dan vrij makkelijk Sims zou kunnen aanpassen om bvb. ADO ipv DAO te gaan gebruiken, of nog extremer, men zou DBS kunnen laten communiceren met een DBS server (die u dan ook moet schrijven) om zo de database door meerdere gebruikers te laten gebruiken over internet of netwerk. De database heeft deze mogelijkheid : als een veld in gebruik is krijgt de desbetreffende record de status ’LOCKED’, dit wordt in beperkte mate slechts gebruikt door Sims, maar U hoeft dan geen locking mechanisme meer te maken als u netwerk functionaliteit wenst. In praktijk wordt dan het veld ’LOCKED’ van een record in recordset op een waarde anders dan 0 gesteld. De functies setLock(), clearLock() en isLocked() bedienen dit mechanisme in elke Sims versie hoger dan 0.1.1-pre6.
Constructie Bij het maken van het DBS object, gaat DBS kijken in SyS.Config, waar de database gevonden zou moeten worden, het zal dan proberen het private DB object in DBS te maken, en indien dit lukt de recordsets verbinden. Bij succes wordt net zoals bij de andere klassen de publieke boolean loadSucces op ”true” gezet. Indien het mislukt hebt u de interessante mogelijk om een nieuwe database te maken met makeNewDBase
makeNewDBase Make newDBase neemt een string als argument, die een niet bestaand bestand zou moeten zijn. Indien het bestand niet bestaat en de schijf schrijfbaar is cre¨eert DBS er een nieuwe Sims compatibele maar lege database. In plaats van een nieuwe database te maken kan u ook altijd dezelfde truc toepassen als met CFG door SyS.Config aan te passen en proberen DBS opnieuw te maken. Dit wordt toegepast in de ”Open” knop op het Splash screen, als er geen database gevonden wordt.
I/O Functies De I/O functies werken allemaal hetzelfde. Om een record te lezen gebruikt u PEEK(UIN,ABS), met UIN xOr ABS niet (-1) als waarde hebbend. De andere functies nemen enkel een UIN als argument. • EDIT(UIN) Record overschrijven met DBBuf. • POKE(VOID)Record toevoegen.
HOOFDSTUK 10. PROGRAMMEURSHANDLEIDING SIMS
169
• DEL(UIN)Record verwijderen. (Status<<1;). • (UIN || VOID) De eigelijke datatransfer gebeurt in het globale object SyS.DBbuf, u moet hier opletten voor datacorruptie! Na een aanroep van DBS kan u de gehele DBBuf niet meer gebruiken. Als u toch DBS calls wil uitsparen moet U zich eerst grondig bekend maken met de desbetreffende functies.
Destructie Bij het vernietigen van het DBS object ( door set