home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************************************
- * PROGRAM NAME: KLNT.PRG
- * CUSTOMER DATABASE SCREEN
- * SAMPLE BUSINESS APPLICATION PROGRAM
- * LAST CHANGED: 080692
- * WRITTEN BY: Borland International Inc.
- *****************************************************************************************
- * FILES USED:
- * Database file = Klnt.dbf (Customer file)
- * Index file = Klnt.mdx
- * TAG: Klnt = klant_nr <= Master index
- * External procedure file = Biblio.prg
- *****************************************************************************************
- * Main procedure
- PROCEDURE Klnt
-
- * Link to external procedure file of "tool" procedures
- SET PROCEDURE TO Biblio
-
- * Set up database environment
- DO Set_env
-
- SET COLOR TO &c_standard.
-
- * Declare variables used:
- * Database memory variables
- STORE "" TO klant_nr, categorie, klantnaam, adres1, adres2, woonplaats, provincie, postcode, telefoon
- STORE "" TO contact, tel_contct, intern, dat_laatst, condities, commentaar
-
- * Miscellaneous variables - used to pass parameters to Library
- STORE "KLNT" TO dbf, mlist && Standard report and mailing list is available
- STORE "N/B" TO cust_rpt && No custom reports available
- STORE "m->klant_nr" TO key, key1
- STORE "GEEN" TO key2, key3
- keyname1 = "Klantnummer:"
- STORE "" TO keyname2, keyname3, mcategory, mcity, mstate
- list_flds = "KLANT_NR, CONTACT, TEL_CONTCT, INTERN"
-
- * Open database files and choose active indexes
- SELECT 1
- USE Klnt ORDER Klant_nr
- GO TOP
- * Used for area code lookup
- USE Netnum ORDER Woonplaats IN 2
-
- record_num = RECNO()
- * Load initial record from database into memory variables
- DO Load_fld
-
- * Show data screen
- CLEAR
- DO Dstatus
- DO Backgrnd
- DO Show_data
-
- DO Bar_def && Define popup menus
-
- * Activate main popup menu - execute user choices
- SET COLOR TO &c_popup.
- ACTIVATE POPUP main_mnu
- DO Sub_ret
- *
- RETURN
- *=============================== end of main procedure ===============================
-
- * UTILITY PROCEDURES (Proprietary to Cust.prg)
-
- PROCEDURE Filter
- * Filter (group) data into subset
- * Select subset to set up filter condition (J=turn on,N=abort selection,U=turn off)
- * If filter is already on, set default choice to T, show window
- * If filter is not on, set default choice to Y, show window
- choice = IIF(filters_on,"N","J")
- DO Filt_ans
- IF choice = "J"
- * Start process of choosing filter condition
- mcategory = SPACE(15)
- mcity = SPACE(20)
- mstate = SPACE(2)
- STORE SPACE(10) TO mzip, mterms
- ACTIVATE WINDOW alert
- * Get user's filter condition selection(s)
- @ 0, 0 SAY "------- FILTERVOORWAARDE OPGEVEN ------"
- @ 1, 0 SAY "CATEGORIE:" GET mcategory FUNCTION "!" ;
- MESSAGE "Typ de gewenste categorie:"
- @ 2, 0 SAY "WOONPLAATS: " GET mcity FUNCTION "!"
- @ 3, 0 SAY "PROVINCIE: " GET mstate PICTURE "!!"
- @ 3,20 SAY "POSTCODE: " GET mzip
- @ 4, 0 SAY "CONDITIES: " GET mterms FUNCTION "!"
- @ 5, 0 SAY "Geef één of meer filtervoorwaarden op"
- READ
- DEACTIVATE WINDOW alert
- subset = "" && Initialize filter condition variable to null (empty)
- * Process user's entries to build filter condition
- mcategory = TRIM(mcategory)
- mcity = TRIM(mcity)
- mstate = TRIM(mstate)
- mzip = TRIM(mzip)
- mterms = TRIM(mterms)
- subset = subset + IIF("" <> mcategory, ;
- [categorie = mcategory .AND. ], "")
- subset = subset + IIF("" <> mcity, ;
- [UPPER(TRIM(woonplaats)) = UPPER(mcity) .AND. ],"")
- subset = subset + IIF("" <> mstate, ;
- [provincie = mstate .AND. ], "")
- subset = subset + IIF("" <> mzip, ;
- [postcode = mzip .AND. ], "")
- subset = subset + IIF("" <> mterms, ;
- [condities = mterms .AND. ], "")
- *
- IF "" = TRIM(subset) && Check whether data entered into subset string
- DO Warnbell
- filters_on = .F.
- ELSE
- * If string is not empty, truncate the .AND. from end of subset string
- subset = SUBSTR(subset,1,LEN(subset)-6)
- SET FILTER TO &subset. && Filter on entered filter string condition
- GO TOP && Activate filter by moving record pointer
- * Check whether filter condition matches any records (none matching=EOF)
- filters_on = .NOT. EOF() && Filter is turned on if .T. (matching records found)
- IF .NOT. filters_on && Turn off filter if no matching records found
- DO Warnbell
- DO Show_msg WITH "0 records voldoen aan filtervoorwaarde"
- SET FILTER TO
- GO record_num
- ENDIF
- ENDIF
- ELSE
- * If user selects "T", turn off filter
- SET FILTER TO
- filters_on = .F.
- ENDIF
- RETURN
-
- PROCEDURE Indexer
- * Create/rebuild index
- INDEX ON klant_nr TAG Klant_nr
- GO TOP
- RETURN
-
- PROCEDURE Init_fld
- * Initialize memory variable values for data entry
- STORE SPACE(30) TO klantnaam, adres1
- STORE SPACE(20) TO woonplaats, contact, commentaar
- STORE SPACE(10) TO postcode, condities
- STORE SPACE(13) TO telefoon, tel_contct
- provincie = "NH" && Could be any state or blank
- klant_nr = SPACE(6)
- categorie = SPACE(15)
- adres2 = SPACE(25)
- intern = SPACE(4)
- dat_laatst = { - - }
- RETURN
-
- PROCEDURE Load_fld
- * Load field values from Klnt database record into memory variables
- klant_nr = klant_nr
- categorie = categorie
- klantnaam = klantnaam
- adres1 = adres1
- adres2 = adres2
- woonplaats = woonplaats
- provincie = provincie
- postcode = postcode
- telefoon = telefoon
- contact = contact
- tel_contct = tel_contct
- intern = intern
- dat_laatst = dat_laatst
- condities = condities
- commentaar = commentaar
- RETURN
-
- PROCEDURE Repl_fld
- * Replace database fields with values of current memory variables
- REPLACE klant_nr WITH m->klant_nr, categorie WITH m->categorie, ;
- klantnaam WITH m->klantnaam, adres1 WITH m->adres1, ;
- adres2 WITH m->adres2, woonplaats WITH m->woonplaats, provincie WITH m->provincie
- REPLACE postcode WITH m->postcode, telefoon WITH m->telefoon,;
- contact WITH m->contact, tel_contct WITH m->tel_contct,;
- intern WITH m->intern, dat_laatst WITH m->dat_laatst, ;
- condities WITH m->condities, commentaar WITH m->commentaar
- RETURN
-
- PROCEDURE Backgrnd
- * Display screen for data entry and viewing
- * Draw and fill in boxes
- @ 1,18 TO 3,41 DOUBLE COLOR &c_blue.
- @ 5, 2 TO 7,56 DOUBLE COLOR &c_red.
- @ 2,19 FILL TO 2,40 COLOR &c_blue.
- @ 6, 3 FILL TO 6,55 COLOR &c_red.
- @ 9, 3 FILL TO 19,55 COLOR &c_red.
- @ 15, 2 TO 15,56 COLOR &c_red.
- @ 8, 2 TO 20,56 COLOR &c_red.
- * Show data
- SET COLOR TO &c_data.
- @ 2,20 SAY " DATABASE KLANTEN"
- @ 6, 4 SAY "KLANTNUMMER:"
- @ 6,29 SAY "CATEGORIE:"
- @ 9, 4 SAY "NAAM:"
- @ 10, 4 SAY "ADRES:"
- @ 12, 4 SAY "PLAATS:"
- @ 13, 4 SAY "PROV.:"
- @ 13,26 SAY "POSTCODE:"
- @ 14, 4 SAY "TEL.:"
- @ 16, 4 SAY "CONTACT:"
- @ 17, 4 SAY "TEL.:"
- @ 17,27 SAY "TOESTEL:"
- @ 18, 4 SAY "LAATSTE CONTACT OP:"
- @ 19, 4 SAY "CONDITIES:"
- @ 19,27 SAY "INFO:"
- SET COLOR TO &c_standard.
- RETURN
-
- @ 6,17 SAY klant_nr
- @ 6,40 SAY categorie
- @ 9,13 SAY klantnaam
- @ 10,13 SAY adres1
- @ 11,13 SAY adres2
- @ 12,13 SAY woonplaats
- @ 13,13 SAY provincie
- @ 13,36 SAY postcode
- @ 14,13 SAY telefoon
- @ 16,13 SAY contact
- @ 17,13 SAY tel_contct
- @ 17,38 SAY intern
- @ 18,26 SAY dat_laatst
- @ 19,15 SAY condities
- @ 19,35 SAY commentaar
- SET COLOR TO &c_standard.
- RETURN
-
- PROCEDURE Show_data
- SET COLOR TO &c_fields.
- @ 6,17 SAY klant_nr
- @ 6,40 SAY categorie
- @ 9,13 SAY klantnaam
- @ 10,13 SAY adres1
- @ 11,13 SAY adres2
- @ 12,13 SAY woonplaats
- @ 13,13 SAY provincie
- @ 13,36 SAY postcode
- @ 14,13 SAY telefoon
- @ 16,13 SAY contact
- @ 17,13 SAY tel_contct
- @ 17,38 SAY intern
- @ 18,26 SAY dat_laatst
- @ 19,15 SAY condities
- @ 19,35 SAY commentaar
- SET COLOR TO &c_standard.
- RETURN
-
- PROCEDURE Get_data
- SET COLOR TO &c_data.
- @ 6,17 GET m->klant_nr PICTURE "!99999" ;
- VALID Duplicat(&key.) ;
- ERROR "Ongeldig klantnr.; voer ander nummer in" ;
- MESSAGE "Typ klantnummer van zes cijfers, beginnend " + ;
- "met een letter, annuleer met Esc."
- @ 6,40 GET m->categorie ;
- PICTURE "@M ARCHITECT,CONSULTANT,AANNEMER,JURIDISCH" ;
- MESSAGE "Druk op spatiebalk voor andere categorie"
- @ 9,13 GET m->klantnaam FUNCTION "!" ;
- MESSAGE "Naam van klant"
- @ 10,13 GET m->adres1
- @ 11,13 GET m->adres2
- @ 12,13 GET m->woonplaats PICTURE "!XXXXXXXXXXXXX"
- @ 13,13 GET m->provincie PICTURE "!!"
- @ 13,36 GET m->postcode
- @ 14,13 GET m->telefoon PICTURE "999X9X9999999"
- @ 16,13 GET m->contact FUNCTION "!" ;
- MESSAGE "Naam van contactpersoon"
- @ 17,13 GET m->tel_contct PICTURE "999X9X9999999"
- @ 17,38 GET m->intern PICTURE "9999" ;
- MESSAGE "Toestelnummer"
- @ 18,26 GET m->dat_laatst FUNCTION "D";
- MESSAGE "Datum van laatste contact met cliënt"
- @ 19,15 GET m->condities PICTURE "@M CASH, NETTO30, NETTO45" ;
- MESSAGE "Druk op spatiebalk voor andere conditie"
- @ 19,35 GET m->commentaar FUNCTION "!" ;
- MESSAGE "Voer eventueel commentaar in"
- SET COLOR TO &c_standard.
- ON KEY LABEL F9 DO Findcode WITH m->woonplaats
- RETURN
-
- ******************************** EINDE KLNT.PRG ***************************************