DEFINE CLASS timetrans AS line Height = 17 Width = 100 cclient = ("") cdescription = ("") *--Service Code cservice = ("") *--Billing Amount namount = 0.00 nrate = 0.00 *--The employee who did the work cemployee = ("") *--Date of service ddate = {} *--Hours worked nhours = 0.00 Name = "timetrans" PROTECTED PROCEDURE CDESCRIPTION_ASSIGN LPARAMETERS vNewVal *--Our billing program only prints up to 600 characters for the description IF LEN(vNewVal) > 600 vNewVal = LEFT(vNewVal, 600) ENDIF this.cdescription = m.vNewVal ENDPROC *--sAVES A TRANSACTION TO THE TABLE PROCEDURE save LOCAL lnSelect lnSelect = Select() IF !USED("tsTrans") USE tstrans ENDIF SELECT tstrans APPEND BLANK WITH this REPLACE ; cemployee WITH .cemployee, ; ddate WITH .ddate, ; cclient with .cclient, ; cservice WITH .cservice, ; mDesc WITH .cdescription, ; nhours with .nhours, ; nrate WITH .nrate, ; namount WITH .namount ENDWITH SELECT (lnSelect) ENDPROC *--Clears out everything for a new record to be defined PROCEDURE add WITH this .ddate = {} .cclient = "" .cservice = "" .cdescription = "" .nhours = 0.00 .nrate = 0 .namount = 0 .cemployee = "" ENDWITH ENDPROC PROTECTED PROCEDURE cservice_assign LPARAMETERS vNewVal *--When we get a service in, we need to get the rate so we can do the math on it and then *--save it to the table. LOCAL lnSelect, lcOldExact lsSelect = SELECT() this.cservice = vNewVal *--Check that we got a character value IF TYPE("vNewVal") # "C" IF INLIST(_vfp.startmode, 1,2,3) this.cStatus = "cService Error" ELSE MESSAGEBOX("cService expects a CHARACTER type value.", 16) ENDIF RETURN ENDIF IF !USED("services") USE services ENDIF SELECT services SET ORDER TO service lcOldExact = SET("exact") SET EXACT ON SEEK UPPER(ALLTRIM(vNewVal)) IF !FOUND() OR EMPTY(vNewVal) this.nrate = services.nrate ENDIF SET EXACT &lcOldExact SELECT (lnSelect) ENDPROC PROTECTED PROCEDURE nrate_asign LPARAMETERS vNewVal *--Calculate the billing amount for this number this.nrate = vNewVal IF TYPE("vNewVal") # "N" IF INLIST(_vfp.startmode, 1,2,3) this.cStatus = "Rate Error" ELSE MESSAGEBOX("nRate expects a NUMERIC type value.", 16) ENDIF ELSE this.namount = this.nrate * this.nhours ENDIF ENDPROC PROTECTED PROCEDURE nhours_assign LPARAMETERS vNewVal *--Calculate the billing amount for this number this.nhours = vNewVal IF TYPE("vNewVal") # "N" IF INLIST(_vfp.startmode, 1,2,3) this.cStatus = "Hours Error" ELSE MESSAGEBOX("nHours expects a NUMERIC type value.", 16) ENDIF ELSE this.namount = this.nrate * this.nhours ENDIF ENDPROC ENDDEFINE * *--EndDefine: timetrans