unit PPSysMain; { 1007.. RJC Email added to tPerson. 1007.. RJC Service records added to iServiceID. } interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, RXSplit, ExtCtrls, ToolWin, Menus, Grids, DBGrids, RXDBCtrl, Db, DBTables, Registry, StdCtrls, DBCtrls, Placemnt, SpeedBar; type TMainForm = class(TForm) MenuSystem: TMainMenu; panelLeftSystem: TPanel; RxSplitterSystem: TRxSplitter; panelRightSystem: TPanel; TreeViewSystem: TTreeView; SysPageControl: TPageControl; TabServiceID: TTabSheet; RxDBGridServiceID: TRxDBGrid; TabValidAccount: TTabSheet; dsSysServiceID: TDataSource; qSysServiceType: TQuery; qSysCentre: TQuery; qSysActivity: TQuery; qSysElement: TQuery; qSysSubledger: TQuery; qSysLocation: TQuery; qSysPerson: TQuery; qSysServiceID: TQuery; qSysCentreID: TIntegerField; qSysCentreDescription: TStringField; qSysCentreActive: TBooleanField; qSysCentreStartDate: TDateTimeField; qSysCentreEndDate: TDateTimeField; qSysCentreDepartmentID: TIntegerField; qSysCentreDepartment: TStringField; qSysActivityID: TIntegerField; qSysActivityDescription: TStringField; qSysActivityStartDate: TDateTimeField; qSysActivityEndDate: TDateTimeField; qSysActivityCustomerID: TIntegerField; qSysActivityActive: TBooleanField; qSysActivityShipTo: TStringField; qSysElementID: TIntegerField; qSysElementElementCode: TStringField; qSysElementDescription: TStringField; qSysElementServiceGroupID: TIntegerField; qSysElementPlatinumUpdate: TBooleanField; qSysElementActive: TBooleanField; qSysElementStartDate: TDateTimeField; qSysElementEndDate: TDateTimeField; qSysElementCustomerID: TIntegerField; qSysElementReportGroupID: TIntegerField; qSysElementShipTo: TStringField; qSysSubledgerID: TIntegerField; qSysSubledgerCustomerID: TIntegerField; qSysSubledgerDescription: TStringField; qSysSubledgerActive: TBooleanField; qSysSubledgerStartDate: TDateTimeField; qSysSubledgerEndDate: TDateTimeField; qSysSubledgerShipTo: TStringField; qSysLocationID: TIntegerField; qSysLocationDescription: TStringField; qSysPersonID: TIntegerField; qSysPersonPerson: TStringField; qSysDepartment: TQuery; qSysGroup: TQuery; qSysDepartmentID: TIntegerField; qSysDepartmentDescription: TStringField; qSysDepartmentGroupID: TIntegerField; qSysDepartmentStartDate: TDateTimeField; qSysDepartmentEndDate: TDateTimeField; qSysDepartmentActive: TBooleanField; qSysDepartmentGroupName: TStringField; qSysGroupID: TIntegerField; qSysGroupCustomerID: TIntegerField; qSysGroupDescription: TStringField; qSysGroupStartDate: TDateTimeField; qSysGroupEndDate: TDateTimeField; qSysGroupActive: TBooleanField; qSysGroupShipTo: TStringField; qSysDiscount: TQuery; qSysDiscountServiceTypeID: TIntegerField; qSysDiscountCustomerID: TIntegerField; qSysDiscountDiscountRate: TFloatField; qSysDiscountNonStdRevAdminFee: TFloatField; qSysDiscountNonStdExpAdminFee: TFloatField; qSysDiscountActive: TBooleanField; qSysDiscountShipTo: TStringField; qSysDiscountServiceType: TStringField; TabCentre: TTabSheet; TabActivity: TTabSheet; TabElement: TTabSheet; TabSubledger: TTabSheet; TabDepartment: TTabSheet; TabGroup: TTabSheet; TabLocation: TTabSheet; TabPerson: TTabSheet; TabServiceType: TTabSheet; TabDiscount: TTabSheet; TabBatchType: TTabSheet; TabDestination: TTabSheet; TabOrigin: TTabSheet; TabSystem: TTabSheet; TabTransactionType: TTabSheet; TabTransactionGroup: TTabSheet; TabServiceSplit: TTabSheet; TabSupplierServiceCode: TTabSheet; TabCustomer: TTabSheet; TabSupplier: TTabSheet; TabBatch: TTabSheet; TabBatchStatus: TTabSheet; TabCriticalType: TTabSheet; TabDataCollectionMap: TTabSheet; TabDataSourceDetail: TTabSheet; TabDataSourceType: TTabSheet; TabDialledNumber: TTabSheet; TabDubiousResolution: TTabSheet; TabDubiousType: TTabSheet; TabDubiousValidResolution: TTabSheet; TabParameter: TTabSheet; TabRate: TTabSheet; TabStatus: TTabSheet; TabUser: TTabSheet; TabUserFunction: TTabSheet; TabFunction: TTabSheet; TabServiceSystem: TTabSheet; TabApplication: TTabSheet; TabBatchHistory: TTabSheet; TabRateDescription: TTabSheet; RxDBGridBatchHistory: TRxDBGrid; RxDBGridApplication: TRxDBGrid; RxDBGridRateDescription: TRxDBGrid; RxDBGridServiceSystem: TRxDBGrid; RxDBGridBatch: TRxDBGrid; RxDBGridBatchStatus: TRxDBGrid; RxDBGridCriticalType: TRxDBGrid; RxDBGridDataCollectionMap: TRxDBGrid; RxDBGridDataSourceDetail: TRxDBGrid; RxDBGridDataSourceType: TRxDBGrid; RxDBGridDialledNumber: TRxDBGrid; RxDBGridDubiousResolution: TRxDBGrid; RxDBGridDubiousType: TRxDBGrid; RxDBGridDubiousValidResolution: TRxDBGrid; RxDBGridParameter: TRxDBGrid; RxDBGridRate: TRxDBGrid; RxDBGridStatus: TRxDBGrid; RxDBGridUser: TRxDBGrid; RxDBGridUserFunction: TRxDBGrid; RxDBGridFunction: TRxDBGrid; RxDBGridPerson: TRxDBGrid; RxDBGridLocation: TRxDBGrid; RxDBGridGroup: TRxDBGrid; RxDBGridDepartment: TRxDBGrid; RxDBGridSubledger: TRxDBGrid; RxDBGridElement: TRxDBGrid; RxDBGridActivity: TRxDBGrid; RxDBGridCentre: TRxDBGrid; RxDBGridServType: TRxDBGrid; RxDBGridValidAccount: TRxDBGrid; RxDBGridDiscount: TRxDBGrid; RxDBGridDestination: TRxDBGrid; RxDBGridCustomer: TRxDBGrid; RxDBGridTransactionGroup: TRxDBGrid; RxDBGridTransactionType: TRxDBGrid; RxDBGridSupplierServiceCode: TRxDBGrid; RxDBGridOrigin: TRxDBGrid; RxDBGridSystem: TRxDBGrid; RxDBGridSupplier: TRxDBGrid; RxDBGridServiceSplit: TRxDBGrid; RxDBGridBatchType: TRxDBGrid; dsSysCentre: TDataSource; dsSysActivity: TDataSource; dsSysElement: TDataSource; dsSysSubledger: TDataSource; dsSysDepartment: TDataSource; dsSysGroup: TDataSource; dsSysLocation: TDataSource; dsSysPerson: TDataSource; dsSysDiscount: TDataSource; qSysValidAccount: TQuery; dsSysValidAccount: TDataSource; qSysValidAccountID: TIntegerField; qSysValidAccountAccountNo: TStringField; qSysValidAccountBatchTypeID: TIntegerField; qSysValidAccountActive: TBooleanField; qSysValidAccountBatchType: TStringField; dsSysServiceType: TDataSource; qSysServiceTypeID: TIntegerField; qSysServiceTypeCode: TStringField; qSysServiceTypeDescription: TStringField; qSysServiceTypeSupplierID: TIntegerField; qSysServiceTypeRevenueElementID: TIntegerField; qSysServiceTypeExpenseElementID: TIntegerField; qSysServiceTypeAdminFee: TBooleanField; qSysServiceTypeSystemID: TIntegerField; qSysServiceTypeExportToTims: TBooleanField; qSysServiceTypeActive: TBooleanField; qSysServiceTypeSplitService: TBooleanField; qSysServiceTypeVRTServiceType: TBooleanField; qSysServiceTypeExpectedRent: TFloatField; qSysServiceTypeNoCalls: TBooleanField; qSysServiceTypeSupplierName: TStringField; qSysServiceTypeRevenueElement: TStringField; qSysServiceTypeExpenseElement: TStringField; qSysServiceTypeSystem: TStringField; qry: TQuery; qSysLocationActive: TBooleanField; qSysPersonActive: TBooleanField; qSysServiceTypeStartDate: TDateTimeField; qSysServiceTypeEndDate: TDateTimeField; qSysServiceIDID: TIntegerField; qSysServiceIDServiceID: TStringField; qSysServiceIDService: TStringField; qSysServiceIDServiceTypeID: TIntegerField; qSysServiceIDSACCnumber: TStringField; qSysServiceIDSupplierAccountID: TIntegerField; qSysServiceIDCustomerCentreID: TIntegerField; qSysServiceIDCustomerActivityID: TIntegerField; qSysServiceIDCustomerElementID: TIntegerField; qSysServiceIDCustomerSubLedgerID: TIntegerField; qSysServiceIDCentreID: TIntegerField; qSysServiceIDActivityID: TIntegerField; qSysServiceIDElementID: TIntegerField; qSysServiceIDSubledgerID: TIntegerField; qSysServiceIDLocationID: TIntegerField; qSysServiceIDCurrentRent: TFloatField; qSysServiceIDCurrentCalls: TFloatField; qSysServiceIDPreviousRent: TFloatField; qSysServiceIDPreviousCalls: TFloatField; qSysServiceIDInstallationDate: TDateTimeField; qSysServiceIDTerminationDate: TDateTimeField; qSysServiceIDUpEnd: TStringField; qSysServiceIDUpMDF: TStringField; qSysServiceIDDownEnd: TStringField; qSysServiceIDDownMDF: TStringField; qSysServiceIDLength: TFloatField; qSysServiceIDPersonID: TIntegerField; qSysServiceIDActive: TBooleanField; qSysServiceIDPayType: TStringField; qSysServiceIDDateEntered: TDateTimeField; qSysServiceIDDateLastChanged: TDateTimeField; qSysServiceIDLastUpdatedBy: TStringField; qSysServiceIDCode: TStringField; qSysServiceIDServiceType: TStringField; qSysServiceIDShipTo: TStringField; qSysServiceIDCustomer: TStringField; qSysServiceIDCustomerCentre: TStringField; qSysServiceIDCustomerActivity: TStringField; qSysServiceIDCustomerElement: TStringField; qSysServiceIDCustomerSubledger: TStringField; qSysServiceIDPerson: TStringField; qSysServiceIDCentre: TStringField; qSysServiceIDActivity: TStringField; qSysServiceIDElement: TStringField; qSysServiceIDSubledger: TStringField; qSysServiceIDCustomerID: TIntegerField; qSysServiceIDGroupDesc: TStringField; qSysServiceIDDepartment: TStringField; qSysServiceIDLocation: TStringField; qSysServiceIDAccountNo: TStringField; qSysCentreGroupID: TIntegerField; qSysCentreGroupName: TStringField; qSysCentreCustomerID: TIntegerField; qSysCentreShipTo: TStringField; qSysDepartmentCustomerID: TIntegerField; qSysDepartmentShipTo: TStringField; qSysValidAccountStartDate: TDateTimeField; qSysValidAccountEndDate: TDateTimeField; qSysLocationStartDate: TDateTimeField; qSysLocationEndDate: TDateTimeField; qSysPersonStartDate: TDateTimeField; qSysPersonEndDate: TDateTimeField; qSysBatchType: TQuery; dsSysBatchType: TDataSource; qSysDestination: TQuery; dsSysDestination: TDataSource; qSysOrigin: TQuery; dsSysOrigin: TDataSource; qSysSystem: TQuery; dsSysSystem: TDataSource; qSysTransactionType: TQuery; dsSysTransactionType: TDataSource; dsSysSupplierServiceCode: TDataSource; qSysSupplierServiceCode: TQuery; dsSysTransactionGroup: TDataSource; qSysServiceSplit: TQuery; dsSysServiceSplit: TDataSource; qSysCustomer: TQuery; dsSysCustomer: TDataSource; qSysCustomerID: TIntegerField; qSysCustomerShipTo: TStringField; qSysCustomerFullName: TStringField; qSysCustomerVNumber: TStringField; qSysCustomerAddress01: TStringField; qSysCustomerAddress02: TStringField; qSysCustomerAddress03: TStringField; qSysCustomerAddress04: TStringField; qSysCustomerAddress05: TStringField; qSysCustomerAddress06: TStringField; qSysCustomerStatus: TStringField; qSysCustomerRate: TIntegerField; qSysCustomerInvoice: TBooleanField; qSysCustomerActive: TBooleanField; qSysCustomerStartDate: TDateTimeField; qSysCustomerEndDate: TDateTimeField; qSysCustomerLastUpdatedBy: TStringField; qSysCustomerPlatinumUpdate: TBooleanField; qSysDestinationID: TIntegerField; qSysDestinationDescription: TStringField; qSysDestinationActive: TBooleanField; qSysOriginID: TIntegerField; qSysOriginDescription: TStringField; qSysOriginActive: TBooleanField; qSysSystemID: TIntegerField; qSysSystemSystem: TStringField; qSysSystemBatchTypeID: TIntegerField; qSysSystemActive: TBooleanField; qSysSystemDateEntered: TDateTimeField; qSysSystemDateLastChanged: TDateTimeField; qSysSystemUserID: TIntegerField; qSysSystemUserLogin: TStringField; qSysTransactionTypeID: TIntegerField; qSysTransactionTypeDescription: TStringField; qSysTransactionTypeTransactionGroupID: TIntegerField; qSysTransactionTypeSystemID: TIntegerField; qSysTransactionTypeActive: TBooleanField; qSysTransactionTypeStartDate: TDateTimeField; qSysTransactionTypeEndDate: TDateTimeField; qSysTransactionTypeLastUpdatedBy: TStringField; qSysTransactionTypeTransactionGroup: TStringField; qSysTransactionTypeSystem: TStringField; qSysTransactionGroup: TQuery; qSysTransactionGroupID: TIntegerField; qSysTransactionGroupDescription: TStringField; qSysTransactionGroupCostRangeFrom: TFloatField; qSysTransactionGroupCostRangeTo: TFloatField; qSysSupplierServiceCodeid: TIntegerField; qSysSupplierServiceCodeCode: TStringField; qSysSupplierServiceCodeAmountCategory: TStringField; qSysSupplierServiceCodeDescription: TStringField; qSysSupplierServiceCodeTransactionTypeID: TIntegerField; qSysSupplierServiceCodeTransactionTypeDesc: TStringField; qSysSupplierServiceCodeSupplierID: TIntegerField; qSysSupplierServiceCodeActive: TBooleanField; qSysSupplierServiceCodeTransactionType: TStringField; qSysSupplierServiceCodeSupplierName: TStringField; qSysSystemBatchType: TStringField; qSysSupplier: TQuery; dsSysSupplier: TDataSource; qSysSupplierID: TIntegerField; qSysSupplierSupplierName: TStringField; qSysSupplierActive: TBooleanField; qSysSupplierStartDate: TDateTimeField; qSysSupplierEndDate: TDateTimeField; qSysSupplierLastUpdatedBy: TStringField; qSysSupplierPlatinumVendorID: TStringField; qSysSupplierPlatinumUpdate: TBooleanField; qSysSupplierVictrack: TBooleanField; qSysSupplierAddress01: TStringField; qSysSupplierAddress02: TStringField; qSysSupplierAddress03: TStringField; qSysSupplierAddress04: TStringField; qSysSupplierAddress05: TStringField; qSysSupplierAddress06: TStringField; qSysServiceSplitID: TIntegerField; qSysServiceSplitServiceID: TIntegerField; qSysServiceSplitCustomerID: TIntegerField; qSysServiceSplitCallPercentage: TIntegerField; qSysServiceSplitRentPercentage: TIntegerField; qSysServiceSplitOtherPercentage: TIntegerField; qSysServiceSplitActive: TBooleanField; qSysServiceSplitServiceID_Desc: TStringField; qSysServiceSplitShipTo: TStringField; qSysBatchTypeID: TIntegerField; qSysBatchTypeDescription: TStringField; qSysBatchTypeSupplierID: TIntegerField; qSysBatchTypeDataSourceTypeID: TIntegerField; qSysBatchTypeAccountNo: TBooleanField; qSysBatchTypeInvoiceNo: TBooleanField; qSysBatchTypeTotalRevenue: TBooleanField; qSysBatchTypeTotalPayable: TBooleanField; qSysBatchTypeTotalCredits: TBooleanField; qSysBatchTypeOpeningBalance: TBooleanField; qSysBatchTypePaymentsReceived: TBooleanField; qSysBatchTypeTotalAdjustments: TBooleanField; qSysBatchTypeBatchStart: TBooleanField; qSysBatchTypeBatchEnd: TBooleanField; qSysBatchTypePaymentDate: TBooleanField; qSysBatchTypeCreditsToCustomers: TBooleanField; qSysBatchTypeGST: TBooleanField; qSysBatchTypeGSTAdjustment: TBooleanField; qSysBatchTypeOrderNumber: TBooleanField; qSysBatchTypeRequisitionNumber: TBooleanField; qSysBatchTypeIssueDate: TBooleanField; qSysBatchTypeRentDates: TBooleanField; qSysBatchTypeCallDates: TBooleanField; qSysBatchTypeRounding: TBooleanField; qSysBatchTypeAccountNoName: TStringField; qSysBatchTypeInvoiceNoName: TStringField; qSysBatchTypeTotalRevenueName: TStringField; qSysBatchTypeTotalPayableName: TStringField; qSysBatchTypeTotalCreditsName: TStringField; qSysBatchTypeOpeningBalanceName: TStringField; qSysBatchTypePaymentsReceivedName: TStringField; qSysBatchTypeTotalAdjustmentsName: TStringField; qSysBatchTypeBatchStartName: TStringField; qSysBatchTypeBatchEndName: TStringField; qSysBatchTypePaymentDateName: TStringField; qSysBatchTypeCreditsToCustomersName: TStringField; qSysBatchTypeRoundingName: TStringField; qSysBatchTypeGSTname: TStringField; qSysBatchTypeGSTAdjustmentName: TStringField; qSysBatchTypeOrderNumberName: TStringField; qSysBatchTypeRequisitionNumberName: TStringField; qSysBatchTypeIssueDateName: TStringField; qSysBatchTypeCriticalCheck01: TBooleanField; qSysBatchTypeCriticalCheck02: TBooleanField; qSysBatchTypeCriticalCheck03: TBooleanField; qSysBatchTypeCriticalCheck04: TBooleanField; qSysBatchTypeCriticalCheck05: TBooleanField; qSysBatchTypeCriticalCheck06: TBooleanField; qSysBatchTypeCriticalCheck07: TBooleanField; qSysBatchTypeCriticalCheck08: TBooleanField; qSysBatchTypeCriticalCheck09: TBooleanField; qSysBatchTypeCriticalCheck10: TBooleanField; qSysBatchTypeCriticalCheck11: TBooleanField; qSysBatchTypeCriticalCheck12: TBooleanField; qSysBatchTypeCriticalCheck13: TBooleanField; qSysBatchTypeCriticalCheck14: TBooleanField; qSysBatchTypeCriticalCheck15: TBooleanField; qSysBatchTypeDubiousCheck01: TBooleanField; qSysBatchTypeDubiousCheck02: TBooleanField; qSysBatchTypeDubiousCheck03: TBooleanField; qSysBatchTypeDubiousCheck04: TBooleanField; qSysBatchTypeDubiousCheck05: TBooleanField; qSysBatchTypeDubiousCheck06: TBooleanField; qSysBatchTypeDubiousCheck07: TBooleanField; qSysBatchTypeDubiousCheck08: TBooleanField; qSysBatchTypeDubiousCheck09: TBooleanField; qSysBatchTypeDubiousCheck10: TBooleanField; qSysBatchTypeDubiousCheck11: TBooleanField; qSysBatchTypeDubiousCheck12: TBooleanField; qSysBatchTypeDubiousCheck13: TBooleanField; qSysBatchTypeDubiousCheck14: TBooleanField; qSysBatchTypeDubiousCheck15: TBooleanField; qSysBatchTypeVar01Description: TStringField; qSysBatchTypeVar02Description: TStringField; qSysBatchTypeVar03Description: TStringField; qSysBatchTypeVar04Description: TStringField; qSysBatchTypeVar05Description: TStringField; qSysBatchTypeVar06Description: TStringField; qSysBatchTypeVar07Description: TStringField; qSysBatchTypeVar08Description: TStringField; qSysBatchTypeVar09Description: TStringField; qSysBatchTypeVar10Description: TStringField; qSysBatchTypeVar11Description: TStringField; qSysBatchTypeVar12Description: TStringField; qSysBatchTypeVar13Description: TStringField; qSysBatchTypeVar14Description: TStringField; qSysBatchTypeVar15Description: TStringField; qSysBatchTypeSupplierName: TStringField; qSysBatchTypeDataSource: TStringField; qSysBatchTypeActive: TBooleanField; qSysDiscountCode: TStringField; ToolBarSystem: TSpeedBar; SpeedbarSection1: TSpeedbarSection; sbtnExit: TSpeedItem; sbtnTabClose: TSpeedItem; MainFormFormStorage: TFormStorage; qSysServiceSystem: TQuery; dsSysServiceSystem: TDataSource; qSysServiceSystemServiceTypeID: TIntegerField; qSysServiceSystemCode: TStringField; qSysServiceSystemSupplierID: TIntegerField; qSysServiceSystemSupplierName: TStringField; qSysServiceSystemSystemID: TIntegerField; qSysServiceSystemSystem: TStringField; qSysServiceSystemBatchTypeID: TIntegerField; qSysServiceSystemBatchTypeDescription: TStringField; qSysServiceSystemValidAccountNumberID: TIntegerField; qSysServiceSystemAccountNo: TStringField; qSysServiceIDExpenseElementID: TIntegerField; panelTopOfTab: TPanel; edtValue: TEdit; btnClear: TButton; btnAdd: TButton; btnDel: TButton; cbField: TComboBox; btnApply: TButton; cbActive: TCheckBox; cbNotActive: TCheckBox; dbNavigator: TDBNavigator; qSysBatch: TQuery; dsSysBatch: TDataSource; qSysBatchStatus: TQuery; dsSysBatchStatus: TDataSource; qSysCriticalType: TQuery; dsSysCriticalType: TDataSource; qSysDataCollectionMap: TQuery; dsSysDataCollectionMap: TDataSource; qSysDataSourceDetail: TQuery; dsSysDataSourceDetail: TDataSource; qSysDataSourceType: TQuery; dsSysDataSourceType: TDataSource; qSysDialledNumber: TQuery; dsSysDialledNumber: TDataSource; qSysDubiousResolution: TQuery; dsSysDubiousResolution: TDataSource; qSysDubiousType: TQuery; dsSysDubiousType: TDataSource; qSysDubiousValidResolution: TQuery; dsSysDubiousValidResolution: TDataSource; qSysParameter: TQuery; dsSysParameter: TDataSource; qSysRate: TQuery; dsSysRate: TDataSource; qSysStatus: TQuery; dsSysStatus: TDataSource; qSysUser: TQuery; dsSysUser: TDataSource; qSysUserFunction: TQuery; dsSysUserFunction: TDataSource; qSysFunction: TQuery; dsSysFunction: TDataSource; qSysBatchID: TIntegerField; qSysBatchBatchTypeID: TIntegerField; qSysBatchBatchStatusID: TIntegerField; qSysBatchBillingPeriod: TStringField; qSysBatchSupplierID: TIntegerField; qSysBatchSupplierAccountID: TIntegerField; qSysBatchInvoiceNo: TStringField; qSysBatchTotalRevenue: TFloatField; qSysBatchTotalPayable: TFloatField; qSysBatchTotalCredits: TFloatField; qSysBatchOpeningBalance: TFloatField; qSysBatchPaymentsReceived: TFloatField; qSysBatchTotalAdjustments: TFloatField; qSysBatchBatchStartDate: TDateTimeField; qSysBatchBatchEndDate: TDateTimeField; qSysBatchPaymentDate: TDateTimeField; qSysBatchCallsStartDate: TDateTimeField; qSysBatchCallsEndDate: TDateTimeField; qSysBatchRentStartDate: TDateTimeField; qSysBatchRentEndDate: TDateTimeField; qSysBatchIssueDate: TDateTimeField; qSysBatchRounding: TFloatField; qSysBatchPayByDate: TDateTimeField; qSysBatchGSTAmount: TFloatField; qSysBatchGSTAdjustment: TFloatField; qSysBatchRequisitionNumber: TStringField; qSysBatchOrderNumber: TStringField; qSysBatchTenderNo: TStringField; qSysBatchBatchType: TStringField; qSysBatchBatchStatus: TStringField; qSysDataSourceDetailID: TIntegerField; qSysDataSourceDetailDescription: TStringField; qSysDataSourceDetailVar01: TStringField; qSysDataSourceDetailVar02: TStringField; qSysDataSourceDetailVar03: TStringField; qSysDataSourceDetailVar04: TStringField; qSysDataSourceDetailVar05: TStringField; qSysDataSourceDetailVar06: TStringField; qSysDataSourceDetailVar07: TStringField; qSysDataSourceDetailVar08: TStringField; qSysDataSourceDetailVar09: TStringField; qSysDataSourceDetailVar10: TStringField; qSysDataSourceDetailVar11: TStringField; qSysDataSourceDetailVar12: TStringField; qSysDataSourceDetailVar13: TStringField; qSysDataSourceDetailVar14: TStringField; qSysDataSourceDetailVar15: TStringField; qSysDataSourceDetailVar01Description: TStringField; qSysDataSourceDetailVar02Description: TStringField; qSysDataSourceDetailVar03Description: TStringField; qSysDataSourceDetailVar04Description: TStringField; qSysDataSourceDetailVar05Description: TStringField; qSysDataSourceDetailVar06Description: TStringField; qSysDataSourceDetailVar07Description: TStringField; qSysDataSourceDetailVar08Description: TStringField; qSysDataSourceDetailVar09Description: TStringField; qSysDataSourceDetailVar10Description: TStringField; qSysDataSourceDetailVar11Description: TStringField; qSysDataSourceDetailVar12Description: TStringField; qSysDataSourceDetailVar13Description: TStringField; qSysDataSourceDetailVar14Description: TStringField; qSysDataSourceDetailVar15Description: TStringField; qSysParameterParm: TStringField; qSysParameterParmField: TStringField; qSysParameterParmText: TStringField; qSysParameterParmNumber: TFloatField; qSysParameterParmDate: TDateTimeField; qSysParameterParmOLE: TBlobField; qSysParameterParmDescription: TStringField; qSysParameterParmUserDefined: TBooleanField; qSysStatusID: TIntegerField; qSysStatusStatus: TStringField; qSysStatusActive: TBooleanField; qSysStatusStartDate: TDateTimeField; qSysStatusEndDate: TDateTimeField; qSysStatusLastUpdatedBy: TStringField; qSysUserID: TIntegerField; qSysUserUserLogin: TStringField; qSysUserFirstName: TStringField; qSysUserSurname: TStringField; qSysUserPassword: TStringField; qSysUserLastLoggedOn: TDateTimeField; qSysUserLastLoggedOff: TDateTimeField; qSysUserActive: TBooleanField; qSysDataCollectionMapDCField: TStringField; qSysDataCollectionMapDCValue: TStringField; qSysDataCollectionMapTransValue: TStringField; qSysBatchStatusID: TIntegerField; qSysBatchStatusDescription: TStringField; qSysCriticalTypeID: TIntegerField; qSysCriticalTypeDescription: TStringField; qSysFunctionID: TIntegerField; qSysFunctionDescription: TStringField; qSysDubiousValidResolutionID: TIntegerField; qSysDubiousValidResolutionDubiousTypeID: TIntegerField; qSysDubiousValidResolutionDubiousType: TStringField; qSysDubiousValidResolutionDubiousResolutionID: TIntegerField; qSysDubiousValidResolutionResolution: TStringField; qSysDubiousValidResolutionActive: TBooleanField; qSysDubiousTypeID: TIntegerField; qSysDubiousTypeDescription: TStringField; qSysDubiousResolutionID: TIntegerField; qSysDubiousResolutionDescription: TStringField; qSysDialledNumberID: TIntegerField; qSysDialledNumberDescription: TStringField; qSysDialledNumberActive: TBooleanField; qSysDataSourceTypeID: TIntegerField; qSysDataSourceTypeDataSource: TStringField; qSysServiceIDDescription: TStringField; qSysBatchTypeValidAccount: TStringField; qSysBatchTypeTenderNo: TStringField; qSysServiceTypeFrequency: TIntegerField; qSysElementLostRevenueFlag: TBooleanField; qSysValidAccountTenderNo: TStringField; qSysBatchHistory: TQuery; dsSysBatchHistory: TDataSource; qSysBatchHistoryID: TIntegerField; qSysBatchHistoryBatchID: TIntegerField; qSysBatchHistoryBatchStatusID: TIntegerField; qSysBatchHistoryStatusChangeDate: TDateTimeField; qSysBatchHistoryUserID: TIntegerField; qSysBatchHistoryBillingPeriod: TStringField; qSysBatchHistoryBatchType: TStringField; qSysBatchHistoryBatchStatus: TStringField; qSysBatchHistoryOperator: TStringField; sbtnPrint: TSpeedItem; sbtnPrinterSetup: TSpeedItem; MainPrinterSetupDialog: TPrinterSetupDialog; qSysUserFunctionUserID: TIntegerField; qSysUserFunctionUserLogin: TStringField; qSysUserFunctionFirstName: TStringField; qSysUserFunctionSurName: TStringField; qSysUserFunctionF1: TIntegerField; qSysUserFunctionF2: TIntegerField; qSysUserFunctionF3: TIntegerField; qSysUserFunctionF4: TIntegerField; qSysUserFunctionF5: TIntegerField; qSysUserFunctionF6: TIntegerField; qSysUserFunctionF7: TIntegerField; qSysUserFunctionF8: TIntegerField; qSysUserFunctionF9: TIntegerField; qSysUserFunctionF10: TIntegerField; qSysUserFunctionF11: TIntegerField; qSysUserFunctionF12: TIntegerField; qSysUserFunctionF13: TIntegerField; qSysUserFunctionF14: TIntegerField; qSysUserFunctionF15: TIntegerField; qSysUserFunctionF16: TIntegerField; qSysUserFunctionPassword: TStringField; qSysUserFunctionActive: TBooleanField; Timebomb: TTimer; qSysServiceIDvServiceCode: TStringField; qSysCentreFullName: TStringField; qSysServiceIDApplicationID: TIntegerField; qSysServiceIDApplication: TStringField; qSysBatchTypePayByDate: TBooleanField; qSysBatchTypeTenderNumber: TBooleanField; qSysApplication: TQuery; dsSysApplication: TDataSource; qSysApplicationID: TIntegerField; qSysApplicationDescription: TStringField; qSysRateDescription: TQuery; dsSysRateDescription: TDataSource; qSysRateDescriptionID: TIntegerField; qSysRateDescriptionDescription: TStringField; qSysRateDescriptionActive: TBooleanField; mnuFile: TMenuItem; mnuFilePrint: TMenuItem; mnuFileLine: TMenuItem; mnuFileExit: TMenuItem; mnuOptions: TMenuItem; mnuTools: TMenuItem; mnuReportsCPIitem: TMenuItem; mnuUpdate: TMenuItem; mnuUpdateSystemdata: TMenuItem; mnuView: TMenuItem; mnuHelp: TMenuItem; mnuHelpAbout: TMenuItem; mnuFilePrintSetup: TMenuItem; mnuFileCloseTab: TMenuItem; qSysServiceSystemServiceType: TStringField; qSysServiceIDJobNo: TStringField; TabAgreement: TTabSheet; RxDBGridAgreement: TRxDBGrid; qSysAgreement: TQuery; dsSysAgreement: TDataSource; TabDiscountedRate: TTabSheet; RxDBGridDiscountedRate: TRxDBGrid; qSysDiscountedRate: TQuery; dsSysDiscountedRate: TDataSource; qSysDiscountedRateID: TIntegerField; qSysDiscountedRateServiceTypeID: TIntegerField; qSysDiscountedRateCustomerID: TIntegerField; qSysDiscountedRateRate: TFloatField; qSysDiscountedRateActive: TBooleanField; qSysDiscountedRateServiceType: TStringField; qSysDiscountedRateCode: TStringField; qSysDiscountedRateShipTo: TStringField; lblTestData: TLabel; mnuToolsSelectMainDatabaseItem: TMenuItem; mnuToolsSelectTestDatabaseItem: TMenuItem; qSysBatchTypeMultiManualEntry: TBooleanField; qSysBatchTypeEarlyRevenue: TBooleanField; qSysCustomerInvoiceServices: TBooleanField; TabProgram: TTabSheet; RxDBGridProgram: TRxDBGrid; qSysProgram: TQuery; dsSysProgram: TDataSource; qSysProgramID: TIntegerField; qSysProgramDescription: TStringField; qSysBatchTypeProgramID: TIntegerField; qSysBatchTypeProgramDesc: TStringField; qSysAgreementTariffs: TQuery; dsSysAgreementTariffs: TDataSource; qSysAgreementType: TQuery; dsSysAgreementType: TDataSource; qSysAgreementID: TIntegerField; qSysAgreementAgreementNo: TStringField; qSysAgreementDescription: TStringField; qSysAgreementAT_ID: TIntegerField; qSysAgreementAgreementType: TStringField; qSysAgreementSupplierID: TIntegerField; qSysAgreementSupplierName: TStringField; qSysAgreementVAN_ID: TIntegerField; qSysAgreementValidAccountNo: TStringField; qSysAgreementBT_ID: TIntegerField; qSysAgreementBatchType: TStringField; qSysAgreementStartDate: TDateTimeField; qSysAgreementEndDate: TDateTimeField; qSysAgreementActive: TBooleanField; TabAgreementTariffs: TTabSheet; RxDBGridAgreementTariffs: TRxDBGrid; TabAgreementType: TTabSheet; RxDBGridAgreementType: TRxDBGrid; qSysAgreementTypeID: TIntegerField; qSysAgreementTypeDescription: TStringField; qSysAgreementTypeActive: TBooleanField; qSysAgreementTariffsID: TIntegerField; qSysAgreementTariffsAgreementID: TIntegerField; qSysAgreementTariffsSupplierServiceCodeID: TIntegerField; qSysAgreementTariffsFixedCharge: TFloatField; qSysAgreementTariffsFlagFall: TFloatField; qSysAgreementTariffsMinCharge: TFloatField; qSysAgreementTariffsMinDuration: TIntegerField; qSysAgreementTariffsMaxCharge: TIntegerField; qSysAgreementTariffsMaxDuration: TIntegerField; qSysAgreementTariffsChargeIntervalSecs: TIntegerField; qSysAgreementTariffsStage1Duration: TIntegerField; qSysAgreementTariffsStage1Charge: TFloatField; qSysAgreementTariffsStage2Duration: TIntegerField; qSysAgreementTariffsStage2Charge: TFloatField; qSysAgreementTariffsStage3Duration: TIntegerField; qSysAgreementTariffsStage3Charge: TFloatField; qSysAgreementTariffsStage4Duration: TIntegerField; qSysAgreementTariffsStage4Charge: TFloatField; qSysAgreementTariffsStage5Duration: TIntegerField; qSysAgreementTariffsStage5Charge: TFloatField; qSysAgreementTariffsSurcharge: TBooleanField; qSysAgreementTariffsSurchargeRate: TFloatField; qSysAgreementTariffsDiscount: TBooleanField; qSysAgreementTariffsDiscountRate: TFloatField; qSysAgreementTariffsChargePeriod: TBooleanField; qSysAgreementTariffsActive: TBooleanField; qSysAgreementTariffsAgreementNo: TStringField; qSysAgreementTariffsAgreement: TStringField; qSysAgreementTariffsAT_ID: TIntegerField; qSysAgreementTariffsAgreementType: TStringField; qSysAgreementTariffsSupplierID: TIntegerField; qSysAgreementTariffsSupplierName: TStringField; qSysAgreementTariffsCode: TStringField; qSysAgreementTariffsVAN_ID: TIntegerField; qSysAgreementTariffsValidAccountNo: TStringField; qSysAgreementTariffsBatchType: TStringField; qSysApplicationActive: TBooleanField; sbtnFile: TSpeedItem; TabAdjustment: TTabSheet; TabAudit: TTabSheet; TabAuditTrail: TTabSheet; qSysAdjustment: TQuery; dsSysAdjustment: TDataSource; qSysAudit: TQuery; dsSysAudit: TDataSource; qSysAuditTrail: TQuery; dsSysAuditTrail: TDataSource; RxDBGridAdjustment: TRxDBGrid; RxDBGridAudit: TRxDBGrid; RxDBGridAuditTrail: TRxDBGrid; qSysAuditTrailAuditID: TIntegerField; qSysAuditTrailUserID: TStringField; qSysAuditTrailActionTime: TDateTimeField; qSysAuditTrailAction: TSmallintField; qSysAuditTrailActionDescription: TStringField; qSysAuditTrailTableName: TStringField; qSysAuditTrailTableID: TIntegerField; qSysAuditTrailFieldName: TStringField; qSysAuditTrailOldValue: TStringField; qSysAuditTrailNewValue: TStringField; qSysAuditTrailDescription: TStringField; qSysAuditID: TIntegerField; qSysAuditTable: TStringField; qSysAuditComment: TStringField; qSysAuditUpdatedBy: TStringField; qSysAuditUpdatedTime: TDateTimeField; qSysAuditUserID: TIntegerField; qSysAuditUserLogin: TStringField; qSysAuditSysLog: TBooleanField; qSysAdjustmentID: TIntegerField; qSysAdjustmentSequenceNo: TStringField; qSysAdjustmentServiceID: TStringField; qSysAdjustmentServiceType: TStringField; qSysAdjustmentTxnDate: TStringField; qSysAdjustmentTxnTime: TStringField; qSysAdjustmentOrigin: TStringField; qSysAdjustmentDestination: TStringField; qSysAdjustmentDuration: TStringField; qSysAdjustmentCallCode: TStringField; qSysAdjustmentRateDescription: TStringField; qSysAdjustmentPeak: TBooleanField; qSysAdjustmentDialledNumber: TStringField; qSysAdjustmentGSTFlag: TStringField; qSysAdjustmentAmountExGST: TFloatField; qSysAdjustmentGSTAmount: TFloatField; qSysAdjustmentAmountIncGST: TFloatField; qSysAdjustmentFromDate: TStringField; qSysAdjustmentToDate: TStringField; qSysAdjustmentBatchID: TIntegerField; qSysAdjustmentTransactionTypeID: TIntegerField; qSysAdjustmentStatusID: TIntegerField; qSysAdjustmentVar01: TStringField; qSysAdjustmentVar02: TStringField; qSysAdjustmentVar03: TStringField; qSysAdjustmentVar04: TStringField; qSysAdjustmentVar05: TStringField; qSysAdjustmentVar06: TStringField; qSysAdjustmentVar07: TStringField; qSysAdjustmentVar08: TStringField; qSysAdjustmentVar09: TStringField; qSysAdjustmentVar10: TStringField; qSysAdjustmentVar11: TStringField; qSysAdjustmentVar12: TStringField; qSysAdjustmentVar13: TStringField; qSysAdjustmentVar14: TStringField; qSysAdjustmentVar15: TStringField; qSysAdjustmentSupplierServiceCodeID: TIntegerField; qSysAdjustmentRevenueFlag: TBooleanField; qSysDubiousResult: TQuery; dsSysDubiousResult: TDataSource; TabDubiousResult: TTabSheet; RxDBGridDubiousResult: TRxDBGrid; qSysDubiousResultID: TIntegerField; qSysDubiousResultSID: TIntegerField; qSysDubiousResultServiceID: TStringField; qSysDubiousResultCustomerID: TIntegerField; qSysDubiousResultShipTo: TStringField; qSysDubiousResultBatchID: TIntegerField; qSysDubiousResultUserID: TIntegerField; qSysDubiousResultUserLogin: TStringField; qSysDubiousResultResolutionID: TIntegerField; qSysDubiousResultDubiousResolution: TStringField; qSysDubiousResultDubiousTypeID: TIntegerField; qSysDubiousResultDubiousType: TStringField; qSysDubiousResultSupplierServiceCodeID: TIntegerField; qSysDubiousResultCode: TStringField; qSysAdjustmentDescription: TStringField; qSysDiscountID: TIntegerField; TabCostRange: TTabSheet; RxDBGrid1: TRxDBGrid; qSysCostRange: TQuery; dsSysCostRange: TDataSource; qSysCostRangeValidAccountNumberID: TIntegerField; qSysCostRangeTransactionTypeID: TIntegerField; qSysCostRangeCostRangeFrom: TFloatField; qSysCostRangeCostRangeTo: TFloatField; qSysCostRangeAccountNo: TStringField; qSysCostRangeTransactionType: TStringField; qSysCostRangeID: TIntegerField; qSysBatchTypeReportGroupID: TIntegerField; qSysBatchTypeSupplierDisplayedName: TStringField; qSysCustomerMaxExServiceAmount: TFloatField; qSysServiceIDKpiNumber: TStringField; qSysServiceIDServiceKpiID: TIntegerField; TABServiceKpi: TTabSheet; RxDBGrid2: TRxDBGrid; qSysServiceKpi: TQuery; dsSysServiceKpi: TDataSource; qSysServiceKpiID: TIntegerField; qSysServiceKpiKpiNumber: TStringField; qSysServiceKpiDescription: TStringField; qSysServiceKpiResponseHours: TStringField; qSysServiceKpiRestorationHours: TStringField; qSysServiceKpiAvailability: TStringField; qSysServiceKpiCoreHours: TStringField; qSysServiceKpiAfterHours: TStringField; qSysServiceKpiTravelTime: TStringField; qSysServiceKpiFaultDetect: TStringField; qSysServiceKpiActive: TBooleanField; qSysPersonEmailAddress: TStringField; qSysServiceIDNo: TStringField; qSysServiceIDPart: TStringField; qSysServiceIDBearerID: TIntegerField; qSysServiceIDSpeedID: TIntegerField; qSysServiceIDDrawing: TStringField; qSysServiceIDModemTypeID: TIntegerField; qSysServiceIDCost: TFloatField; qSysServiceIDCost100: TFloatField; qSysServiceIDMake: TStringField; qSysServiceIDCh: TFloatField; qSysServiceIDMux: TStringField; qSysServiceIDLineID: TIntegerField; qSysServiceIDStartTerminalID: TIntegerField; qSysServiceIDInvoiced: TFloatField; qSysServiceIDTelcoID: TIntegerField; qSysServiceIDAuthorityID: TIntegerField; qSysServiceIDVirtualCableID: TIntegerField; qSysServiceIDServiceMnemonicID: TIntegerField; TabServiceMnemonic: TTabSheet; RxDBGrid3: TRxDBGrid; qSysServiceMnemonic: TQuery; dsSysServiceMnemonic: TDataSource; qSysServiceMnemonicID: TIntegerField; qSysServiceMnemonicServiceCode: TStringField; qSysServiceMnemonicDescription: TStringField; qSysServiceMnemonicPrefix: TStringField; qSysServiceMnemonicPass: TStringField; qSysServiceMnemonicActive: TBooleanField; qSysRateID: TIntegerField; qSysRateServiceTypeID: TIntegerField; qSysRateCode: TStringField; qSysRateServiceType: TStringField; qSysRateLength: TFloatField; qSysRateCost: TFloatField; qSysRateCost100: TFloatField; qSysRatePercentage: TIntegerField; qSysRatePartCost: TFloatField; qSysRateRateDescription: TStringField; qSysRateActive: TBooleanField; qSysRateStartDate: TDateTimeField; qSysRateEndDate: TDateTimeField; qSysRateLastUpdatedBy: TStringField; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure GetUserName(var sUserName: string); procedure CheckEnvironment(var sUserName: String; var lSuccessful: boolean); procedure PaintTreeViewSystem; procedure TreeViewSystemChange(Sender: TObject; Node: TTreeNode); procedure ClearTabSheets; procedure CloseTab(CloseTabSheet : TTabSheet); procedure OpenTab(OpenTabSheet : TTabSheet); procedure EditRecord(const TabPageID: integer;const AppendRecord: boolean); procedure DeleteRecord(const TabPageID: integer); procedure ApplyFilter(OpenTabSheet : TTabSheet); procedure FieldChange(const TabPageID: integer); procedure btnAddClick(Sender: TObject); procedure btnApplyFilterClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject); procedure RxDBGridSysDblClick(Sender: TObject); procedure RxDBGridSysTitleClick(Column: TColumn); procedure RxDBGridSysGetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); procedure cbFieldChange(Sender: TObject); procedure btnClearClick(Sender: TObject); function CurrentQuery(const TabPageID: integer): TQuery; function CurrentTabPageID: integer; function CurrentDataSource(const TabPageID: integer): TDataSource; function CurrentTable(const TabPageID: integer): string; function CurrentField(const TabPageID: integer): string; procedure ActionTabClose(Sender: TObject); procedure ActionExit(Sender: TObject); procedure ActionPrintCurrentTab(Sender: TObject); procedure ActionFileCurrentTab(Sender: TObject); procedure SysPageControlChange(Sender: TObject); procedure cbActiveClick(Sender: TObject); procedure cbNotActiveClick(Sender: TObject); procedure mnuMainFilePrinterSetupClick(Sender: TObject); procedure mnuHelpAboutClick(Sender: TObject); procedure mnuFilePrintSetupClick(Sender: TObject); procedure mnuFileExitClick(Sender: TObject); procedure mnuToolsSelectTestDatabaseItemClick(Sender: TObject); procedure mnuToolsSelectMainDatabaseItemClick(Sender: TObject); private { Private declarations } nWindow: Integer; // Array element in MainForm's (Public) array aWinForm. OperatorID : string; // Network Name - Used for multiple data entry. n_User_ID : Integer; // tUser.ID for the operator. AuditActionUpdate : string; AuditActionDelete : string; AuditActionInsert : string; TabList : Array of string; TabFieldNumberList : Array of integer; TabEditList : Array of string; TabActiveList : Array of boolean; TabNotActiveList : Array of boolean; TabListIndex : integer; TestDatabaseFlag : boolean; procedure ActionReportCPIAdjustment(Sender: TObject); function GetEditValue(const TabPage: TTabSheet): string; procedure SetEditValue(const TabPage: TTabSheet;const Value: string); function GetFieldNumberValue(const TabPage: TTabSheet): integer; procedure SetFieldNumberValue(const TabPage:TTabSheet; const Value: integer); function GetActiveValue(const TabPage: TTabSheet): boolean; procedure SetActiveValue(const TabPage: TTabSheet; const Value: boolean); function GetNotActiveValue(const TabPage: TTabSheet): boolean; procedure SetNotActiveValue(const TabPage: TTabSheet; const Value: boolean); procedure SetOperatorID(const Value: string); procedure SetCaption(const Value: string); procedure SetUserID(const Value: integer); protected // procedure SetWindowNum(Value: Integer); published // Used to access nWindow. // property ActiveWindowNum: Integer // read nWindow write SetWindowNum default -1; property OPERATORNAME: string read OperatorID write SetOperatorID; property OPERATORFULLNAME: string write SetCaption; property OPERATORNUMBER: integer read n_User_ID write SetUserID; public { Public declarations } end; var MainForm: TMainForm; s_User_ID : string; // ID number (string) for OperatorID. // sExeDirectory : string; // Directory con implementation uses About, AccessRightsSys, ConstantValuesSys, DataMod, DateFunctions, GenFns, GenericPrint, CommonControlFns, // PrinterFunctions, SysEdit, SysEditServiceID, SysEditServType, SysEditBatchType, SysEditUserFunction, SysEditCustomer, SysEditAgreement, SysEditTariff, SysEditSupplier, SysEditServiceSplit, SysEditServiceKpi; {$R *.DFM} var TreeViewBeingUpdated : boolean; InitiatingForm : boolean; CloseDisabled : boolean; aAccess : array[0..16] of boolean; // Holds access rights of the Operator. TabPageID : integer; // JobID : string; // Job Name - Used for multiple data entry. // SelectedBatchID : Integer; // InitiateNode : TTreeNode; sFieldActivity : string; sFieldAdjustment : string; sFieldAgreement : string; sFieldAgreementTariffs : string; sFieldAgreementType : string; sFieldApplication : string; sFieldAudit : string; sFieldAuditTrail : string; sFieldBatch : string; sFieldBatchHistory : string; sFieldBatchStatus : string; sFieldBatchType : string; sFieldCentre : string; sFieldCostRange : string; sFieldCriticalType : string; sFieldCustomer : string; sFieldDataCollectionMap : string; sFieldDataSourceDetail : string; sFieldDataSourceType : string; sFieldDepartment : string; sFieldDialledNumber : string; sFieldDestination : string; sFieldDiscount : string; sFieldDiscountedRate : string; sFieldDubiousResolution : string; sFieldDubiousResult : string; sFieldDubiousType : string; sFieldDubiousValidResolution : string; sFieldElement : string; sFieldFunction : string; sFieldGroup : string; sFieldLocation : string; sFieldOrigin : string; sFieldParameter : string; sFieldPerson : string; sFieldProgram : string; sFieldRate : string; sFieldRateDescription : string; sFieldServiceID : string; sFieldServiceKpi : string; sFieldServiceSplit : string; sFieldServiceSystem : string; sFieldServiceType : string; sFieldStatus : string; sFieldSubledger : string; sFieldSupplier : string; sFieldSupplierServiceCode : string; sFieldSystem : string; sFieldTransactionGroup : string; sFieldTransactionType : string; sFieldUser : string; sFieldUserFunction : string; sFieldValidAccount : string; procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction); begin // Indicate that this form is closed. if not Timebomb.Enabled then ClearTabSheets; LogOffUser(s_User_ID); DM.dbPPdata.Connected := False; // if nWindow <> -1 then // // It has been set by the calling program. // aWinForm[nWindow] := False; // Value of nWindow set by calling program. end; // procedure FormClose(). procedure TMainForm.FormCreate(Sender: TObject); var nCount : integer; nMaxCount : integer; PromptUser: boolean; ActionDescription : string; begin nWindow := -1; TreeViewBeingUpdated := False; InitiatingForm := True; PromptUser := (ParamCount = 0); if PromptUser then begin // True=Prompt for password. GetUserName(OperatorID); GetOperatorReference(OperatorID, s_User_ID); end else begin s_User_ID := Trim(ParamStr(1)); DM.SetDatabaseSet((ParamStr(2) = '1')); end; n_User_ID := StrToInt(s_User_ID); if SetAccessRights(PromptUser, aAccess) then begin qry.SQL.Add('SELECT *'); qry.SQL.Add('FROM tEvent'); qry.SQL.Add('WHERE Description LIKE ''Reference%'''); qry.Open; while not qry.Eof do begin ActionDescription := UpperCase(qry.FieldByName('Description').AsString); if (Pos('UPDATE', ActionDescription) > 0) then AuditActionUpdate := qry.FieldByName('id').AsString else if (Pos('DELETE', ActionDescription) > 0) then AuditActionDelete := qry.FieldByName('id').AsString else if (Pos('INSERT', ActionDescription) > 0) then AuditActionInsert := qry.FieldByName('id').AsString; qry.Next; end; qry.Close; qry.SQL.Clear; with SysPageControl do begin nMaxCount := PageCount; SetLength(TabList, nMaxCount); SetLength(TabFieldNumberList, nMaxCount); SetLength(TabEditList, nMaxCount); SetLength(TabActiveList, nMaxCount); SetLength(TabNotActiveList, nMaxCount); Dec(nMaxCount); for nCount := 0 to nMaxCount do begin TabList[nCount] := Pages[nCount].Name; if (Pages[nCount].Name = 'TabServiceID') then begin TabListIndex := nCount; TabFieldNumberList[nCount] := 1; // ServiceID - CommonControlFns(). TabEditList[nCount] := '02'; end else if (Pages[nCount].Name = 'TabAdjustment') then begin TabListIndex := nCount; TabFieldNumberList[nCount] := 5; // BatchID - CommonControlFns(). TabEditList[nCount] := '1111'; end else begin TabFieldNumberList[nCount] := -1; TabEditList[nCount] := ''; end; TabActiveList[nCount] := True; TabNotActiveList[nCount] := False; end; // for count. end; // with. TabListIndex := 0; PaintTreeViewSystem; TestDatabaseFlag := TestForTestDB; if TestDatabaseFlag and not aAccess[DEVELOPER] then begin TestDatabaseFlag := False; DM.SetDatabaseSet(TestDatabaseFlag); end; lblTestData.Visible := TestDatabaseFlag; end else begin TimeBomb.Enabled := True; end; InitiatingForm := False; CloseDisabled := False; end; // procedure FormCreate(). //procedure TMainForm.SetWindowNum(Value: Integer); //// This procedure allows the calling procedure to identify this form. //begin // if nWindow <> Value then // if (Value > -1) and (Value < WINNUM) then // nWindow := Value // else nWindow := -1; //end; // procedure SetWindowNum(). procedure TMainForm.SetOperatorID(const Value: string); begin OperatorID := Value; end; // SetOperatorID. procedure TMainForm.SetCaption(const Value: string); begin Caption := 'Preprocessor System Tables Operator: ' + Value; end; // SetCaption. procedure TMainForm.SetUserID(const Value: integer); begin if (Value > 0) then begin n_user_id := Value; s_user_id := IntToStr(n_user_id); end; end; // SetUserID. procedure TMainForm.GetUserName(var sUserName: string); var Reg : TRegistry; lFound : Boolean; sTempUserName : string; begin sTempUserName := 'unknown'; lFound := False; Reg := TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; // Windows 95/98. if Reg.OpenKeyReadOnly('\Network\Logon') then begin if Reg.ValueExists('Username') then begin try sTempUserName := Reg.ReadString('Username'); lFound := True; except lFound := False; end; // try..except. end; // if Reg.ValueExists('Username') then. end; // if Reg.OpenKeyReadOnly('\Network\Logon') then. (Windows 95/98) // Windows NT. if not lFound then begin Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKeyReadOnly('\Volatile Environment') then begin if Reg.ValueExists('LOGIN_NAME') then begin // Netware networking variables. try // Netware networking variables. sTempUserName := Reg.ReadString('LOGIN_NAME'); lFound := True; except lFound := False; end; // try..except. end // if Reg.ValueExists('LOGIN_NAME') then. else if Reg.ValueExists('NWUSERNAME') then begin // Netware networking variables. try sTempUserName := Reg.ReadString('NWUSERNAME'); lFound := True; except lFound := False; end; // try..except. end; // if Reg.ValueExists('LOGIN_NAME') then. end; end; // if not lFound then. (Windows NT) Reg.Free; // Windows 2000. if not lFound then CheckEnvironment(sTempUserName, lFound); if not lFound then sTempUserName := 'unknown'; sUserName := sTempUserName; end; // procedure GetUserName(). procedure TMainForm.CheckEnvironment(var sUserName : String; var lSuccessful: boolean); var pcEnvironmentName: PChar; pcValue: PChar; nLenValue: Integer; begin lSuccessful := False; nLenValue := 20; pcEnvironmentName := 'USERNAME'; pcValue := StrAlloc(nLenValue); nLenValue := GetEnvironmentVariable( pcEnvironmentName, pcValue, nLenValue); if nLenValue > 0 then begin sUserName := StrPas(pcValue); lSuccessful := True; end else begin sUserName := ''; end; // if nLenValue > 0 then begin. end; // procedure CheckEnvironment(). function TMainForm.GetEditValue(const TabPage: TTabSheet): string; var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin Result := TabEditList[TabListIndex]; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; Result := TabEditList[TabListIndex]; end else begin TabListIndex := 0; Result := ''; end; end; end; // GetEditValue. procedure TMainForm.SetEditValue(const TabPage: TTabSheet;const Value: string); var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin TabEditList[TabListIndex] := Value; edtValue.Text := Value; end else begin for nCount := 0 to Length(TabList) - 1 do if (TabList[nCount] = CurrentTabPageName) then break; if (nCount < Length(TabList)) then begin TabListIndex := nCount; TabEditList[TabListIndex] := Value; edtValue.Text := Value; end else begin TabListIndex := 0; end; end; end; // SetEditValue. function TMainForm.GetFieldNumberValue(const TabPage: TTabSheet): integer; var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin Result := TabFieldNumberList[TabListIndex]; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; Result := TabFieldNumberList[TabListIndex]; end else begin TabListIndex := 0; Result := -1; end; end; end; // GetFieldNumberValue. procedure TMainForm.SetFieldNumberValue( const TabPage: TTabSheet; const Value: integer); var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin TabFieldNumberList[TabListIndex] := Value; if (Value = -1) then cbField.Text := ''; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; TabFieldNumberList[TabListIndex] := Value; if (Value = -1) then cbField.Text := ''; end else begin TabListIndex := 0; end; end; FieldChange(TabPageID); end; // SetFieldNumberValue. function TMainForm.GetActiveValue(const TabPage: TTabSheet): boolean; var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin Result := TabActiveList[TabListIndex]; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; Result := TabActiveList[TabListIndex]; end else begin TabListIndex := 0; Result := False; end; end; end; // GetActiveValue. procedure TMainForm.SetActiveValue(const TabPage: TTabSheet; const Value: boolean); var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin TabActiveList[TabListIndex] := Value; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; TabActiveList[TabListIndex] := Value; end else begin TabListIndex := 0; end; end; end; // SetActiveValue. function TMainForm.GetNotActiveValue(const TabPage: TTabSheet): boolean; var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin Result := TabNotActiveList[TabListIndex]; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; Result := TabNotActiveList[TabListIndex]; end else begin TabListIndex := 0; Result := False; end; end; end; // GetNotActiveValue. procedure TMainForm.SetNotActiveValue(const TabPage: TTabSheet; const Value: boolean); var CurrentTabPageName : string; nCount : integer; begin CurrentTabPageName := TabPage.Name; if (TabList[TabListIndex] = CurrentTabPageName) then begin TabNotActiveList[TabListIndex] := Value; end else begin for nCount := 0 to Length(TabList) - 1 do begin if (TabList[nCount] = CurrentTabPageName) then break; end; if (nCount < Length(TabList)) then begin TabListIndex := nCount; TabNotActiveList[TabListIndex] := Value; end else begin TabListIndex := 0; end; end; end; // SetNotActiveValue. procedure TMainForm.PaintTreeViewSystem; const White_ = 0; Yellow_ = 2; Red_ = 4; Green_ = 6; var RootName : string; // NodeName : string; MyTreeNode1 : TTreeNode; // MyTreeNode2 : TTreeNode; // MyImageIndex : integer; // NodeImageIndex : integer; // ThisState : integer; begin TreeViewBeingUpdated := True; TreeViewSystem.Items.BeginUpdate; TreeViewSystem.Items[0]; // Initiate only. RootName := ''; // NodeImageIndex := Green_; // Initiate only. TreeViewSystem.Items.Clear; // Add the invoice entry part (at the top of the tree). with TreeViewSystem.Items do begin // Now add the remaining elements of the tree. // MyImageIndex := White_; MyTreeNode1 := Add(nil, 'Charges'); AddChild(MyTreeNode1,'tCentre'); AddChild(MyTreeNode1,'tActivity'); AddChild(MyTreeNode1,'tDepartment'); AddChild(MyTreeNode1,'tElement'); AddChild(MyTreeNode1,'tGroup'); AddChild(MyTreeNode1,'tRate'); AddChild(MyTreeNode1,'tSubledger'); MyTreeNode1 := Add(nil, 'Customer'); AddChild(MyTreeNode1,'tCustomer'); AddChild(MyTreeNode1,'tDiscount'); AddChild(MyTreeNode1,'tDiscountedRate'); AddChild(MyTreeNode1,'tServiceSplit'); AddChild(MyTreeNode1,'tLocation'); AddChild(MyTreeNode1,'tPerson'); AddChild(MyTreeNode1,'tStatus'); MyTreeNode1 := Add(nil, 'Information'); AddChild(MyTreeNode1,'tDestination'); AddChild(MyTreeNode1,'tDialledNumber'); AddChild(MyTreeNode1,'tOrigin'); AddChild(MyTreeNode1,'tParameter'); AddChild(MyTreeNode1,'tProgram'); AddChild(MyTreeNode1,'tRateDescription'); AddChild(MyTreeNode1,'tTransactionGroup'); AddChild(MyTreeNode1,'tTransactionType'); MyTreeNode1 := Add(nil, 'Invoice'); AddChild(MyTreeNode1,'tAdjustment'); AddChild(MyTreeNode1,'tBatch'); AddChild(MyTreeNode1,'tBatchType'); AddChild(MyTreeNode1,'tBatchHistory'); AddChild(MyTreeNode1,'tBatchStatus'); AddChild(MyTreeNode1,'tDataCollectionMap'); AddChild(MyTreeNode1,'tDataSourceDetail'); AddChild(MyTreeNode1,'tDataSourceType'); if aAccess[DEVELOPER] then begin MyTreeNode1 := Add(nil, 'Security'); AddChild(MyTreeNode1,'tFunction'); AddChild(MyTreeNode1,'tUser'); AddChild(MyTreeNode1,'tUserFunction'); if aAccess[AUDIT] then begin AddChild(MyTreeNode1,'tAudit'); AddChild(MyTreeNode1,'tAuditTrail'); // MyTreeNode1 := Add(nil, 'Audit'); // MyTreeNode1.ImageIndex := MyImageIndex; // MyTreeNode1.SelectedIndex := MyImageIndex + 1; end; // AUDIT. end; MyTreeNode1 := Add(nil, 'Service'); AddChild(MyTreeNode1,'tAgreement'); AddChild(MyTreeNode1,'tAgreementTariffs'); AddChild(MyTreeNode1,'tAgreementType'); AddChild(MyTreeNode1,'tApplication'); AddChild(MyTreeNode1,'tServiceID'); AddChild(MyTreeNode1,'tServiceKpi'); AddChild(MyTreeNode1,'tServiceMnemonic'); AddChild(MyTreeNode1,'tServiceType'); AddChild(MyTreeNode1,'tSupplier'); AddChild(MyTreeNode1,'tSupplierServiceCode'); AddChild(MyTreeNode1,'tSystem'); AddChild(MyTreeNode1,'tValidAccountNumber'); AddChild(MyTreeNode1,'ValidServiceSystem'); MyTreeNode1 := Add(nil, 'Validation'); AddChild(MyTreeNode1,'tCostRange'); AddChild(MyTreeNode1,'tCriticalType'); AddChild(MyTreeNode1,'tDubiousResolution'); AddChild(MyTreeNode1,'tDubiousResult'); AddChild(MyTreeNode1,'tDubiousType'); AddChild(MyTreeNode1,'tDubiousValidResolution'); end; // with TreeViewSystem.Items do begin. mnuToolsSelectMainDatabaseItem.Visible := aAccess[DEVELOPER]; mnuToolsSelectTestDatabaseItem.Visible := mnuToolsSelectMainDatabaseItem.Visible; TreeViewSystem.Items.EndUpdate; if not InitiatingForm then TreeViewSystem.SetFocus; TreeViewBeingUpdated := False; ClearTabSheets; end; // PaintTreeViewSystem. procedure TMainForm.TreeViewSystemChange(Sender: TObject; Node: TTreeNode); var NodeName : string; begin if not TreeViewBeingUpdated then begin NodeName := Node.Text; if (NodeName = 'tActivity') then OpenTab(TabActivity) else if (NodeName = 'tAdjustment') then OpenTab(TabAdjustment) else if (NodeName = 'tAgreement') then OpenTab(TabAgreement) else if (NodeName = 'tAgreementTariffs') then OpenTab(TabAgreementTariffs) else if (NodeName = 'tAgreementType') then OpenTab(TabAgreementType) else if (NodeName = 'tApplication') then OpenTab(TabApplication) else if (NodeName = 'tAudit') then OpenTab(TabAudit) else if (NodeName = 'tAuditTrail') then OpenTab(TabAuditTrail) else if (NodeName = 'tBatch') then OpenTab(TabBatch) else if (NodeName = 'tBatchHistory') then OpenTab(TabBatchHistory) else if (NodeName = 'tBatchStatus') then OpenTab(TabBatchStatus) else if (NodeName = 'tBatchType') then OpenTab(TabBatchType) else if (NodeName = 'tCentre') then OpenTab(TabCentre) else if (NodeName = 'tCostRange') then OpenTab(TabCostRange) else if (NodeName = 'tCriticalType') then OpenTab(TabCriticalType) else if (NodeName = 'tCustomer') then OpenTab(TabCustomer) else if (NodeName = 'tDataCollectionMap') then OpenTab(TabDataCollectionMap) else if (NodeName = 'tDataSourceDetail') then OpenTab(TabDataSourceDetail) else if (NodeName = 'tDataSourceType') then OpenTab(TabDataSourceType) else if (NodeName = 'tDepartment') then OpenTab(TabDepartment) else if (NodeName = 'tDestination') then OpenTab(TabDestination) else if (NodeName = 'tDialledNumber') then OpenTab(TabDialledNumber) else if (NodeName = 'tDiscount') then OpenTab(TabDiscount) else if (NodeName = 'tDiscountedRate') then OpenTab(TabDiscountedRate) else if (NodeName = 'tDubiousResolution') then OpenTab(TabDubiousResolution) else if (NodeName = 'tDubiousResult') then OpenTab(TabDubiousResult) else if (NodeName = 'tDubiousType') then OpenTab(TabDubiousType) else if (NodeName = 'tDubiousValidResolution') then OpenTab(TabDubiousValidResolution) else if (NodeName = 'tElement') then OpenTab(TabElement) else if (NodeName = 'tFunction') then OpenTab(TabFunction) else if (NodeName = 'tGroup') then OpenTab(TabGroup) else if (NodeName = 'tLocation') then OpenTab(TabLocation) else if (NodeName = 'tOrigin') then OpenTab(TabOrigin) else if (NodeName = 'tParameter') then OpenTab(TabParameter) else if (NodeName = 'tPerson') then OpenTab(TabPerson) else if (NodeName = 'tProgram') then OpenTab(TabProgram) else if (NodeName = 'tRate') then OpenTab(TabRate) else if (NodeName = 'tRateDescription') then OpenTab(TabRateDescription) else if (NodeName = 'tServiceID') then OpenTab(TabServiceID) else if (NodeName = 'tServiceKpi') then OpenTab(TabServiceKpi) else if (NodeName = 'tServiceMnemonic') then OpenTab(TabServiceMnemonic) else if (NodeName = 'tServiceSplit') then OpenTab(TabServiceSplit) else if (NodeName = 'tServiceType') then OpenTab(TabServiceType) else if (NodeName = 'tStatus') then OpenTab(TabStatus) else if (NodeName = 'tSubledger') then OpenTab(TabSubledger) else if (NodeName = 'tSupplier') then OpenTab(TabSupplier) else if (NodeName = 'tSupplierServiceCode') then OpenTab(TabSupplierServiceCode) else if (NodeName = 'tSystem') then OpenTab(TabSystem) else if (NodeName = 'tTransactionGroup') then OpenTab(TabTransactionGroup) else if (NodeName = 'tTransactionType') then OpenTab(TabTransactionType) else if (NodeName = 'tUser') then OpenTab(TabUser) else if (NodeName = 'tUserFunction') then OpenTab(TabUserFunction) else if (NodeName = 'tValidAccountNumber') then OpenTab(TabValidAccount) else if (NodeName = 'ValidServiceSystem') then OpenTab(TabServiceSystem); SysPageControl.Visible := True; SysPageControlChange(Sender); // For when the Tab is first opened. end; // if not TreeViewBeingUpdated then begin. end; // TreeViewSystemChange(). procedure TMainForm.ClearTabSheets; var nTab : integer; begin for nTab := 0 to SysPageControl.PageCount-1 do CloseTab(SysPageControl.Pages[nTab]); SysPageControl.Visible := False; panelTopOfTab.Visible := False; end; // procedure ClearTabSheets(). procedure TMainForm.CloseTab(CloseTabSheet : TTabSheet); var TabSheet : TTabSheet; begin TabSheet := CloseTabSheet; TabSheet.TabVisible := False; TabSheet.Visible := False; if (TabSheet = TabActivity) then qSysActivity.Close else if (TabSheet = TabAdjustment) then qSysAdjustment.Close else if (TabSheet = TabAgreement) then qSysAgreement.Close else if (TabSheet = TabAgreementTariffs) then qSysAgreementTariffs.Close else if (TabSheet = TabAgreementType) then qSysAgreementType.Close else if (TabSheet = TabApplication) then qSysApplication.Close else if (TabSheet = TabAudit) then qSysAudit.Close else if (TabSheet = TabAuditTrail) then qSysAuditTrail.Close else if (TabSheet = TabBatch) then qSysBatch.Close else if (TabSheet = TabBatchHistory) then qSysBatchHistory.Close else if (TabSheet = TabBatchType) then qSysBatchType.Close else if (TabSheet = TabBatchStatus) then qSysBatchStatus.Close else if (TabSheet = TabCentre) then qSysCentre.Close else if (TabSheet = TabCostRange) then qSysCostRange.Close else if (TabSheet = TabCriticalType) then qSysCriticalType.Close else if (TabSheet = TabCustomer) then qSysCustomer.Close else if (TabSheet = TabDataCollectionMap) then qSysDataCollectionMap.Close else if (TabSheet = TabDataSourceDetail) then qSysDataSourceDetail.Close else if (TabSheet = TabDataSourceType) then qSysDataSourceType.Close else if (TabSheet = TabDepartment) then qSysDepartment.Close else if (TabSheet = TabDestination) then qSysDestination.Close else if (TabSheet = TabDialledNumber) then qSysDialledNumber.Close else if (TabSheet = TabDiscount) then qSysDiscount.Close else if (TabSheet = TabDiscountedRate) then qSysDiscountedRate.Close else if (TabSheet = TabDubiousResolution) then qSysDubiousResolution.Close else if (TabSheet = TabDubiousResult) then qSysDubiousResult.Close else if (TabSheet = TabDubiousType) then qSysDubiousType.Close else if (TabSheet = TabDubiousValidResolution) then qSysDubiousValidResolution.Close else if (TabSheet = TabElement) then qSysElement.Close else if (TabSheet = TabFunction) then qSysFunction.Close else if (TabSheet = TabGroup) then qSysGroup.Close else if (TabSheet = TabLocation) then qSysLocation.Close else if (TabSheet = TabOrigin) then qSysOrigin.Close else if (TabSheet = TabParameter) then qSysParameter.Close else if (TabSheet = TabPerson) then qSysPerson.Close else if (TabSheet = TabProgram) then qSysProgram.Close else if (TabSheet = TabRate) then qSysRate.Close else if (TabSheet = TabRateDescription) then qSysRateDescription.Close else if (TabSheet = TabServiceID) then qSysServiceID.Close else if (TabSheet = TabServiceKpi) then qSysServiceKpi.Close else if (TabSheet = TabServiceMnemonic) then qSysServiceMnemonic.Close else if (TabSheet = TabServiceSplit) then qSysServiceSplit.Close else if (TabSheet = TabServiceSystem) then qSysServiceSystem.Close else if (TabSheet = TabServiceType) then qSysServiceType.Close else if (TabSheet = TabStatus) then qSysStatus.Close else if (TabSheet = TabSubledger) then qSysSubledger.Close else if (TabSheet = TabSupplier) then qSysSupplier.Close else if (TabSheet = TabSupplierServiceCode) then qSysSupplierServiceCode.Close else if (TabSheet = TabSystem) then qSysSystem.Close else if (TabSheet = TabTransactionGroup) then qSysTransactionGroup.Close else if (TabSheet = TabTransactionType) then qSysTransactionType.Close else if (TabSheet = TabUser) then qSysUser.Close else if (TabSheet = TabUserFunction) then qSysUserFunction.Close else if (TabSheet = TabValidAccount) then qSysValidAccount.Close; SysPageControlChange(Nil); // Resets data for the Tab now in focus. end; // procedure CloseTab(). procedure TMainForm.OpenTab(OpenTabSheet : TTabSheet); var TabSheet : TTabSheet; begin TabSheet := OpenTabSheet; TabSheet.TabVisible := True; TabSheet.Visible := TabSheet.TabVisible; SysPageControl.Visible := True; SysPageControl.ActivePage := TabSheet; // Take the opportunity to let Windows do its stuff. Application.ProcessMessages; TabPageID := CurrentTabPageID; if (TabPageID = TabActivityID) then qSysActivity.Open else if (TabPageID = TabAdjustmentID) then qSysAdjustment.Open else if (TabPageID = TabAgreementID) then qSysAgreement.Open else if (TabPageID = TabAgreementTariffsID) then qSysAgreementTariffs.Open else if (TabPageID = TabAgreementTypeID) then qSysAgreementType.Open else if (TabPageID = TabApplicationID) then qSysApplication.Open else if (TabPageID = TabAuditID) then qSysAudit.Open else if (TabPageID = TabAuditTrailID) then qSysAuditTrail.Open else if (TabPageID = TabBatchID) then qSysBatch.Open else if (TabPageID = TabBatchHistoryID) then qSysBatchHistory.Open else if (TabPageID = TabBatchTypeID) then qSysBatchType.Open else if (TabPageID = TabBatchStatusID) then qSysBatchStatus.Open else if (TabPageID = TabCentreID) then qSysCentre.Open else if (TabPageID = TabCostRangeID) then qSysCostRange.Open else if (TabPageID = TabCriticalTypeID) then qSysCriticalType.Open else if (TabPageID = TabCustomerID) then qSysCustomer.Open else if (TabPageID = TabDataCollectionMapID) then qSysDataCollectionMap.Open else if (TabPageID = TabDataSourceDetailID) then qSysDataSourceDetail.Open else if (TabPageID = TabDataSourceTypeID) then qSysDataSourceType.Open else if (TabPageID = TabDepartmentID) then qSysDepartment.Open else if (TabPageID = TabDestinationID) then qSysDestination.Open else if (TabPageID = TabDialledNumberID) then qSysDialledNumber.Open else if (TabPageID = TabDiscountID) then qSysDiscount.Open else if (TabPageID = TabDiscountedRateID) then qSysDiscountedRate.Open else if (TabPageID = TabDubiousResolutionID) then qSysDubiousResolution.Open else if (TabPageID = TabDubiousResultID) then qSysDubiousResult.Open else if (TabPageID = TabDubiousTypeID) then qSysDubiousType.Open else if (TabPageID = TabDubiousValidResolutionID) then qSysDubiousValidResolution.Open else if (TabPageID = TabElementID) then qSysElement.Open else if (TabPageID = TabFunctionID) then qSysFunction.Open else if (TabPageID = TabGroupID) then qSysGroup.Open else if (TabPageID = TabLocationID) then qSysLocation.Open else if (TabPageID = TabOriginID) then qSysOrigin.Open else if (TabPageID = TabParameterID) then qSysParameter.Open else if (TabPageID = TabPersonID) then qSysPerson.Open else if (TabPageID = TabProgramID) then qSysProgram.Open else if (TabPageID = TabRateID) then qSysRate.Open else if (TabPageID = TabRateDescriptionID) then qSysRateDescription.Open else if (TabPageID = TabServiceIDID) then qSysServiceID.Open else if (TabPageID = TabServiceKpiID) then qSysServiceKpi.Open else if (TabPageID = TabServiceMnemonicID) then qSysServiceMnemonic.Open else if (TabPageID = TabServiceSplitID) then qSysServiceSplit.Open else if (TabPageID = TabServiceSystemID) then qSysServiceSystem.Open else if (TabPageID = TabServiceTypeID) then qSysServiceType.Open else if (TabPageID = TabStatusID) then qSysStatus.Open else if (TabPageID = TabSubledgerID) then qSysSubledger.Open else if (TabPageID = TabSupplierID) then qSysSupplier.Open else if (TabPageID = TabSupplierServiceCodeID) then qSysSupplierServiceCode.Open else if (TabPageID = TabSystemID) then qSysSystem.Open else if (TabPageID = TabTransactionTypeID) then qSysTransactionType.Open else if (TabPageID = TabTransactionGroupID) then qSysTransactionGroup.Open else if (TabPageID = TabUserID) then qSysUser.Open else if (TabPageID = TabUserFunctionID) then qSysUserFunction.Open else if (TabPageID = TabValidAccountID) then qSysValidAccount.Open; // Take the opportunity to let Windows do its stuff again. Application.ProcessMessages; end; // procedure OpenTab(). procedure TMainForm.ApplyFilter(OpenTabSheet : TTabSheet); var qFilter : TQuery; slQuery : TStrings; sField : string; nPos : integer; slWhere : TStringList; nWhere : integer; sTempString : string; lNumberUpdated : boolean; sValue : string; begin // Apply the filter to reduce the data displayed. slWhere := TStringList.Create; qFilter := CurrentQuery(TabPageID); sField := CurrentField(TabPageID); if (qFilter <> Nil) then begin qFilter.Close; slQuery := qFilter.SQL; for nPos := (slQuery.Count-1) downto 0 do begin if (Pos('WHERE ',UpperCase(slQuery.Strings[nPos])) > 0) and (Pos('WHERE ',UpperCase(slQuery.Strings[nPos])) < 5) then break; end; if (nPos < 0)then begin for nPos := 0 to (slQuery.Count-1) do begin if (Pos('ORDER BY ',UpperCase(slQuery.Strings[nPos])) > 0) then break; end; if (nPos = slQuery.Count-1) then begin nPos := slQuery.Count - 1; slQuery.Add(slQuery[nPos]); slQuery[nPos] := ''; end else begin slQuery.Add(slQuery.Strings[nPos]); slQuery.Strings[nPos] := ''; end; end else begin slQuery.Strings[nPos] := ''; end; sValue := Trim(edtValue.Text); if (Length(sValue) > 0) then begin sField := Trim(sField); if (Length(sField) = 0) then begin cbFieldChange(nil); sField := CurrentField(TabPageID); end; sTempString := 'WHERE ' + sField; if (Copy(sField,Length(sField),1) = '''') then begin // string or date. sTempString := sTempString + Trim(sValue)+'%'''; end else begin // number. lNumberUpdated := False; ProveWholeInteger(sValue, lNumberUpdated); if lNumberUpdated then begin sValue := Trim(sValue); end; if (Length(sValue) > 0) then begin sTempString := sTempString + sValue; end else begin sTempString := ''; edtValue.Text := sTempString; end; end; slWhere.Add(sTempString); end; if cbActive.Visible then if cbActive.Checked then begin if not cbNotActive.Checked then begin if (Length(sTempString) = 0) then slWhere.Add('WHERE Active = 1') else slWhere.Add('AND Active = 1'); end; end else begin if not cbNotActive.Checked then cbNotActive.Checked := True; if (Length(sTempString) = 0) then slWhere.Add('WHERE Active <> 1') else slWhere.Add('AND Active <> 1'); end; for nWhere := 0 to (slWhere.Count - 1) do slQuery.Strings[nPos] := slQuery.Strings[nPos] + slWhere.Strings[nWhere]; if (Length(Trim(slQuery.Strings[nPos])) = 0) then slQuery.Delete(nPos); qFilter.SQL := slQuery; qFilter.Open; end; // if (qFilter <> Nil) then begin. end; // ApplyFilter(). procedure TMainForm.DeleteRecord(const TabPageID: integer); var CurrentTabID : integer; vNowAt : variant; sNewValue : string; sOldValue : string; sNewDate : string; sOldDate : string; sTodayNow : string; lAudit : boolean; AuditAction : string; lContinue : boolean; sAuditInsert : string; sAuditField : string; sAuditValue : string; AuditString : TStringList; sTempValue : string; // Used for SplitService. begin AuditString := TStringList.Create; CurrentTabID := TabPageID; lAudit := TestForAudit(CurrentTable(CurrentTabID)); sTodayNow := StandardDateTimeString(Now); sOldDate := 'NULL'; sNewDate := ''''+StandardDateString(Date)+''''; if (CurrentTabID = TabActivityID) then begin vNowAt := qSysActivity['id']; sOldDate := 'NULL'; if qSysActivity.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin // Need to save old value. qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tActivity'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tActivity'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tActivity'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysActivity.Close; qSysActivity.Open; with qSysActivity do Locate('id',vNowAt,[]); end // TabActivityID. else if (CurrentTabID = TabAgreementID) then begin vNowAt := qSysAgreement['id']; if not VarIsNull(vNowAt) then begin if qSysAgreement.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tAgreement'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin AuditAction := AuditActionDelete; SetAuditStart(IntToStr(OPERATORNUMBER), AuditAction, 'tAgreement', sAuditInsert, sAuditField, sAuditValue); SetAuditID(IntToStr(vNowAt), sAuditValue); SetAuditData('ACTIVE', sOldValue, sNewValue, AuditString); SaveAudit(sAuditInsert, sAuditField, sAuditValue, AuditString); end; // lAudit. qSysAgreement.Close; qSysAgreement.Open; end; // vNowAt. end // TabAgreementID. else if (CurrentTabID = TabAgreementTariffsID) then begin vNowAt := qSysAgreementTariffs['id']; sOldDate := 'NULL'; if not VarIsNull(vNowAt) then begin if qSysAgreementTariffs.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tAgreementTariffs'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin AuditAction := AuditActionDelete; SetAuditStart(IntToStr(OPERATORNUMBER), AuditAction, 'tAgreementTariffs', sAuditInsert, sAuditField, sAuditValue); SetAuditID(IntToStr(vNowAt), sAuditValue); SetAuditData('ACTIVE', sOldValue, sNewValue, AuditString); SaveAudit(sAuditInsert, sAuditField, sAuditValue, AuditString); end; // lAudit. qSysAgreementTariffs.Close; qSysAgreementTariffs.Open; end; // vNowAt. end // TabAgreementTariffsID. else if (CurrentTabID = TabAgreementTypeID) then begin vNowAt := qSysAgreementType['id']; sOldDate := 'NULL'; if not VarIsNull(vNowAt) then begin if qSysAgreementType.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tAgreementType'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin AuditAction := AuditActionDelete; SetAuditStart(IntToStr(OPERATORNUMBER), AuditAction, 'tAgreementType', sAuditInsert, sAuditField, sAuditValue); SetAuditData('ID', IntToStr(vNowAt), 'NULL', AuditString); SetAuditData('DESCRIPTION', qSysProgram['Description'], 'NULL', AuditString); SaveAudit(sAuditInsert, sAuditField, sAuditValue, AuditString); end; // lAudit. qSysAgreementType.Close; qSysAgreementType.Open; end; // vNowAt. end // TabAgreementTypeID. else if (CurrentTabID = TabApplicationID) then begin vNowAt := qSysApplication['id']; if qSysApplication.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; with qry do begin Close; SQL.Clear; SQL.Add('UPDATE tApplication'); SQL.Add('SET Active = '+sNewValue); SQL.Add('WHERE ID ='+IntToStr(vNowAt)); ExecSQL; Close; if lAudit then begin SQL.Clear; SQL.Add('INSERT INTO tAuditTrail'); SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tApplication'',''Active'','+sOldValue+ ','+sNewValue+','+IntToStr(vNowAt)+')'); ExecSQL; Close; end; // lAudit. end; // qry. qSysApplication.Close; qSysApplication.Open; with qSysApplication do Locate('id',vNowAt,[]); end // TabApplicationID. else if (CurrentTabID = TabBatchTypeID) then begin vNowAt := qSysBatchType['id']; if qSysBatchType.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tBatchType'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tBatchType'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysBatchType.Close; qSysBatchType.Open; with qSysBatchType do Locate('id',vNowAt,[]); end // TabBatchTypeID. else if (CurrentTabID = TabCentreID) then begin vNowAt := qSysCentre['id']; sOldDate := 'NULL'; if qSysCentre.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tCentre'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tCentre'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tCentre'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysCentre.Close; qSysCentre.Open; with qSysCentre do Locate('id',vNowAt,[]); end // TabCentreID. else if (CurrentTabID = TabCustomerID) then begin vNowAt := qSysCustomer['id']; sOldDate := 'NULL'; if qSysCustomer.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tCustomer'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tCustomer'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tCustomer'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysCustomer.Close; qSysCustomer.Open; with qSysCustomer do Locate('id',vNowAt,[]); end // TabCustomerID. else if (CurrentTabID = TabDepartmentID) then begin vNowAt := qSysDepartment['id']; sOldDate := 'NULL'; if qSysDepartment.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tDepartment'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tDepartment'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tDepartment'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysDepartment.Close; qSysDepartment.Open; with qSysDepartment do Locate('id',vNowAt,[]); end // TabDepartmentID. else if (CurrentTabID = TabDestinationID) then begin vNowAt := qSysDestination['id']; sOldDate := 'NULL'; if qSysDestination.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tDestination'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tDestination'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysDestination.Close; qSysDestination.Open; with qSysDestination do Locate('id',vNowAt,[]); end // TabDestinationID. else if (CurrentTabID = TabDiscountID) then begin vNowAt := qSysDiscount['id']; if qSysDiscount.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tDiscount'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tDiscount'',''Active'','''+sOldValue+ ''','+sNewValue+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysDiscount.Close; qSysDiscount.Open; with qSysDiscount do Locate('id',vNowAt,[]); end // TabDiscountID. else if (CurrentTabID = TabDiscountedRateID) then begin vNowAt := qSysDiscountedRate['id']; if qSysDiscountedRate.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tDiscountedRate'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tDiscountedRate'',''Active'','''+sOldValue+ ''','+sNewValue+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysDiscountedRate.Close; qSysDiscountedRate.Open; with qSysDiscountedRate do Locate('id',vNowAt,[]); end // TabDiscountedRateID. else if (CurrentTabID = TabElementID) then begin vNowAt := qSysElement['id']; sOldDate := 'NULL'; if qSysElement.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tElement'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tElement'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tElement'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysElement.Close; qSysElement.Open; with qSysElement do Locate('id',vNowAt,[]); end // TabElementID. else if (CurrentTabID = TabGroupID) then begin vNowAt := qSysGroup['id']; sOldDate := 'NULL'; if qSysGroup.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tGroup'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tGroup'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tGroup'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysGroup.Close; qSysGroup.Open; with qSysGroup do Locate('id',vNowAt,[]); end // TabGroupID. else if (CurrentTabID = TabLocationID) then begin vNowAt := qSysLocation['id']; sOldDate := 'NULL'; if qSysLocation.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tLocation'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tLocation'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tLocation'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysLocation.Close; qSysLocation.Open; with qSysLocation do Locate('id',vNowAt,[]); end // TabLocationID. else if (CurrentTabID = TabOriginID) then begin vNowAt := qSysOrigin['id']; if qSysOrigin.FieldByName('Active').AsBoolean then begin sOldValue := '1'; sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sOldValue := '0'; sNewValue := '1'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tOrigin'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tOrigin'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysOrigin.Close; qSysOrigin.Open; with qSysOrigin do Locate('id',vNowAt,[]); end // TabOriginID. else if (CurrentTabID = TabPersonID) then begin vNowAt := qSysPerson['id']; if qSysPerson.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tPerson'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tPerson'',''Active'','''+sOldValue+ ''','+sNewValue+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysPerson.Close; qSysPerson.Open; with qSysPerson do Locate('id',vNowAt,[]); end // TabPersonID. else if (CurrentTabID = TabProgramID) then begin vNowAt := qSysProgram['id']; with qry do begin Close; SQL.Clear; SQL.Add('SELECT id'); SQL.Add('FROM tBatchType'); SQL.Add('WHERE ProgramID = '+IntToStr(vNowAt)); Open; if not (bof and eof) then lContinue := (MessageDlg('This ID is used in tBatchType. Continue?', mtWarning, [mbYes, mbNo], 0) = mrYes) else lContinue := True; Close; end; if lContinue then begin if lAudit then begin AuditAction := AuditActionDelete; SetAuditStart(IntToStr(OPERATORNUMBER), AuditAction, 'tProgram', sAuditInsert, sAuditField, sAuditValue); SetAuditData('ID', IntToStr(vNowAt), 'NULL', AuditString); SetAuditData('DESCRIPTION', qSysProgram['Description'], 'NULL', AuditString); SaveAudit(sAuditInsert, sAuditField, sAuditValue, AuditString); end; // lAudit. with qry do begin Close; SQL.Clear; SQL.Add('DELETE FROM tProgram'); SQL.Add('WHERE ID = '+IntToStr(vNowAt)); ExecSQL; end; qSysProgram.Close; qSysProgram.Open; end; // lContinue. end // TabProgramID. else if (CurrentTabID = TabRateID) then begin vNowAt := qSysRate['id']; sOldDate := 'NULL'; if qSysRate.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tRate'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tRate'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate+','); qry.SQL.Add('LastUpdatedBy = '''+OperatorID+''''); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tRate'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. Application.ProcessMessages; qSysRate.Close; qSysRate.Open; with qSysRate do Locate('id',vNowAt,[]); end // TabRateID. else if (CurrentTabID = TabServiceIDID) then begin vNowAt := qSysServiceID['id']; sOldDate := 'NULL'; if qSysServiceID.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT TerminationDate'); qry.SQL.Add('FROM tServiceID'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('TerminationDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceID'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('TerminationDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceID'',''TerminationDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysServiceID.Close; qSysServiceID.Open; with qSysServiceID do Locate('id',vNowAt,[]); end // TabServiceIDID. else if (CurrentTabID = TabServiceKpiID) then begin vNowAt := qSysServiceKpi['id']; if not qSysServiceKpi.FieldByName('Active').AsBoolean then begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end else begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceKpi'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceKpi'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysServiceKpi.Close; qSysServiceKpi.Open; with qSysServiceKpi do Locate('id',vNowAt,[]); end // TabServiceKpiID. else if (CurrentTabID = TabServiceMnemonicID) then begin vNowAt := qSysServiceMnemonic['id']; if not qSysServiceMnemonic.FieldByName('Active').AsBoolean then begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end else begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceMnemonic'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceMnemonic'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysServiceMnemonic.Close; qSysServiceMnemonic.Open; with qSysServiceMnemonic do Locate('id',vNowAt,[]); end // TabServiceMnemonicID. else if (CurrentTabID = TabServiceSplitID) then begin vNowAt := qSysServiceSplit['id']; if not qSysServiceSplit.FieldByName('Active').AsBoolean then begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end else begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceSplit'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceSplit'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. // Update the displayed split services. qSysServiceSplit.Close; qSysServiceSplit.Open; with qSysServiceSplit do Locate('id',vNowAt,[]); // The following Message deleted a/c RLD request. Tests done elsewhere to // prevent invoice processing so this "catch-all" comment is no longer required. // Test and deleting a service is also added below. RJC 110403. // MessageDlg('The tServiceSplit table MUST be updated '#13#10+ // 'to process relevant transactions.', mtWarning, [mbOk], 0); // Get the ServiceID value that links this deleted split record. qry.SQL.Clear; qry.SQL.Add('SELECT tServiceSplit.ServiceID'); qry.SQL.Add('FROM tServiceSplit'); qry.SQL.Add('WHERE tServiceSplit.ID = '+IntToStr(vNowAt)); qry.Open; sTempValue := qry.FieldByName('ServiceID').AsString; // Integer. qry.Close; // Now check if there are any active splits still in the table. qry.SQL.Clear; qry.SQL.Add('SELECT COUNT(*) AS "NumberActive"'); qry.SQL.Add('FROM tServiceSplit'); qry.SQL.Add('WHERE tServiceSplit.ServiceID = '+sTempValue); qry.SQL.Add('AND tServiceSplit.Active = 1'); qry.Open; if qry.FieldByName('NumberActive').AsInteger = 0 then begin // We must Terminate the ServiceID too - no Customers to charge. if qSysServiceID.Active then vNowAt := qSysServiceID['id'] // ONLY if table is open. else vNowAt := 0; // Closed, so don't sort. sOldDate := 'NULL'; sNewValue := '0'; AuditAction := AuditActionDelete; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceID'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('TerminationDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+sTempValue); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceID'',''TerminationDate'','''+sOldDate+ ''','+sNewDate+','+sTempValue+')'); qry.ExecSQL; qry.Close; end; // lAudit. if (vNowAt > 0) then begin // ONLY if table is open. qSysServiceID.Close; qSysServiceID.Open; with qSysServiceID do Locate('id',vNowAt,[]); end; // qSysServiceID is open. // Now let the User know of the Service Terminated. qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT ServiceID'); qry.SQL.Add('FROM tServiceID'); qry.SQL.Add('WHERE tServiceID.ID = '+sTempValue); qry.Open; MessageDlg('The entry in ServiceID ('+sTempValue+') '+ qry.FieldByName('ServiceID').AsString +#13#10+ 'has been Terminated - all valid splits are deleted.', mtWarning, [mbOk], 0); end; // Terminate the ServiceID too. qry.Close; end // TabServiceSplitID. else if (CurrentTabID = TabServiceTypeID) then begin vNowAt := qSysServiceType['id']; sOldDate := 'NULL'; if qSysServiceType.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tServiceType'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tServiceType'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tServiceType'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysServiceType.Close; qSysServiceType.Open; with qSysServiceType do Locate('id',vNowAt,[]); end // TabServiceTypeID. else if (CurrentTabID = TabSubledgerID) then begin vNowAt := qSysSubledger['id']; sOldDate := 'NULL'; if qSysSubledger.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tSubledger'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tSubledger'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tSubledger'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysSubledger.Close; qSysSubledger.Open; with qSysSubledger do Locate('id',vNowAt,[]); end // TabSubledgerID. else if (CurrentTabID = TabSupplierID) then begin vNowAt := qSysSupplier['id']; sOldDate := 'NULL'; if qSysSupplier.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tSupplier'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tSupplier'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tSupplier'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysSupplier.Close; qSysSupplier.Open; with qSysSupplier do Locate('id',vNowAt,[]); end // TabSupplierID. else if (CurrentTabID = TabSupplierServiceCodeID) then begin vNowAt := qSysSupplierServiceCode['id']; if qSysSupplierServiceCode.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tSupplierServiceCode'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tSupplierServiceCode'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysSupplierServiceCode.Close; qSysSupplierServiceCode.Open; with qSysSupplierServiceCode do Locate('id',vNowAt,[]); end // TabSupplierServiceCodeID. else if (CurrentTabID = TabSystemID) then begin vNowAt := qSysSystem['id']; sNewDate := sTodayNow; if qSysSystem.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tSystem'); qry.SQL.Add('SET Active = '+sNewValue); // qry.SQL.Add('SET Active = '+sNewValue+','); // qry.SQL.Add('DateLastChanged = '+sNewDate+','); // qry.SQL.Add('UserID = '+IntToStr(OPERATORNUMBER)); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tSystem'',''Active'','''+sOldDate+ ''','''+sNewDate+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysSystem.Close; qSysSystem.Open; with qSysSystem do Locate('id',vNowAt,[]); end // TabSystemID. else if (CurrentTabID = TabTransactionTypeID) then begin vNowAt := qSysTransactionType['id']; sOldDate := 'NULL'; if qSysTransactionType.FieldByName('Active').AsBoolean then begin sNewValue := '0'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sNewDate := 'NULL'; AuditAction := AuditActionUpdate; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tTransactionType'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tTransactionType'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tTransactionType'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysTransactionType.Close; qSysTransactionType.Open; with qSysTransactionType do Locate('id',vNowAt,[]); end // TabTransactionTypeID. else if (CurrentTabID = TabTransactionGroupID) then begin // Not available as the "Active" field is not in the table. *************** end // TabTransactionGroupID. else if (CurrentTabID = TabUserID) then begin vNowAt := qSysUser['id']; if qSysUser.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tUser'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tUser'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysUser.Close; qSysUser.Open; with qSysUser do Locate('id',vNowAt,[]); if qSysUserFunction.Active then begin vNowAt := qSysUserFunction['UserID']; qSysUserFunction.Close; qSysUserFunction.Open; with qSysUserFunction do Locate('UserID',vNowAt,[]); end; end // TabUserID. else if (CurrentTabID = TabUserFunctionID) then begin vNowAt := qSysUserFunction['UserID']; if qSysUserFunction.FieldByName('Active').AsBoolean then begin sNewValue := '0'; sOldValue := '1'; AuditAction := AuditActionDelete; end else begin sNewValue := '1'; sOldValue := '0'; AuditAction := AuditActionUpdate; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tUser'); qry.SQL.Add('SET Active = '+sNewValue); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tUser'',''Active'','''+sOldValue+ ''','''+sNewValue+''','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysUserFunction.Close; qSysUserFunction.Open; with qSysUserFunction do Locate('UserID',vNowAt,[]); if qSysUser.Active then begin vNowAt := qSysUser['id']; qSysUser.Close; qSysUser.Open; with qSysUser do Locate('id',vNowAt,[]); end; end // TabUserFunctionID. else if (CurrentTabID = TabValidAccountID) then begin vNowAt := qSysValidAccount['id']; sOldDate := 'NULL'; if qSysValidAccount.FieldByName('Active').AsBoolean then begin sNewValue := '0'; end else begin sNewValue := '1'; sNewDate := 'NULL'; if lAudit then begin qry.Close; qry.SQL.Clear; qry.SQL.Add('SELECT EndDate'); qry.SQL.Add('FROM tValidAccountNumber'); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.Open; sOldDate := StandardDateString(qry.FieldByName('EndDate').AsDateTime); qry.Close; end; end; qry.Close; qry.SQL.Clear; qry.SQL.Add('UPDATE tValidAccountNumber'); qry.SQL.Add('SET Active = '+sNewValue+','); qry.SQL.Add('EndDate = '+sNewDate); qry.SQL.Add('WHERE ID ='+IntToStr(vNowAt)); qry.ExecSQL; qry.Close; if lAudit then begin qry.SQL.Clear; qry.SQL.Add('INSERT INTO tAuditTrail'); qry.SQL.Add('(UserID,ActionTime,Action,TableName,FieldName,Oldvalue,'+ 'NewValue,TableID)'); qry.SQL.Add('VALUES ('''+OPERATORNAME+''','''+sTodayNow+ ''','+ AuditAction +',''tValidAccountNumber'',''EndDate'','''+sOldDate+ ''','+sNewDate+','+IntToStr(vNowAt)+')'); qry.ExecSQL; qry.Close; end; // lAudit. qSysValidAccount.Close; qSysValidAccount.Open; with qSysValidAccount do Locate('id',vNowAt,[]); end; // TabValidAccountID. Application.ProcessMessages; end; // DeleteRecord. procedure TMainForm.EditRecord(const TabPageID: integer;const AppendRecord: boolean); var TabSheet : TTabSheet; CurrentTabID : integer; lAppend : boolean; lLoadCurrentRecord : boolean; SysEditForm : TSysEditForm; SysEditServTypeForm : TSysEditServTypeForm; SysEditServiceIDForm : TSysEditServiceIDForm; SysEditServiceSplitForm : TSplitForm; SysEditBatchTypeForm : TSysEditBatchTypeForm; SysEditAgreementForm : TSysEditAgreementForm; slNew : TStringList; vNowAt : variant; nStarted : integer; sFunctionState : string; sValue : string; begin CurrentTabID := TabPageID; lAppend := AppendRecord; slNew := TStringList.Create; if (CurrentTabID = TabActivityID) then begin if not (qSysActivity.Bof and qSysActivity.Eof) or lAppend then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_ACTIVITY; vNowAt := qSysActivity.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit2 := qSysActivity.FieldByName('Description').AsString; SysEditForm.Edit3 := qSysActivity.FieldByName('CustomerID').AsString; SysEditForm.Edit4 := qSysActivity.FieldByName('ShipTo').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin SysEditForm.Edit1 := IntToStr(vNowAt); if not VarIsNull(qSysActivity['StartDate']) then begin SysEditForm.Edit7 := qSysActivity['StartDate']; end; if not VarIsNull(qSysActivity['EndDate']) then begin SysEditForm.Edit8 := qSysActivity['EndDate']; end; end; // lAppend; end else begin SysEditForm.Edit7 := Date; // Appending a New entry. end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysActivity.Close; qSysActivity.Open; with qSysActivity do Locate('id',vNowAt,[]); end; end; // not empty. end // TabActivityID. else if (CurrentTabID = TabAgreementID) then begin if not (qSysAgreement.Bof and qSysAgreement.Eof) or lAppend then begin SysEditAgreementForm := TSysEditAgreementForm.Create(SELF); vNowAt := qSysAgreement.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditAgreementForm do begin AgreementNo := qSysAgreement.FieldByName('AgreementNo').AsString; Description := qSysAgreement.FieldByName('Description').AsString; AgreementTypeID := qSysAgreement.FieldByName('AT_ID').AsInteger; SupplierID := qSysAgreement.FieldByName('SupplierID').AsInteger; BatchTypeID := qSysAgreement.FieldByName('BT_ID').AsInteger; ValidAccountNumberID := qSysAgreement.FieldByName('VAN_ID').AsInteger; if lAppend then begin StartDate := Date; end else begin ID := vNowAt; if not VarIsNull(qSysAgreement['StartDate']) then begin StartDate := qSysAgreement['StartDate']; end; if not VarIsNull(qSysAgreement['EndDate']) then begin EndDate := qSysAgreement['EndDate']; end; end; // lAppend; end; // SysAgreementEditForm. end else begin SysEditAgreementForm.StartDate := Date; end; // if not lAppend or.. SysEditAgreementForm.AppendMode := lAppend; if (SysEditAgreementForm.ShowModal = mrOk) then begin qSysAgreement.Close; qSysAgreement.Open; with qSysAgreement do Locate('id',vNowAt,[]); end; end; // not empty. end // TabAgreementID. else if (CurrentTabID = TabAgreementTariffsID) then begin if not (qSysAgreementTariffs.Bof and qSysAgreementTariffs.Eof) or lAppend then begin SysEditTariffForm := TSysEditTariffForm.Create(SELF); vNowAt := qSysAgreementTariffs.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with qSysAgreementTariffs do begin SysEditTariffForm.AgreementID := FieldByName('ID').AsInteger; SysEditTariffForm.SupplierServiceCodeID := FieldByName('SupplierServiceCodeID').AsInteger; if not VarIsNull(FieldByName('FixedCharge').AsVariant) then SysEditTariffForm.FixedCharge := FieldByName('FixedCharge').AsCurrency; if not VarIsNull(FieldByName('FlagFall').AsVariant) then SysEditTariffForm.FlagFall := FieldByName('FlagFall').AsCurrency; if not VarIsNull(FieldByName('ChargeIntervalSecs').AsVariant) then SysEditTariffForm.ChargeIntervalSecs := FieldByName('ChargeIntervalSecs').AsInteger; if not VarIsNull(FieldByName('MinDuration').AsVariant) then SysEditTariffForm.MinDuration := FieldByName('MinDuration').AsInteger; if not VarIsNull(FieldByName('MinCharge').AsVariant) then SysEditTariffForm.MinCharge := FieldByName('MinCharge').AsCurrency; if not VarIsNull(FieldByName('MaxDuration').AsVariant) then SysEditTariffForm.MaxDuration := FieldByName('MaxDuration').AsInteger; if not VarIsNull(FieldByName('MaxCharge').AsVariant) then SysEditTariffForm.MaxCharge := FieldByName('MaxCharge').AsCurrency; if not VarIsNull(FieldByName('Stage1Duration').AsVariant) then SysEditTariffForm.Stage1Duration := FieldByName('Stage1Duration').AsInteger; if not VarIsNull(FieldByName('Stage1Charge').AsVariant) then SysEditTariffForm.Stage1Charge := FieldByName('Stage1Charge').AsCurrency; if not VarIsNull(FieldByName('Stage2Duration').AsVariant) then SysEditTariffForm.Stage2Duration := FieldByName('Stage2Duration').AsInteger; if not VarIsNull(FieldByName('Stage2Charge').AsVariant) then SysEditTariffForm.Stage2Charge := FieldByName('Stage2Charge').AsCurrency; if not VarIsNull(FieldByName('Stage3Duration').AsVariant) then SysEditTariffForm.Stage3Duration := FieldByName('Stage3Duration').AsInteger; if not VarIsNull(FieldByName('Stage3Charge').AsVariant) then SysEditTariffForm.Stage3Charge := FieldByName('Stage3Charge').AsCurrency; if not VarIsNull(FieldByName('Stage4Duration').AsVariant) then SysEditTariffForm.Stage4Duration := FieldByName('Stage4Duration').AsInteger; if not VarIsNull(FieldByName('Stage4Charge').AsVariant) then SysEditTariffForm.Stage4Charge := FieldByName('Stage4Charge').AsCurrency; if not VarIsNull(FieldByName('Stage5Duration').AsVariant) then SysEditTariffForm.Stage5Duration := FieldByName('Stage5Duration').AsInteger; if not VarIsNull(FieldByName('Stage5Charge').AsVariant) then SysEditTariffForm.Stage5Charge := FieldByName('Stage5Charge').AsCurrency; if not VarIsNull(FieldByName('SurchargeRate').AsVariant) then SysEditTariffForm.Surcharge := FieldByName('SurchargeRate').AsCurrency; if not VarIsNull(FieldByName('DiscountRate').AsVariant) then SysEditTariffForm.Discount := FieldByName('DiscountRate').AsCurrency; SysEditTariffForm.CheckSurcharge := FieldByName('Surcharge').AsBoolean; SysEditTariffForm.CheckDiscount := FieldByName('Discount').AsBoolean; SysEditTariffForm.CheckChargePeriod := FieldByName('ChargePeriod').AsBoolean; end; // with qSysAgreementTariffs. if not lAppend then begin SysEditTariffForm.ID := vNowAt; end; // lAppend; end; // if not lAppend or.. SysEditTariffForm.AppendMode := lAppend; if (SysEditTariffForm.ShowModal = mrOk) then begin qSysAgreementTariffs.Close; qSysAgreementTariffs.Open; with qSysAgreementTariffs do Locate('id',vNowAt,[]); end; end; // not empty. end // TabAgreementTariffsID. else if (CurrentTabID = TabAgreementTypeID) then begin if not (qSysAgreementType.Bof and qSysAgreementType.Eof) or lAppend then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_AGREEMENTTYPE; vNowAt := qSysAgreementType.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysAgreementType.FieldByName('Description').AsString; end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysAgreementType.Close; qSysAgreementType.Open; with qSysAgreementType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabAgreementTypeID. else if (CurrentTabID = TabApplicationID) then begin if not (qSysApplication.Bof and qSysApplication.Eof) or lAppend then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_APPLICATION; vNowAt := qSysApplication.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditForm do begin Edit2 := qSysApplication.FieldByName('Description').AsString; if not lAppend then Edit1 := IntToStr(vNowAt); end; end; SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysApplication.Close; qSysApplication.Open; with qSysApplication do Locate('id',vNowAt,[]); end; end; // not empty. end // TabApplicationID. else if (CurrentTabID = TabBatchID) then begin { if not (qSysBatch.Bof and qSysBatch.Eof) then begin // not empty. if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin end; // not lAppend or.. end; // not empty. } end // TabBatchID. else if (CurrentTabID = TabBatchHistoryID) then begin { if not (qSysBatchHistory.Bof and qSysBatchHistory.Eof) then begin // not empty. if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin end; // not lAppend or.. end; // not empty. } end // TabBatchHistoryID. else if (CurrentTabID = TabBatchTypeID) then begin if not (qSysBatchType.Bof and qSysBatchType.Eof) or lAppend then begin SysEditBatchTypeForm := TSysEditBatchTypeForm.Create(SELF); vNowAt := qSysBatchType.FieldByName('id').AsInteger; if not lAppend then SysEditBatchTypeForm.BatchTypeID := IntToStr(vNowAt); if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditBatchTypeForm do begin Description := qSysBatchType.FieldByName('Description').AsString; SupplierDisplayedName := qSysBatchType.FieldByName('SupplierDisplayedName').AsString; if not VarIsNull(qSysBatchType['SupplierID']) then SupplierID := qSysBatchType.FieldByName('SupplierID').AsInteger; if not VarIsNull(qSysBatchType['ProgramID']) then ProgramID := qSysBatchType.FieldByName('ProgramID').AsInteger; if not VarIsNull(qSysBatchType['ReportGroupID']) then ReportGroupID := qSysBatchType.FieldByName('ReportGroupID').AsInteger; if not VarIsNull(qSysBatchType['DataSourceTypeID']) then DataSourceTypeID := qSysBatchType.FieldByName('DataSourceTypeID').AsInteger; if qSysBatchType.FieldByName('AccountNo').AsBoolean then begin AccountNo := True; AccountNoName := qSysBatchType.FieldByName('AccountNoName').AsString end; // AccountNo. if qSysBatchType.FieldByName('InvoiceNo').AsBoolean then begin InvoiceNo := True; InvoiceNoName := qSysBatchType.FieldByName('InvoiceNoName').AsString end; // InvoiceNo. if qSysBatchType.FieldByName('TotalRevenue').AsBoolean then begin TotalRevenue := True; TotalRevenueName := qSysBatchType.FieldByName('TotalRevenueName').AsString end; // TotalRevenue. if qSysBatchType.FieldByName('TotalPayable').AsBoolean then begin TotalPayable := True; TotalPayableName := qSysBatchType.FieldByName('TotalPayableName').AsString end; // TotalPayable. if qSysBatchType.FieldByName('TotalCredits').AsBoolean then begin TotalCredits := True; TotalCreditsName := qSysBatchType.FieldByName('TotalCreditsName').AsString end; // TotalCredits. if qSysBatchType.FieldByName('OpeningBalance').AsBoolean then begin OpeningBalance := True; OpeningBalanceName := qSysBatchType.FieldByName('OpeningBalanceName').AsString end; // OpeningBalance. if qSysBatchType.FieldByName('PaymentsReceived').AsBoolean then begin PaymentsReceived := True; PaymentsReceivedName := qSysBatchType.FieldByName('PaymentsReceivedName').AsString end; // PaymentsReceived. if qSysBatchType.FieldByName('TotalAdjustments').AsBoolean then begin TotalAdjustments := True; TotalAdjustmentsName := qSysBatchType.FieldByName('TotalAdjustmentsName').AsString end; // TotalAdjustments. if qSysBatchType.FieldByName('BatchStart').AsBoolean then begin BatchStart := True; BatchStartName := qSysBatchType.FieldByName('BatchStartName').AsString end; // BatchStart. if qSysBatchType.FieldByName('BatchEnd').AsBoolean then begin BatchEnd := True; BatchEndName := qSysBatchType.FieldByName('BatchEndName').AsString end; // BatchEnd. if qSysBatchType.FieldByName('PaymentDate').AsBoolean then begin PaymentDate := True; PaymentDateName := qSysBatchType.FieldByName('PaymentDateName').AsString end; // PaymentDate. if qSysBatchType.FieldByName('CreditsToCustomers').AsBoolean then begin CreditsToCustomers := True; CreditsToCustomersName := qSysBatchType.FieldByName('CreditsToCustomers').AsString end; // CreditsToCustomers. if qSysBatchType.FieldByName('GST').AsBoolean then begin GST := True; GSTName := qSysBatchType.FieldByName('GSTName').AsString end; // GST. if qSysBatchType.FieldByName('GSTAdjustment').AsBoolean then begin GSTAdjustment := True; GSTAdjustmentName := qSysBatchType.FieldByName('GSTAdjustmentName').AsString end; // GSTAdjustment. if qSysBatchType.FieldByName('OrderNumber').AsBoolean then begin OrderNumber := True; OrderNumberName := qSysBatchType.FieldByName('OrderNumberName').AsString end; // OrderNumber. if qSysBatchType.FieldByName('RequisitionNumber').AsBoolean then begin RequisitionNumber := True; RequisitionNumberName := qSysBatchType.FieldByName('RequisitionNumberName').AsString end; // RequisitionNumber. if qSysBatchType.FieldByName('IssueDate').AsBoolean then begin IssueDate := True; IssueDateName := qSysBatchType.FieldByName('IssueDateName').AsString end; // IssueDate. RentDates := qSysBatchType.FieldByName('RentDates').AsBoolean; CallDates := qSysBatchType.FieldByName('CallDates').AsBoolean; if qSysBatchType.FieldByName('Rounding').AsBoolean then begin Rounding := True; RoundingName := qSysBatchType.FieldByName('RoundingName').AsString end; // Rounding. TenderNumber := qSysBatchType.FieldByName('TenderNumber').AsBoolean; MultiManual := qSysBatchType.FieldByName('MultiManualEntry').AsBoolean; EarlyRevenue := qSysBatchType.FieldByName('EarlyRevenue').AsBoolean; Var01 := Trim(qSysBatchType.FieldByName('Var01Description').AsString); Var02 := Trim(qSysBatchType.FieldByName('Var02Description').AsString); Var03 := Trim(qSysBatchType.FieldByName('Var03Description').AsString); Var04 := Trim(qSysBatchType.FieldByName('Var04Description').AsString); Var05 := Trim(qSysBatchType.FieldByName('Var05Description').AsString); Var06 := Trim(qSysBatchType.FieldByName('Var06Description').AsString); Var07 := Trim(qSysBatchType.FieldByName('Var07Description').AsString); Var08 := Trim(qSysBatchType.FieldByName('Var08Description').AsString); Var09 := Trim(qSysBatchType.FieldByName('Var09Description').AsString); Var10 := Trim(qSysBatchType.FieldByName('Var10Description').AsString); Var11 := Trim(qSysBatchType.FieldByName('Var11Description').AsString); Var12 := Trim(qSysBatchType.FieldByName('Var12Description').AsString); Var13 := Trim(qSysBatchType.FieldByName('Var13Description').AsString); Var14 := Trim(qSysBatchType.FieldByName('Var14Description').AsString); Var15 := Trim(qSysBatchType.FieldByName('Var15Description').AsString); sFunctionState := ''; if qSysBatchType.fieldByName('CriticalCheck01').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck02').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck03').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck04').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck05').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck06').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck07').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck08').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck09').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck10').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck11').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck12').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck13').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck14').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('CriticalCheck15').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; Critical1to15 := sFunctionState; sFunctionState := ''; if qSysBatchType.fieldByName('DubiousCheck01').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck02').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck03').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck04').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck05').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck06').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck07').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck08').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck01').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck10').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck11').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck12').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck13').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck14').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; if qSysBatchType.fieldByName('DubiousCheck15').AsBoolean then sFunctionState := sFunctionState+'1' else sFunctionState := sFunctionState+'0'; Dubious1To15 := sFunctionState; end; // with SysEditBatchTypeForm end; // not lAppend or.. SysEditBatchTypeForm.AppendMode := lAppend; if (SysEditBatchTypeForm.ShowModal = mrOk) then begin qSysBatchType.Close; qSysBatchType.Open; with qSysBatchType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabBatchType. else if (CurrentTabID = TabCentreID) then begin if not (qSysCentre.Bof and qSysCentre.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_CENTRE; vNowAt := qSysCentre.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysCentre.FieldByName('Description').AsString; SysEditForm.Edit3 := qSysCentre.FieldByName('DepartmentID').AsString; SysEditForm.Edit4 := qSysCentre.FieldByName('Department').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysCentre['StartDate']) then begin SysEditForm.Edit7 := qSysCentre['StartDate']; end; if not VarIsNull(qSysCentre['EndDate']) then begin SysEditForm.Edit8 := qSysCentre['EndDate']; end; end; // lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysCentre.Close; qSysCentre.Open; with qSysCentre do Locate('id',vNowAt,[]); end; end; // not empty. end // TabCentreID. else if (CurrentTabID = TabCriticalTypeID) then begin if not (qSysCriticalType.Bof and qSysCriticalType.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_CRITICALTYPE; vNowAt := qSysCriticalType.FieldByName('id').AsInteger; if not lAppend then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysCriticalType.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysCriticalType.Close; qSysCriticalType.Open; with qSysCriticalType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabCriticalTypeID. else if (CurrentTabID = TabCustomerID) then begin if not (qSysCustomer.Bof and qSysCustomer.Eof) then begin // not empty. vNowAt := qSysCustomer.FieldByName('id').AsInteger; SysEditCustomerForm := TSysEditCustomerForm.Create(SELF); if not lAppend then SysEditCustomerForm.CustomerID := IntToStr(vNowAt); if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditCustomerForm do begin ShipTo := qSysCustomer.FieldByName('ShipTo').AsString; FullName := qSysCustomer.FieldByName('FullName').AsString; VNumber := qSysCustomer.FieldByName('VNumber').AsString; Active := qSysCustomer.FieldByName('Active').AsBoolean; Status := qSysCustomer.FieldByName('Status').AsString; // StartDate := qSysCustomer.FieldByName('StartDate').AsDateTime; // EndDate := qSysCustomer.FieldByName('EndDate').AsDateTime; Rate := qSysCustomer.FieldByName('Rate').AsInteger; MaxExServiceAmount := qSysCustomer.FieldByName('MaxExServiceAmount').AsCurrency; PlatinumUpdate := qSysCustomer.FieldByName('PlatinumUpdate').AsBoolean; Invoice := qSysCustomer.FieldByName('Invoice').AsBoolean; InvoiceServices := qSysCustomer.FieldByName('InvoiceServices').AsBoolean; Address01 := qSysCustomer.FieldByName('Address01').AsString; Address02 := qSysCustomer.FieldByName('Address02').AsString; Address03 := qSysCustomer.FieldByName('Address03').AsString; Address04 := qSysCustomer.FieldByName('Address04').AsString; Address05 := qSysCustomer.FieldByName('Address05').AsString; Address06 := qSysCustomer.FieldByName('Address06').AsString; end; // SysEditCustomerForm. end; // not lAppend or.. SysEditCustomerForm.AppendMode := lAppend; if (SysEditCustomerForm.ShowModal = mrOk) then begin qSysCustomer.Close; qSysCustomer.Open; with qSysCustomer do Locate('id',vNowAt,[]); end; end; // not empty. end // TabCustomerID. else if (CurrentTabID = TabCostRangeID) then begin if not (qSysCostRange.Bof and qSysCostRange.Eof) or lAppend then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_COSTRANGE; vNowAt := qSysCostRange.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit3 := qSysCostRange.FieldByName('ValidAccountNumberID').AsString; SysEditForm.Edit4 := qSysCostRange.FieldByName('AccountNo').AsString; SysEditForm.Edit5 := qSysCostRange.FieldByName('TransactionTypeID').AsString; SysEditForm.Edit6 := qSysCostRange.FieldByName('TransactionType').AsString; SysEditForm.Edit9 := qSysCostRange.FieldByName('CostRangeFrom').AsString; SysEditForm.Edit10:= qSysCostRange.FieldByName('CostRangeTo').AsString; end; // not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysCostRange.Close; qSysCostRange.Open; with qSysCostRange do Locate('id',vNowAt,[]); end; end; // not empty. end // TabCostRangeID. else if (CurrentTabID = TabDepartmentID) then begin if not (qSysDepartment.Bof and qSysDepartment.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DEPARTMENT; vNowAt := qSysDepartment.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDepartment.FieldByName('Description').AsString; SysEditForm.Edit3 := qSysDepartment.FieldByName('GroupID').AsString; SysEditForm.Edit4 := qSysDepartment.FieldByName('GroupName').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysDepartment['StartDate']) then begin SysEditForm.Edit7 := qSysDepartment['StartDate']; end; if not VarIsNull(qSysDepartment['EndDate']) then begin SysEditForm.Edit8 := qSysDepartment['EndDate']; end; end; // lAppend; end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDepartment.Close; qSysDepartment.Open; with qSysDepartment do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDepartmentID. else if (CurrentTabID = TabDiscountID) then begin if not (qSysDiscount.Bof and qSysDiscount.Eof) or lAppend then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DISCOUNT; vNowAt := qSysDiscount.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDiscount.FieldByName('DiscountRate').AsString; SysEditForm.Edit3 := qSysDiscount.FieldByName('ServiceTypeID').AsString; SysEditForm.Edit4 := qSysDiscount.FieldByName('Code').AsString+ ' '+ qSysDiscount.FieldByName('ServiceType').AsString; SysEditForm.Edit5 := qSysDiscount.FieldByName('CustomerID').AsString; SysEditForm.Edit6 := qSysDiscount.FieldByName('ShipTo').AsString; SysEditForm.Edit9 := qSysDiscount.FieldByName('NonStdRevAdminFee').AsString; SysEditForm.Edit10:= qSysDiscount.FieldByName('NonStdExpAdminFee').AsString; end; // not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDiscount.Close; qSysDiscount.Open; with qSysDiscount do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDiscountID. else if (CurrentTabID = TabDiscountedRateID) then begin if not (qSysDiscountedRate.Bof and qSysDiscountedRate.Eof) or lAppend then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DISCOUNTEDRATE; vNowAt := qSysDiscountedRate.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDiscountedRate.FieldByName('Rate').AsString; SysEditForm.Edit3 := qSysDiscountedRate.FieldByName('ServiceTypeID').AsString; SysEditForm.Edit4 := qSysDiscountedRate.FieldByName('Code').AsString+ ' '+ qSysDiscountedRate.FieldByName('ServiceType').AsString; SysEditForm.Edit5 := qSysDiscountedRate.FieldByName('CustomerID').AsString; SysEditForm.Edit6 := qSysDiscountedRate.FieldByName('ShipTo').AsString; end; // not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDiscountedRate.Close; qSysDiscountedRate.Open; with qSysDiscountedRate do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDiscountedRateID. else if (CurrentTabID = TabDestinationID) then begin if not (qSysDestination.Bof and qSysDestination.Eof) or lAppend then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DESTINATION; vNowAt := qSysDestination.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDestination.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDestination.Close; qSysDestination.Open; with qSysDestination do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDestinationID. else if (CurrentTabID = TabDubiousTypeID) then begin if not (qSysDubiousType.Bof and qSysDubiousType.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DUBIOUSTYPE; vNowAt := qSysDubiousType.FieldByName('id').AsInteger; if not lAppend then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDubiousType.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDubiousType.Close; qSysDubiousType.Open; with qSysDubiousType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDubiousTypeID. else if (CurrentTabID = TabDubiousResolutionID) then begin if not (qSysDubiousResolution.Bof and qSysDubiousResolution.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DUBIOUSRESOLUTION; vNowAt := qSysDubiousResolution.FieldByName('id').AsInteger; if not lAppend then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysDubiousResolution.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDubiousResolution.Close; qSysDubiousResolution.Open; with qSysDubiousResolution do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDubiousResolutionID. else if (CurrentTabID = TabDubiousResultID) then begin { if not (qSysDubiousResult.Bof and qSysDubiousResult.Eof) then begin // not empty. SysEditSupplierForm := TSysEditSupplierForm.Create(SELF); vNowAt := qSysDubiousResult.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditSupplierForm do begin SupplierName := qSysDubiousResult.FieldByName('SupplierName').AsString; PlatinumVendorID := qSysDubiousResult.FieldByName('PlatinumVendorID').AsString; Active := qSysDubiousResult.FieldByName('Active').AsBoolean; PlatinumUpdate := qSysDubiousResult.FieldByName('PlatinumUpdate').AsBoolean; VicTrack := qSysDubiousResult.FieldByName('VicTrack').AsBoolean; Address01 := qSysDubiousResult.FieldByName('Address01').AsString; Address02 := qSysDubiousResult.FieldByName('Address02').AsString; Address03 := qSysDubiousResult.FieldByName('Address03').AsString; Address04 := qSysDubiousResult.FieldByName('Address04').AsString; Address05 := qSysDubiousResult.FieldByName('Address05').AsString; Address06 := qSysDubiousResult.FieldByName('Address06').AsString; end; // SysEditCustomerForm. end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDubiousResult.Close; qSysDubiousResult.Open; with qSysDubiousResult do Locate('id',vNowAt,[]); end; end; // not empty. } end // TabDubiousResult. else if (CurrentTabID = TabDubiousValidResolutionID) then begin if not (qSysDubiousValidResolution.Bof and qSysDubiousValidResolution.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_DUBIOUSVALIDRESN; vNowAt := qSysDubiousValidResolution.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit3 := IntToStr( qSysDubiousValidResolution.FieldByName('DubiousTypeID').AsInteger); SysEditForm.Edit4 := qSysDubiousValidResolution.FieldByName('DubiousType').AsString; SysEditForm.Edit5 := IntToStr( qSysDubiousValidResolution.FieldByName('DubiousResolutionID').AsInteger); SysEditForm.Edit6 := qSysDubiousValidResolution.FieldByName('Resolution').AsString; end; // not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysDubiousValidResolution.Close; qSysDubiousValidResolution.Open; with qSysDubiousValidResolution do Locate('id',vNowAt,[]); end; end; // not empty. end // TabDubiousValidResolutionID. else if (CurrentTabID = TabElementID) then begin if not (qSysElement.Bof and qSysElement.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_ELEMENT; vNowAt := qSysElement.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysElement.FieldByName('ServiceGroupID').AsString; SysEditForm.Edit3 := qSysElement.FieldByName('ElementCode').AsString; SysEditForm.Edit4 := qSysElement.FieldByName('Description').AsString; SysEditForm.Edit5 := qSysElement.FieldByName('CustomerID').AsString; SysEditForm.Edit6 := qSysElement.FieldByName('ShipTo').AsString; SysEditForm.Check1 := qSysElement['PlatinumUpdate']; SysEditForm.Check2 := qSysElement['LostRevenueFlag']; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysElement['StartDate']) then begin SysEditForm.Edit7 := qSysElement['StartDate']; end; if not VarIsNull(qSysElement['EndDate']) then begin SysEditForm.Edit8 := qSysElement['EndDate']; end; end; // lAppend. SysEditForm.Edit9 := qSysElement.FieldByName('ReportGroupID').AsString; end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysElement.Close; qSysElement.Open; with qSysElement do Locate('id',vNowAt,[]); end; end; // not empty. end // TabElementID. else if (CurrentTabID = TabFunctionID) then begin if not (qSysFunction.Bof and qSysFunction.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_FUNCTION; vNowAt := qSysFunction.FieldByName('id').AsInteger; if not lAppend then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysFunction.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysFunction.Close; qSysFunction.Open; with qSysFunction do Locate('id',vNowAt,[]); end; end; // not empty. end // TabFunctionID. else if (CurrentTabID = TabGroupID) then begin if not (qSysGroup.Bof and qSysGroup.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_GROUP; vNowAt := qSysGroup.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysGroup.FieldByName('Description').AsString; SysEditForm.Edit3 := qSysGroup.FieldByName('CustomerID').AsString; SysEditForm.Edit4 := qSysGroup.FieldByName('ShipTo').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysGroup['StartDate']) then begin SysEditForm.Edit7 := qSysGroup['StartDate']; end; if not VarIsNull(qSysGroup['EndDate']) then begin SysEditForm.Edit8 := qSysGroup['EndDate']; end; end; //lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysGroup.Close; qSysGroup.Open; with qSysGroup do Locate('id',vNowAt,[]); end; end; // not empty. end // TabGroupID. else if (CurrentTabID = TabLocationID) then begin if not (qSysLocation.Bof and qSysLocation.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_LOCATION; vNowAt := qSysLocation.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysLocation.FieldByName('Description').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysLocation['StartDate']) then begin SysEditForm.Edit7 := qSysLocation['StartDate']; end; if not VarIsNull(qSysLocation['EndDate']) then begin SysEditForm.Edit8 := qSysLocation['EndDate']; end; end; // lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysLocation.Close; qSysLocation.Open; with qSysLocation do Locate('id',vNowAt,[]); end; end; // not empty. end // TabLocationID. else if (CurrentTabID = TabOriginID) then begin if not (qSysOrigin.Bof and qSysOrigin.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_ORIGIN; vNowAt := qSysOrigin.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysOrigin.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysOrigin.Close; qSysOrigin.Open; with qSysOrigin do Locate('id',vNowAt,[]); end; end; // not empty. end // TabOriginID. else if (CurrentTabID = TabPersonID) then begin if not (qSysPerson.Bof and qSysPerson.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_PERSON; vNowAt := qSysPerson.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysPerson.FieldByName('person').AsString; SysEditForm.Edit3 := qSysPerson.FieldByName('EmailAddress').AsString; if lAppend then begin SysEditForm.edtEdit7.Text := DateToStr(Date); end else begin if not VarIsNull(qSysPerson['StartDate']) then SysEditForm.Edit7 := qSysPerson['StartDate']; if not VarIsNull(qSysPerson['EndDate']) then SysEditForm.Edit8 := qSysPerson['EndDate']; end; // lAppend. end else if lAppend then begin SysEditForm.Edit7 := Date; end; { else begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysPerson.FieldByName('person').AsString; if lAppend then begin SysEditForm.edtEdit7.Text := DateToStr(Date); end else begin if not VarIsNull(qSysPerson['StartDate']) then SysEditForm.Edit7 := qSysPerson['StartDate']; if not VarIsNull(qSysPerson['EndDate']) then SysEditForm.Edit8 := qSysPerson['EndDate']; end; // lAppend. end; // if lAppend then begin..else. } SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysPerson.Close; qSysPerson.Open; with qSysPerson do Locate('id',vNowAt,[]); end; end; // not empty. end // TabPersonID. else if (CurrentTabID = TabProgramID) then begin if not (qSysProgram.Bof and qSysProgram.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_PROGRAM; vNowAt := qSysProgram.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysProgram.FieldByName('Description').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysProgram.Close; qSysProgram.Open; with qSysProgram do Locate('id',vNowAt,[]); end; end; // not empty. end // TabProgram. else if (CurrentTabID = TabRateID) then begin if not (qSysRate.Bof and qSysRate.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_RATE; vNowAt := qSysRate.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysRate.FieldByName('ServiceTypeID').AsString; SysEditForm.Edit3 := qSysRate.FieldByName('Length').AsString; SysEditForm.Edit4 := qSysRate.FieldByName('Percentage').AsString; SysEditForm.Edit5 := qSysRate.FieldByName('Cost').AsString; SysEditForm.Edit6 := qSysRate.FieldByName('Cost100').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysRate['StartDate']) then begin SysEditForm.Edit7 := qSysRate['StartDate']; end; if not VarIsNull(qSysRate['EndDate']) then begin SysEditForm.Edit8 := qSysRate['EndDate']; end; end; // lAppend. SysEditForm.Edit9 := qSysRate.FieldByName('RateDescription').AsString; SysEditForm.Edit10:= qSysRate.FieldByName('PartCost').AsString; end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysRate.Close; qSysRate.Open; with qSysRate do Locate('id',vNowAt,[]); end; end; // not empty. end // TabRateID. else if (CurrentTabID = TabRateDescriptionID) then begin if not (qSysRateDescription.Bof and qSysRateDescription.Eof) then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_RATEDESCRIPTION; vNowAt := qSysRateDescription.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysRateDescription.FieldByName('Description').AsString; end; // if not lAppend. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysRateDescription.Close; qSysRateDescription.Open; with qSysRateDescription do Locate('id',vNowAt,[]); end; end; // not empty. end // TabRateDescriptionID. else if (CurrentTabID = TabServiceIDID) then begin if not (qSysServiceID.Bof and qSysServiceID.Eof) then begin // not empty. SysEditServiceIDForm := TSysEditServiceIDForm.Create(SELF); vNowAt := qSysServiceID.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditServiceIDForm do begin if lAppend then begin SysEditServiceIDForm.edtInstallationDate.Date := Date; end else begin ID := vNowAt; if not VarIsNull(qSysServiceID['InstallationDate']) then InstallationDate := qSysServiceID['InstallationDate']; end; Description := qSysServiceID.FieldByName('Description').AsString; SACCNumber := qSysServiceID.FieldByName('SACCNumber').AsString; ServiceID := qSysServiceID.FieldByName('ServiceID').AsString; ServiceName := qSysServiceID.FieldByName('Service').AsString; if not VarIsNull(qSysServiceID['ServiceTypeID']) then ServiceTypeID := qSysServiceID.FieldByName('ServiceTypeID').AsInteger; ServiceTypeName := qSysServiceID.FieldByName('ServiceType').AsString; if not VarIsNull(qSysServiceID['PayType']) then PayType := qSysServiceID.FieldByName('PayType').AsString; if not VarIsNull(qSysServiceID['ApplicationID']) then ApplicationID :=qSysServiceID.FieldByName('ApplicationID').AsInteger; if not VarIsNull(qSysServiceID['vServiceCode']) and (Length(qSysServiceID['vServiceCode']) > 0) then ServiceCode := Copy(qSysServiceID.FieldByName('vServiceCode').AsString, 2, Length(qSysServiceID.FieldByName('vServiceCode').AsString)-2); if not VarIsNull(qSysServiceID['CentreID']) then CentreID := qSysServiceID.FieldByName('CentreID').AsInteger; CentreName := qSysServiceID.FieldByName('Centre').AsString; if not VarIsNull(qSysServiceID['ActivityID']) then ActivityID := qSysServiceID.FieldByName('ActivityID').AsInteger; ActivityName := qSysServiceID.FieldByName('Activity').AsString; if not VarIsNull(qSysServiceID['ExpenseElementID']) then ElementID := qSysServiceID.FieldByName('ExpenseElementID').AsInteger; ElementName := qSysServiceID.FieldByName('Element').AsString; if not VarIsNull(qSysServiceID['SubledgerID']) then SubledgerID := qSysServiceID.FieldByName('SubledgerID').AsInteger; SubledgerName := qSysServiceID.FieldByName('Subledger').AsString; if not VarIsNull(qSysServiceID['LocationID']) then LocationID := qSysServiceID.FieldByName('LocationID').AsInteger; LocationName := qSysServiceID.FieldByName('Location').AsString; if not VarIsNull(qSysServiceID['PersonID']) then PersonID := qSysServiceID.FieldByName('PersonID').AsInteger; PersonName := qSysServiceID.FieldByName('Person').AsString; if not VarIsNull(qSysServiceID['SupplierAccountID']) then SupplierAccountID := qSysServiceID.FieldByName('SupplierAccountID').AsInteger; SupplierAccountName := qSysServiceID.FieldByName('AccountNo').AsString; if not VarIsNull(qSysServiceID['CustomerCentreID']) then CustomerCentreID := qSysServiceID.FieldByName('CustomerCentreID').AsInteger; CustomerCentreName := qSysServiceID.FieldByName('CustomerCentre').AsString; if not VarIsNull(qSysServiceID['CustomerActivityID']) then CustomerActivityID := qSysServiceID.FieldByName('CustomerActivityID').AsInteger; CustomerActivityName := qSysServiceID.FieldByName('CustomerActivity').AsString; if not VarIsNull(qSysServiceID['CustomerElementID']) then CustomerElementID := qSysServiceID.FieldByName('CustomerElementID').AsInteger; CustomerElementName := qSysServiceID.FieldByName('CustomerElement').AsString; if not VarIsNull(qSysServiceID['CustomerSubledgerID']) then CustomerSubledgerID := qSysServiceID.FieldByName('CustomerSubledgerID').AsInteger; CustomerSubledgerName := qSysServiceID.FieldByName('CustomerSubledger').AsString; if not VarIsNull(qSysServiceID['CurrentRent']) then CurrentRent := qSysServiceID.FieldByName('CurrentRent').AsCurrency; if not VarIsNull(qSysServiceID['CurrentCalls']) then CurrentCalls := qSysServiceID.FieldByName('CurrentCalls').AsCurrency; if not VarIsNull(qSysServiceID['PreviousRent']) then PreviousRent := qSysServiceID.FieldByName('PreviousRent').AsCurrency; if not VarIsNull(qSysServiceID['PreviousCalls']) then PreviousCalls := qSysServiceID.FieldByName('PreviousCalls').AsCurrency; Jobno := qSysServiceID.FieldByName('Jobno').AsString; UpMDF := qSysServiceID.FieldByName('UpMDF').AsString; UpEnd := qSysServiceID.FieldByName('UpEnd').AsString; DownMDF := qSysServiceID.FieldByName('DownMDF').AsString; DownEnd := qSysServiceID.FieldByName('DownEnd').AsString; LineLength := qSysServiceID.FieldByName('Length').AsString; if not VarIsNull(qSysServiceID['Cost']) then Cost := qSysServiceID.FieldByName('Cost').AsCurrency; if not VarIsNull(qSysServiceID['Cost100']) then Cost100 := qSysServiceID.FieldByName('Cost100').AsCurrency; if not VarIsNull(qSysServiceID['Invoiced']) then Invoiced := qSysServiceID.FieldByName('Invoiced').AsCurrency; ServiceKpiID := qSysServiceID.FieldByName('ServiceKpiID').AsInteger; MnemonicID := qSysServiceID.FieldByName('ServiceMnemonicID').AsInteger; if not VarIsNull(qSysServiceID['TerminationDate']) then TerminationDate := qSysServiceID.FieldByName('TerminationDate').AsDateTime; No := qSysServiceID.FieldByName('No').AsString; Part := qSysServiceID.FieldByName('Part').AsString; Drawing := qSysServiceID.FieldByName('Drawing').AsString; // Commented out for now. nvarchar types requiring extra attention in saving too. // ServiceLink := qSysServiceID.FieldByName('ServiceLink').AsString; // MuxLink := qSysServiceID.FieldByName('MuxLink').AsString; AuthorityID := qSysServiceID.FieldByName('AuthorityID').AsInteger; ModemTypeID := qSysServiceID.FieldByName('ModemTypeID').AsInteger; BearerID := qSysServiceID.FieldByName('BearerID').AsInteger; SpeedID := qSysServiceID.FieldByName('SpeedID').AsInteger; Make := qSysServiceID.FieldByName('Make').AsString; Ch := qSysServiceID.FieldByName('Ch').AsString; Mux := qSysServiceID.FieldByName('Mux').AsString; end; // with SysServiceIDEditForm do begin. end else begin SysEditServiceIDForm.edtInstallationDate.Date := Date; end; // if not lAppend or.. SysEditServiceIDForm.AppendMode := lAppend; // Always refresh as the User can save within the subform. SysEditServiceIDForm.ShowModal; qSysServiceID.Close; qSysServiceID.Open; with qSysServiceID do Locate('id',vNowAt,[]); end; // not empty. end // TabServiceIDID. else if (CurrentTabID = TabServiceKpiID) then begin // 100314 RJC. if lAppend or not (qSysServiceKpi.Bof and qSysServiceKpi.Eof) then begin // not empty. SysEditServiceKpiForm := TSysEditServiceKpiForm.Create(SELF); vNowAt := qSysServiceKpi.FieldByName('id').AsInteger; // "AppendMode" initiates a database - call it first. SysEditServiceKpiForm.AppendMode := lAppend; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditServiceKpiForm do begin ID := vNowAt; KpiNumber := qSysServiceKpi.FieldByName('KpiNumber').AsString; Description := qSysServiceKpi.FieldByName('Description').AsString; ResponseHours := qSysServiceKpi.FieldByName('ResponseHours').AsString; RestorationHours := qSysServiceKpi.FieldByName('RestorationHours').AsString; Availability := qSysServiceKpi.FieldByName('Availability').AsString; CoreHours := qSysServiceKpi.FieldByName('CoreHours').AsString; AfterHours := qSysServiceKpi.FieldByName('AfterHours').AsString; TravelTime := qSysServiceKpi.FieldByName('TravelTime').AsString; FaultDetect := qSysServiceKpi.FieldByName('FaultDetect').AsString; end; // SysEditServiceKpiForm. end; // not lAppend or.. if (SysEditServiceKpiForm.ShowModal = mrOk) then begin qSysServiceKpi.Close; qSysServiceKpi.Open; with qSysServiceKpi do Locate('id',vNowAt,[]); end; end; // not empty. end // TabServiceKpiID. else if (CurrentTabID = TabServiceMnemonicID) then begin // 111112 RJC. if lAppend or // not empty. not (qSysServiceMnemonic.Bof and qSysServiceMnemonic.Eof) then begin SysEditForm := TSysEditForm.Create(SELF); vNowAt := qSysServiceMnemonic.FieldByName('id').AsInteger; // "AppendMode" initiates a database - call it first. SysEditForm.TableNameID := TABLE_MNEMONIC; SysEditForm.AppendMode := lAppend; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditForm do begin Edit1 := qSysServiceMnemonic.FieldByName('id').AsString; Edit2 := qSysServiceMnemonic.FieldByName('ServiceCode').AsString; Edit3 := qSysServiceMnemonic.FieldByName('Description').AsString; Edit4 := qSysServiceMnemonic.FieldByName('Prefix').AsString; Edit5 := qSysServiceMnemonic.FieldByName('Pass').AsString; end; // SysEditServiceMnemonicForm. end; // not lAppend or.. if (SysEditForm.ShowModal = mrOk) then begin qSysServiceMnemonic.Close; qSysServiceMnemonic.Open; with qSysServiceMnemonic do Locate('id',vNowAt,[]); end; end; // not empty. end // TabServiceMnmonicID. else if (CurrentTabID = TabServiceSplitID) then begin if lAppend or not (qSysServiceSplit.Bof and qSysServiceSplit.Eof) then begin // not empty. SysEditServiceSplitForm := TSplitForm.Create(SELF); vNowAt := qSysServiceSplit.FieldByName('id').AsInteger; // "AppendMode" initiates a database - call it first. SysEditServiceSplitForm.AppendMode := lAppend; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditServiceSplitForm do begin ServiceID := qSysServiceSplit.FieldByName('ServiceID').AsInteger; end; // SysEditServiceSplitForm. end; // not lAppend or.. SysEditServiceSplitForm.AppendMode := lAppend; if (SysEditServiceSplitForm.ShowModal = mrOk) then begin qSysServiceSplit.Close; qSysServiceSplit.Open; with qSysServiceSplit do Locate('id',vNowAt,[]); end; end; // not empty. end // TabServiceSplitID. else if (CurrentTabID = TabServiceTypeID) then begin if not (qSysServiceType.Bof and qSysServiceType.Eof) then begin // not empty. SysEditServTypeForm := TSysEditServTypeForm.Create(SELF); vNowAt := qSysServiceType.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditServTypeForm do begin if lAppend then begin StartDate := Date; end else begin ID := vNowAt; if not VarIsNull(qSysServiceType['StartDate']) then begin StartDate := qSysServiceType.FieldByName('StartDate').AsDateTime; end; end; // if lAppend then begin..else. Code := qSysServiceType.FieldByName('Code').AsString; Description := qSysServiceType.FieldByName('Description').AsString; SupplierID := qSysServiceType.FieldByName('SupplierID').AsInteger; SupplierName := qSysServiceType.FieldByName('SupplierName').AsString; RevenueElementID := qSysServiceType.FieldByName('RevenueElementID').AsInteger; ExpenseElementID := qSysServiceType.FieldByName('ExpenseElementID').AsInteger; SystemID := qSysServiceType.FieldByName('SystemID').AsInteger; SystemName := qSysServiceType.FieldByName('System').AsString; if not VarIsNull(qSysServiceType['EndDate']) then begin EndDate := qSysServiceType.FieldByName('EndDate').AsDateTime; end; if not VarIsNull(qSysServiceType['ExpectedRent']) then begin ExpectedRent := qSysServiceType['ExpectedRent']; end; if VarIsNull(qSysServiceType['AdminFee']) then AdminFee := False else AdminFee := qSysServiceType.FieldByName('AdminFee').AsBoolean; if VarIsNull(qSysServiceType['ExportToTims']) then ExportToTims := False else ExportToTims := qSysServiceType.FieldByName('ExportToTims').AsBoolean; if VarIsNull(qSysServiceType['SplitService']) then SplitService := False else SplitService := qSysServiceType.FieldByName('SplitService').AsBoolean; if VarIsNull(qSysServiceType['VRTServiceType']) then VRTServiceType := False else VRTServiceType := qSysServiceType.FieldByName('VRTServiceType').AsBoolean; if VarIsNull(qSysServiceType['NoCalls']) then NoCalls := False else NoCalls := qSysServiceType.FieldByName('NoCalls').AsBoolean; if not VarIsNull(qSysServiceType['Frequency']) then begin Frequency := qSysServiceType.FieldByName('Frequency').AsInteger; end; end; // with SysEditServTypeForm do begin. end else begin SysEditServTypeForm.StartDate := Date; end; // if not lAppend or.. SysEditServTypeForm.AppendMode := lAppend; if (SysEditServTypeForm.ShowModal = mrOk) then begin qSysServiceType.Close; qSysServiceType.Open; with qSysServiceType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabServiceTypeID. else if (CurrentTabID = TabStatusID) then begin { if not (qSysStatus.Bof and qSysStatus.Eof) then begin // not empty. if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin end; // not lAppend or.. end; // not empty. } end // TabStatusID. else if (CurrentTabID = TabSubledgerID) then begin if not (qSysSubledger.Bof and qSysSubledger.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_SUBLEDGER; vNowAt := qSysSubledger.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysSubledger.FieldByName('Description').AsString; SysEditForm.Edit3 := qSysSubledger.FieldByName('CustomerID').AsString; SysEditForm.Edit4 := qSysSubledger.FieldByName('ShipTo').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysSubledger['StartDate']) then begin SysEditForm.Edit7 := qSysSubledger['StartDate']; end; if not VarIsNull(qSysSubledger['EndDate']) then begin SysEditForm.Edit8 := qSysSubledger['EndDate']; end; end; // lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysSubledger.Close; qSysSubledger.Open; with qSysSubledger do Locate('id',vNowAt,[]); end; end; // not empty. end // TabSubledgerID. else if (CurrentTabID = TabSupplierID) then begin if not (qSysSupplier.Bof and qSysSupplier.Eof) then begin // not empty. SysEditSupplierForm := TSysEditSupplierForm.Create(SELF); vNowAt := qSysSupplier.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin with SysEditSupplierForm do begin if not lAppend then SupplierID := IntToStr(vNowAt); SupplierName := qSysSupplier.FieldByName('SupplierName').AsString; PlatinumVendorID := qSysSupplier.FieldByName('PlatinumVendorID').AsString; Active := qSysSupplier.FieldByName('Active').AsBoolean; PlatinumUpdate := qSysSupplier.FieldByName('PlatinumUpdate').AsBoolean; VicTrack := qSysSupplier.FieldByName('VicTrack').AsBoolean; Address01 := qSysSupplier.FieldByName('Address01').AsString; Address02 := qSysSupplier.FieldByName('Address02').AsString; Address03 := qSysSupplier.FieldByName('Address03').AsString; Address04 := qSysSupplier.FieldByName('Address04').AsString; Address05 := qSysSupplier.FieldByName('Address05').AsString; Address06 := qSysSupplier.FieldByName('Address06').AsString; end; // SysEditSupplierForm. end; // if not lAppend or.. SysEditSupplierForm.AppendMode := lAppend; if (SysEditSupplierForm.ShowModal = mrOk) then begin qSysSupplier.Close; qSysSupplier.Open; with qSysSupplier do Locate('id',vNowAt,[]); end; end; // not empty. end // TabSupplierID. else if (CurrentTabID = TabSupplierServiceCodeID) then begin { if not (qSysSupplierServiceCode.Bof and qSysSupplierServiceCode.Eof) then begin // not empty. if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin end; // not lAppend or.. end; // not empty. } end // TabSupplierServiceCodeID. else if (CurrentTabID = TabSystemID) then begin if not (qSysSystem.Bof and qSysSystem.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_SYSTEM; vNowAt := qSysSystem.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysSystem.FieldByName('System').AsString; SysEditForm.Edit3 := qSysSystem.FieldByName('BatchTypeID').AsString; SysEditForm.Edit4 := qSysSystem.FieldByName('BatchType').AsString; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysSystem.Close; qSysSystem.Open; with qSysSystem do Locate('id',vNowAt,[]); end; end; // not empty. end // TabSystemID. else if (CurrentTabID = TabTransactionGroupID) then begin if not (qSysTransactionGroup.Bof and qSysTransactionGroup.Eof) then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_TRANSACTIONGROUP; vNowAt := qSysTransactionGroup.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysTransactionGroup.FieldByName('Description').AsString; if not VarIsNull(qSysTransactionGroup['CostRangeFrom']) then begin SysEditForm.Edit3 := CurrToStr( qSysTransactionGroup['CostRangeFrom']); end; if not VarIsNull(qSysTransactionGroup['CostRangeTo']) then begin SysEditForm.Edit4 := CurrToStr(qSysTransactionGroup['CostRangeTo']); end; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysTransactionGroup.Close; qSysTransactionGroup.Open; with qSysTransactionGroup do Locate('id',vNowAt,[]); end; end; // not empty. end // TabTransactionGroupID. else if (CurrentTabID = TabTransactionTypeID) then begin // Ensure it isn't empty: if not (qSysTransactionType.Bof and qSysTransactionType.Eof) then begin SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_TRANSACTIONTYPE; vNowAt := qSysTransactionType.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysTransactionType.FieldByName('Description').AsString; if not VarIsNull(qSysTransactionType['TransactionGroupID']) then begin SysEditForm.Edit3 := IntToStr( qSysTransactionType['TransactionGroupID']); SysEditForm.Edit4 := qSysTransactionType.FieldByName('TransactionGroup').AsString; end; if not VarIsNull(qSysTransactionType['SystemID']) then begin SysEditForm.Edit5 := IntToStr(qSysTransactionType['SystemID']); SysEditForm.Edit6 := qSysTransactionType.FieldByName('System').AsString; end; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysTransactionType['StartDate']) then begin SysEditForm.Edit7 := qSysTransactionType['StartDate']; end; if not VarIsNull(qSysTransactionType['EndDate']) then begin SysEditForm.Edit8 := qSysTransactionType['EndDate']; end; end; // lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysTransactionType.Close; qSysTransactionType.Open; with qSysTransactionType do Locate('id',vNowAt,[]); end; end; // not empty. end // TabTransactionTypeID. else if (CurrentTabID = TabUserFunctionID) then begin if not (qSysUserFunction.Bof and qSysUserFunction.Eof) then begin // not empty. SysEditUserFunctionForm := TSysEditUserFunctionForm.Create(SELF); vNowAt := qSysUserFunction.FieldByName('UserID').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditUserFunctionForm.UserID := vNowAt; SysEditUserFunctionForm.UserLogin := qSysUserFunction['UserLogin']; SysEditUserFunctionForm.Password := Trim( qSysUserFunction.FieldByName('Password').AsString); SysEditUserFunctionForm.FirstName := Trim( qSysUserFunction.FieldByName('FirstName').AsString); SysEditUserFunctionForm.Surname := Trim( qSysUserFunction.FieldByName('Surname').AsString); sFunctionState := ''; sValue := IntToStr(qSysUserFunction.FieldByName('F1').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F2').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F3').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F4').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F5').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F6').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F7').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F8').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F9').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F10').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F11').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F12').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F13').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F14').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F15').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; sValue := IntToStr(qSysUserFunction.FieldByName('F16').AsInteger); if (sValue <> '0') then sValue := '1'; sFunctionState := sFunctionState + sValue; SysEditUserFunctionForm.Function1To16 := sFunctionState; end; // if not lAppend or.. SysEditUserFunctionForm.AppendMode := lAppend; if (SysEditUserFunctionForm.ShowModal = mrOk) then begin qSysUserFunction.Close; qSysUserFunction.Open; with qSysUserFunction do Locate('UserID',vNowAt,[]); end; end; // not empty. end // TabUserFunctionID. else if (CurrentTabID = TabUserID) then begin if not (qSysUser.Bof and qSysUser.Eof) then begin // not empty. MessageDlg('Select tUserFunction to edit this table.', mtInformation, [mbOk], 0); end; // not empty. end // TabUserID. else if (CurrentTabID = TabValidAccountID) then begin if not (qSysValidAccount.Bof and qSysValidAccount.Eof) then begin // not empty. SysEditForm := TSysEditForm.Create(SELF); SysEditForm.TableNameID := TABLE_VALIDACCOUNT; vNowAt := qSysValidAccount.FieldByName('id').AsInteger; if not lAppend or (MessageDlg('Use the present data as a starting point?', mtConfirmation, [mbYes, mbNo], 0)=mrYes) then begin if not lAppend then SysEditForm.Edit1 := IntToStr(vNowAt); SysEditForm.Edit2 := qSysValidAccount.FieldByName('AccountNo').AsString; SysEditForm.Edit3 := qSysValidAccount.FieldByName('BatchTypeID').AsString; SysEditForm.Edit4 := qSysValidAccount.FieldByName('BatchType').AsString; SysEditForm.Edit5 := qSysValidAccount.FieldByName('TenderNo').AsString; if lAppend then begin SysEditForm.Edit7 := Date; end else begin if not VarIsNull(qSysTransactionType['StartDate']) then begin SysEditForm.Edit7 := qSysTransactionType['StartDate']; end; if not VarIsNull(qSysTransactionType['EndDate']) then begin SysEditForm.Edit8 := qSysTransactionType['EndDate']; end; end; // lAppend. end else begin SysEditForm.Edit7 := Date; end; // if not lAppend or.. SysEditForm.AppendMode := lAppend; if (SysEditForm.ShowModal = mrOk) then begin qSysValidAccount.Close; qSysValidAccount.Open; with qSysValidAccount do Locate('id',vNowAt,[]); end; end; // not empty. end; // TabValidAccountID. Application.ProcessMessages; slNew.Free; end; // EditRecord. procedure TMainForm.btnApplyFilterClick(Sender: TObject); begin SetEditValue(SysPageControl.ActivePage, edtValue.Text); ApplyFilter(SysPageControl.ActivePage); end; procedure TMainForm.btnAddClick(Sender: TObject); begin if aAccess[USERMAINT] then EditRecord(TabPageID, True); // Append. end; procedure TMainForm.RxDBGridSysDblClick(Sender: TObject); begin if aAccess[USERMAINT] then EditRecord(TabPageID, False); // Edit. end; procedure TMainForm.btnDeleteClick(Sender: TObject); begin if aAccess[USERMAINT] then DeleteRecord(TabPageID); end; // btnDeletePersonClick. procedure TMainForm.RxDBGridSysGetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); var DataSet: TDataSet; begin if not Highlight then begin DataSet := (Sender as TrxDBGrid).DataSource.DataSet; if cbActive.Visible then begin if not (DataSet.FieldByName('Active').AsBoolean) then AFont.Color := clBlue; end; end; // if not Highlight then. end; // RxDBGridSysGetCellParams. function TMainForm.CurrentTabPageID: integer; var TabSheet : TTabSheet; begin TabSheet := SysPageControl.ActivePage; if (TabSheet = TabActivity) then Result := TabActivityID else if (TabSheet = TabAdjustment) then Result := TabAdjustmentID else if (TabSheet = TabAgreement) then Result := TabAgreementID else if (TabSheet = TabAgreementTariffs) then Result := TabAgreementTariffsID else if (TabSheet = TabAgreementType) then Result := TabAgreementTypeID else if (TabSheet = TabApplication) then Result := TabApplicationID else if (TabSheet = TabAudit) then Result := TabAuditID else if (TabSheet = TabAuditTrail) then Result := TabAuditTrailID else if (TabSheet = TabBatch) then Result := TabBatchID else if (TabSheet = TabBatchHistory) then Result := TabBatchHistoryID else if (TabSheet = TabBatchStatus) then Result := TabBatchStatusID else if (TabSheet = TabBatchType) then Result := TabBatchTypeID else if (TabSheet = TabCentre) then Result := TabCentreID else if (TabSheet = TabCostRange) then Result := TabCostRangeID else if (TabSheet = TabCriticalType) then Result := TabCriticalTypeID else if (TabSheet = TabCustomer) then Result := TabCustomerID else if (TabSheet = TabDataCollectionMap) then Result := TabDataCollectionMapID else if (TabSheet = TabDataSourceDetail) then Result := TabDataSourcedetailID else if (TabSheet = TabDataSourceType) then Result := TabDataSourceTypeID else if (TabSheet = TabDepartment) then Result := TabDepartmentID else if (TabSheet = TabDestination) then Result := TabDestinationID else if (TabSheet = TabDialledNumber) then Result := TabDialledNumberID else if (TabSheet = TabDiscount) then Result := TabDiscountID else if (TabSheet = TabDiscountedRate) then Result := TabDiscountedRateID else if (TabSheet = TabDubiousResolution) then Result := TabDubiousResolutionID else if (TabSheet = TabDubiousResult) then Result := TabDubiousResultID else if (TabSheet = TabDubiousType) then Result := TabDubiousTypeID else if (TabSheet = TabDubiousValidResolution) then Result := TabDubiousValidResolutionID else if (TabSheet = TabElement) then Result := TabElementID else if (TabSheet = TabFunction) then Result := TabFunctionID else if (TabSheet = TabGroup) then Result := TabGroupID else if (TabSheet = TabLocation) then Result := TabLocationID else if (TabSheet = TabOrigin) then Result := TabOriginID else if (TabSheet = TabParameter) then Result := TabParameterID else if (TabSheet = TabPerson) then Result := TabPersonID else if (TabSheet = TabProgram) then Result := TabProgramID else if (TabSheet = TabRate) then Result := TabRateID else if (TabSheet = TabRateDescription) then Result := TabRateDescriptionID else if (TabSheet = TabServiceID) then Result := TabServiceIDID else if (TabSheet = TabServiceKpi) then Result := TabServiceKpiID else if (TabSheet = TabServiceMnemonic) then Result := TabServiceMnemonicID else if (TabSheet = TabServiceSplit) then Result := TabServiceSplitID else if (TabSheet = TabServiceSystem) then Result := TabServiceSystemID else if (TabSheet = TabServiceType) then Result := TabServiceTypeID else if (TabSheet = TabStatus) then Result := TabStatusID else if (TabSheet = TabSubledger) then Result := TabSubledgerID else if (TabSheet = TabSupplier) then Result := TabSupplierID else if (TabSheet = TabSupplierServiceCode) then Result := TabSupplierServiceCodeID else if (TabSheet = TabSystem) then Result := TabSystemID else if (TabSheet = TabTransactionGroup) then Result := TabTransactionGroupID else if (TabSheet = TabTransactionType) then Result := TabTransactionTypeID else if (TabSheet = TabUser) then Result := TabUserID else if (TabSheet = TabUserFunction) then Result := TabUserFunctionID else if (TabSheet = TabValidAccount) then Result := TabValidAccountID else Result := 0; end; // CurrentTabPageID. function TMainForm.CurrentQuery(const TabPageID: integer): TQuery; var CurrentTabID : integer; begin CurrentTabID := TabPageID; case CurrentTabID of TabActivityID: Result := qSysActivity; TabAdjustmentID: Result := qSysAdjustment; TabAgreementID: Result := qSysAgreement; TabAgreementTariffsID: Result := qSysAgreementTariffs; TabAgreementTypeID: Result := qSysAgreementType; TabApplicationID: Result := qSysApplication; TabAuditID: Result := qSysAudit; TabAuditTrailID: Result := qSysAuditTrail; TabBatchID: Result := qSysBatch; TabBatchHistoryID: Result := qSysBatchHistory; TabBatchStatusID: Result := qSysBatchStatus; TabBatchTypeID: Result := qSysBatchType; TabCentreID: Result := qSysCentre; TabCostRangeID: Result := qSysCostRange; TabCriticalTypeID: Result := qSysCriticalType; TabCustomerID: Result := qSysCustomer; TabDataCollectionMapID: Result := qSysDataCollectionMap; TabDataSourceDetailID: Result := qSysDataSourcedetail; TabDataSourceTypeID: Result := qSysDataSourceType; TabDepartmentID: Result := qSysDepartment; TabDestinationID: Result := qSysDestination; TabDialledNumberID: Result := qSysDialledNumber; TabDiscountID: Result := qSysDiscount; TabDiscountedRateID: Result := qSysDiscountedRate; TabDubiousResolutionID: Result := qSysDubiousResolution; TabDubiousResultID: Result := qSysDubiousResult; TabDubiousTypeID: Result := qSysDubiousType; TabDubiousValidResolutionID: Result := qSysDubiousValidResolution; TabElementID: Result := qSysElement; TabFunctionID: Result := qSysFunction; TabGroupID: Result := qSysGroup; TabLocationID: Result := qSysLocation; TabOriginID: Result := qSysOrigin; TabParameterID: Result := qSysParameter; TabPersonID: Result := qSysPerson; TabProgramID: Result := qSysProgram; TabRateID: Result := qSysRate; TabRateDescriptionID: Result := qSysRateDescription; TabServiceIDID: Result := qSysServiceID; TabServiceKpiID: Result := qSysServiceKpi; TabServiceMnemonicID: Result := qSysServiceMnemonic; TabServiceSplitID: Result := qSysServiceSplit; TabServiceSystemID: Result := qSysServiceSystem; TabServiceTypeID: Result := qSysServiceType; TabStatusID: Result := qSysStatus; TabSubledgerID: Result := qSysSubledger; TabSupplierID: Result := qSysSupplier; TabSupplierServiceCodeID: Result := qSysSupplierServiceCode; TabSystemID: Result := qSysSystem; TabTransactionGroupID: Result := qSysTransactionGroup; TabTransactionTypeID: Result := qSysTransactionType; TabUserID: Result := qSysUser; TabUserFunctionID: Result := qSysUserFunction; TabValidAccountID: Result := qSysValidAccount; else Result := Nil; end; // case. end; // CurrentQuery. function TMainForm.CurrentDataSource(const TabPageID: integer): TDataSource; var CurrentTabID : integer; begin CurrentTabID := TabPageID; case CurrentTabID of TabActivityID: Result := dsSysActivity; TabAdjustmentID: Result := dsSysAdjustment; TabAgreementID: Result := dsSysAgreement; TabAgreementTariffsID: Result := dsSysAgreementTariffs; TabAgreementTypeID: Result := dsSysAgreementType; TabApplicationID: Result := dsSysApplication; TabAuditID: Result := dsSysAudit; TabAuditTrailID: Result := dsSysAuditTrail; TabBatchID: Result := dsSysBatch; TabBatchHistoryID: Result := dsSysBatchHistory; TabBatchStatusID: Result := dsSysBatchStatus; TabBatchTypeID: Result := dsSysBatchType; TabCentreID: Result := dsSysCentre; TabCostRangeID: Result := dsSysCostRange; TabCriticalTypeID: Result := dsSysCriticalType; TabCustomerID: Result := dsSysCustomer; TabDataCollectionMapID: Result := dsSysDataCollectionMap; TabDataSourceDetailID: Result := dsSysDataSourcedetail; TabDataSourceTypeID: Result := dsSysDataSourceType; TabDepartmentID: Result := dsSysDepartment; TabDestinationID: Result := dsSysDestination; TabDialledNumberID: Result := dsSysDialledNumber; TabDiscountID: Result := dsSysDiscount; TabDiscountedRateID: Result := dsSysDiscountedRate; TabDubiousResolutionID: Result := dsSysDubiousResolution; TabDubiousResultID: Result := dsSysDubiousResult; TabDubiousTypeID: Result := dsSysDubiousType; TabDubiousValidResolutionID: Result := dsSysDubiousValidResolution; TabElementID: Result := dsSysElement; TabFunctionID: Result := dsSysFunction; TabGroupID: Result := dsSysGroup; TabLocationID: Result := dsSysLocation; TabOriginID: Result := dsSysOrigin; TabParameterID: Result := dsSysParameter; TabPersonID: Result := dsSysPerson; TabProgramID: Result := dsSysProgram; TabRateID: Result := dsSysRate; TabRateDescriptionID: Result := dsSysRateDescription; TabServiceIDID: Result := dsSysServiceID; TabServiceKpiID: Result := dsSysServiceKpi; TabServiceSplitID: Result := dsSysServiceSplit; TabServiceSystemID: Result := dsSysServiceSystem; TabServiceTypeID: Result := dsSysServiceType; TabStatusID: Result := dsSysStatus; TabSubledgerID: Result := dsSysSubledger; TabSupplierID: Result := dsSysSupplier; TabSupplierServiceCodeID: Result := dsSysSupplierServiceCode; TabSystemID: Result := dsSysSystem; TabTransactionGroupID: Result := dsSysTransactionGroup; TabTransactionTypeID: Result := dsSysTransactionType; TabUserID: Result := dsSysUser; TabUserFunctionID: Result := dsSysUserFunction; TabValidAccountID: Result := dsSysValidAccount; else Result := Nil; end; // case. end; // CurrentDataSource. function TMainForm.CurrentTable(const TabPageID: integer): string; var CurrentTabID : integer; begin CurrentTabID := TabPageID; case CurrentTabID of TabActivityID: Result := 'tActivity'; TabAdjustmentID: Result := 'tAdjustment'; TabAgreementID: Result := 'tAgreement'; TabAgreementTariffsID: Result := 'tAgreementTariffs'; TabAgreementTypeID: Result := 'tAgreementType'; TabApplicationID: Result := 'tApplication'; TabAuditID: Result := 'tAudit'; TabAuditTrailID: Result := 'tAuditTrail'; TabBatchID: Result := 'tBatch'; TabBatchHistoryID: Result := 'tBatchHistory'; TabBatchStatusID: Result := 'tBatchStatus'; TabBatchTypeID: Result := 'tBatchType'; TabCentreID: Result := 'tCentre'; TabCostRangeID: Result := 'tCostRange'; TabCriticalTypeID: Result := 'tCriticalType'; TabCustomerID: Result := 'tCustomer'; TabDataCollectionMapID: Result := 'tDataCollectionMap'; TabDataSourceDetailID: Result := 'tDataSourceDetail'; TabDataSourceTypeID: Result := 'tDataSourceType'; TabDepartmentID: Result := 'tDepartment'; TabDestinationID: Result := 'tDestination'; TabDialledNumberID: Result := 'tDialledNumber'; TabDiscountID: Result := 'tDiscount'; TabDiscountedRateID: Result := 'tDiscountedRate'; TabDubiousResolutionID: Result := 'tDubiousResolution'; TabDubiousResultID: Result := 'tDubiousResult'; TabDubiousTypeID: Result := 'tDubiousType'; TabDubiousValidResolutionID: Result := 'tDubiousValidResolution'; TabElementID: Result := 'tElement'; TabFunctionID: Result := 'tFunction'; TabGroupID: Result := 'tGroup'; TabLocationID: Result := 'tLocation'; TabOriginID: Result := 'tOrigin'; TabParameterID: Result := 'tParameter'; TabPersonID: Result := 'tPerson'; TabProgramID: Result := 'tProgram'; TabRateID: Result := 'tRate'; TabRateDescriptionID: Result := 'tRateDescription'; TabServiceIDID: Result := 'tServiceID'; TabServiceKpiID: Result := 'tServiceKpi'; TabServiceSplitID: Result := 'tServiceSplit'; TabServiceSystemID: Result := 'ServiceSystem'; TabServiceTypeID: Result := 'tServiceType'; TabStatusID: Result := 'tStatus'; TabSubledgerID: Result := 'tSubledger'; TabSupplierID: Result := 'tSupplier'; TabSupplierServiceCodeID: Result := 'tSupplierServiceCode'; TabSystemID: Result := 'tSystem'; TabTransactionGroupID: Result := 'tTransactionGroup'; TabTransactionTypeID: Result := 'tTransactionType'; TabUserID: Result := 'tUser'; TabUserFunctionID: Result := 'tUserFunction'; TabValidAccountID: Result := 'tValidAccount'; else Result := 'empty'; end; // case. end; // CurrentTable. procedure TMainForm.RxDBGridSysTitleClick(Column: TColumn); var qTitle: TQuery; slQuery : TStrings; begin // Change sort order. qTitle := CurrentQuery(TabPageID); if (qTitle <> Nil) then begin qTitle.Close; slQuery := qTitle.SQL; GridTitleSort(Column, slQuery); qTitle.SQL := slQuery; qTitle.Open; end; end; // RxDBGridSysTitleClick. function TMainForm.CurrentField(const TabPageID: integer): string; var CurrentTabID : integer; begin CurrentTabID := TabPageID; case CurrentTabID of TabActivityID: Result := sFieldActivity; TabAdjustmentID: Result := sFieldAdjustment; TabAgreementID: Result := sFieldAgreement; TabAgreementTariffsID: Result := sFieldAgreementTariffs; TabAgreementTypeID: Result := sFieldAgreementType; TabApplicationID: Result := sFieldApplication; TabAuditID: Result := sFieldAudit; TabAuditTrailID: Result := sFieldAuditTrail; TabBatchID: Result := sFieldBatch; TabBatchHistoryID: Result := sFieldBatchHistory; TabBatchStatusID: Result := sFieldBatchStatus; TabBatchTypeID: Result := sFieldBatchType; TabCentreID: Result := sFieldCentre; TabCostRangeID: Result := sFieldCostRange; TabCriticalTypeID: Result := sFieldCriticalType; TabCustomerID: Result := sFieldCustomer; TabDataCollectionMapID: Result := sFieldDataCollectionMap; TabDataSourceDetailID: Result := sFieldDataSourcedetail; TabDataSourceTypeID: Result := sFieldDataSourceType; TabDepartmentID: Result := sFieldDepartment; TabDestinationID: Result := sFieldDestination; TabDialledNumberID: Result := sFieldDialledNumber; TabDiscountID: Result := sFieldDiscount; TabDiscountedRateID: Result := sFieldDiscountedRate; TabDubiousResolutionID: Result := sFieldDubiousResolution; TabDubiousResultID: Result := sFieldDubiousResult; TabDubiousTypeID: Result := sFieldDubiousType; TabDubiousValidResolutionID: Result := sFieldDubiousValidResolution; TabElementID: Result := sFieldElement; TabFunctionID: Result := sFieldFunction; TabGroupID: Result := sFieldGroup; TabLocationID: Result := sFieldLocation; TabOriginID: Result := sFieldOrigin; TabParameterID: Result := sFieldParameter; TabPersonID: Result := sFieldPerson; TabProgramID: Result := sFieldProgram; TabRateID: Result := sFieldRate; TabRateDescriptionID: Result := sFieldRateDescription; TabServiceIDID: Result := sFieldServiceID; TabServiceKpiID: Result := sFieldServiceKpi; TabServiceSplitID: Result := sFieldServiceSplit; TabServiceSystemID: Result := sFieldServiceSystem; TabServiceTypeID: Result := sFieldServiceType; TabStatusID: Result := sFieldStatus; TabSubledgerID: Result := sFieldSubledger; TabSupplierID: Result := sFieldSupplier; TabSupplierServiceCodeID: Result := sFieldSupplierServiceCode; TabSystemID: Result := sFieldSystem; TabTransactionGroupID: Result := sFieldTransactionGroup; TabTransactionTypeID: Result := sFieldTransactionType; TabUserID: Result := sFieldUser; TabUserFunctionID: Result := sFieldUserFunction; TabValidAccountID: Result := sFieldValidAccount; else Result := 'ID'; end; // case. end; // CurrentField. procedure TMainForm.FieldChange(const TabPageID: integer); var CurrentTabID : integer; nSelection : integer; begin CurrentTabID := TabPageID; nSelection := cbField.ItemIndex; if (CurrentTabID = TabActivityID) then begin case nSelection of 0: sFieldActivity := 'ID = '; 1: sFieldActivity := 'Description LIKE '''; 2: sFieldActivity := 'CustomerID = '; 3: sFieldActivity := 'ShipTo LIKE '''; end; // case. end // TabActivityID. else if (CurrentTabID = TabAdjustmentID) then begin case nSelection of 0: sFieldAdjustment := 'ServiceID LIKE '''; 1: sFieldAdjustment := 'ServiceType LIKE '''; 2: sFieldAdjustment := 'Description LIKE '''; 3: sFieldAdjustment := 'CallCode LIKE '''; 4: sFieldAdjustment := 'RateDescription LIKE '''; 5: sFieldAdjustment := 'BatchID = '; end; // case. end // TabAdjustmentID. else if (CurrentTabID = TabAgreementID) then begin case nSelection of 0: sFieldAgreement := 'ID = '; 1: sFieldAgreement := 'AgreementNo LIKE '''; 2: sFieldAgreement := 'SupplierID = '; 3: sFieldAgreement := 'Supplier LIKE '''; end; // case. end // TabAgreementID. else if (CurrentTabID = TabAgreementTariffsID) then begin case nSelection of 0: sFieldAgreementTariffs := 'ID = '; 1: sFieldAgreementTariffs := 'AgreementNo LIKE '''; 2: sFieldAgreementTariffs := 'AgreementType LIKE '''; 3: sFieldAgreementTariffs := 'SupplierID = '; 4: sFieldAgreementTariffs := 'SupplierName LIKE '''; 5: sFieldAgreementTariffs := 'Code LIKE '''; 6: sFieldAgreementTariffs := 'ValidAccountNo LIKE '''; end; // case. end // TabAgreementTariffsID. else if (CurrentTabID = TabAgreementTypeID) then begin case nSelection of 0: sFieldAgreementType := 'ID = '; 1: sFieldAgreementType := 'Description LIKE '''; end; // case. end // TabAgreementTypeID. else if (CurrentTabID = TabApplicationID) then begin case nSelection of 0: sFieldApplication := 'ID = '; 1: sFieldApplication := 'Description LIKE '''; end; // case. end // TabApplicationID. else if (CurrentTabID = TabAuditID) then begin case nSelection of 0: sFieldAudit := 'ID = '; 1: sFieldAudit := '[Table] LIKE '''; 3: sFieldAudit := 'UserLogin LIKE '''; end; // case. end // TabAuditID. else if (CurrentTabID = TabAuditTrailID) then begin case nSelection of 0: sFieldAuditTrail := 'UserID LIKE '''; 1: sFieldAuditTrail := 'Action = '; 2: sFieldAuditTrail := 'TableName LIKE '''; 3: sFieldAuditTrail := 'TableID = '; 4: sFieldAuditTrail := 'FieldName LIKE '''; 5: sFieldAuditTrail := 'OldValue LIKE '''; 6: sFieldAuditTrail := 'NewValue LIKE '''; end; // case. end // TabAuditTrailID. else if (CurrentTabID = TabBatchID) then begin case nSelection of 0: sFieldBatch := 'ID = '; 1: sFieldBatch := 'BatchTypeID = '; 2: sFieldBatch := 'BatchType LIKE '''; 3: sFieldBatch := 'BatchStatusID = '; 4: sFieldBatch := 'BatchStatus LIKE '''; 5: sFieldBatch := 'BillingPeriod LIKE '''; 6: sFieldBatch := 'SupplierID = '; 7: sFieldBatch := 'SupplierAccountID = '; 8: sFieldBatch := 'InvoiceNo LIKE '''; 9: sFieldBatch := 'RequisitionNumber LIKE '''; 10: sFieldBatch := 'OrderNumber LIKE '''; 11: sFieldBatch := 'TenderNo LIKE '''; end; // case. end // TabBatchID. else if (CurrentTabID = TabBatchHistoryID) then begin case nSelection of 0: sFieldBatchHistory := 'ID = '; 1: sFieldBatchHistory := 'BatchID = '; 2: sFieldBatchHistory := 'BatchType LIKE '''; 3: sFieldBatchHistory := 'BatchStatusID = '; 4: sFieldBatchHistory := 'BatchStatus LIKE '''; 5: sFieldBatchHistory := 'StatusChangeDate = '''; 6: sFieldBatchHistory := 'BillingPeriod LIKE '''; 7: sFieldBatchHistory := 'UserID = '; 8: sFieldBatchHistory := 'Operator LIKE '''; end; // case. end // TabBatchHistoryID. else if (CurrentTabID = TabBatchStatusID) then begin case nSelection of 0: sFieldBatchStatus := 'ID = '; 1: sFieldBatchStatus := 'Description LIKE '''; end; // case. end // TabBatchStatusID. else if (CurrentTabID = TabBatchTypeID) then begin case nSelection of 0: sFieldBatchType := 'ID = '; 1: sFieldBatchType := 'Description LIKE '''; 2: sFieldBatchType := 'SupplierID = '; 3: sFieldBatchType := 'SupplierName LIKE '''; 4: sFieldBatchType := 'DataSourceTypeID = '; 5: sFieldBatchType := 'DataSource LIKE '''; 6: sFieldBatchType := 'ValidAccount LIKE '''; 7: sFieldBatchType := 'ProgramDesc LIKE '''; 8: sFieldBatchType := 'TenderNo LIKE '''; 9: sFieldBatchType := 'AccountNoName LIKE '''; 10: sFieldBatchType := 'InvoiceNoName LIKE '''; 11: sFieldBatchType := 'TotalRevenueName LIKE '''; 12: sFieldBatchType := 'TotalPayableName LIKE '''; 13: sFieldBatchType := 'TotalCreditsName LIKE '''; 14: sFieldBatchType := 'OpeningBalanceName LIKE '''; 15: sFieldBatchType := 'PaymentsReceivedName LIKE '''; 16: sFieldBatchType := 'TotalAdjustmentsName LIKE '''; 17: sFieldBatchType := 'BatchStartName LIKE '''; 18: sFieldBatchType := 'BatchEndName LIKE '''; 19: sFieldBatchType := 'PaymentDateName LIKE '''; 20: sFieldBatchType := 'CreditsToCustomersName LIKE '''; 21: sFieldBatchType := 'GSTname LIKE '''; 22: sFieldBatchType := 'GSTAdjustmentName LIKE '''; 23: sFieldBatchType := 'OrderNumberName LIKE '''; 24: sFieldBatchType := 'requisitionNumberName LIKE '''; 25: sFieldBatchType := 'IssueDateName LIKE '''; 26: sFieldBatchType := 'RoundingName LIKE '''; end; // case. end // TabBatchTypeID. else if (CurrentTabID = TabCentreID) then begin case nSelection of 0: sFieldCentre := 'ID = '; 1: sFieldCentre := 'Description LIKE '''; 2: sFieldCentre := 'DepartmentID = '; 3: sFieldCentre := 'Department LIKE '''; 4: sFieldCentre := 'GroupID = '; 5: sFieldCentre := 'GroupName LIKE '''; 6: sFieldCentre := 'CustomerID = '; 7: sFieldCentre := 'ShipTo LIKE '''; 8: sFieldCentre := 'FullName LIKE '''; end; // case. end // TabCentreID. else if (CurrentTabID = TabCostRangeID) then begin case nSelection of 0: sFieldCostRange := 'ValidAccountNumberID = '; 1: sFieldCostRange := 'AccountNo LIKE '''; 2: sFieldCostRange := 'TransactionTypeID = '; 3: sFieldCostRange := 'TransactionType LIKE '''; end; // case. end else if (CurrentTabID = TabCustomerID) then begin case nSelection of 0: sFieldCustomer := 'ID = '; 1: sFieldCustomer := 'ShipTo LIKE '''; 2: sFieldCustomer := 'FullName LIKE '''; 3: sFieldCustomer := 'VNumber LIKE '''; 4: sFieldCustomer := 'Address01 LIKE '''; 5: sFieldCustomer := 'Address02 LIKE '''; 6: sFieldCustomer := 'Address03 LIKE '''; 7: sFieldCustomer := 'Address04 LIKE '''; 8: sFieldCustomer := 'Address05 LIKE '''; 9: sFieldCustomer := 'Address06 LIKE '''; 10: sFieldCustomer := 'Status LIKE '''; 11: sFieldCustomer := 'Invoice = '; 12: sFieldCustomer := 'InvoiceServices = '; 13: sFieldCustomer := 'PlatinumUpdate = '; end; // case. end // TabCustomerID. else if (CurrentTabID = TabDataCollectionMapID) then begin case nSelection of 0: sFieldDataCollectionMap := 'DCField LIKE '''; 1: sFieldDataCollectionMap := 'DCValue LIKE '''; 2: sFieldDataCollectionMap := 'TransValue LIKE '''; end; // case. end // TabDataCollectionMapID. else if (CurrentTabID = TabDepartmentID) then begin case nSelection of 0: sFieldDepartment := 'ID = '; 1: sFieldDepartment := 'Description LIKE '''; 2: sFieldDepartment := 'GroupID = '; 3: sFieldDepartment := 'GroupName LIKE '''; 4: sFieldDepartment := 'CustomerID = '; 5: sFieldDepartment := 'ShipTo LIKE '''; end; // case. end // TabDepartmentID. else if (CurrentTabID = TabDestinationID) then begin case nSelection of 0: sFieldDestination := 'ID = '; 1: sFieldDestination := 'Description LIKE '''; end; // case. end // TabDestinationID. else if (CurrentTabID = TabDialledNumberID) then begin case nSelection of 0: sFieldDialledNumber := 'ID = '; 1: sFieldDialledNumber := 'Description LIKE '''; end; // case. end // TabDialledNumberID. else if (CurrentTabID = TabDiscountID) then begin case nSelection of 0: sFieldDiscount := 'ServiceTypeID = '; 1: sFieldDiscount := 'Code LIKE '''; 2: sFieldDiscount := 'ServiceType LIKE '''; 3: sFieldDiscount := 'CustomerID = '; 4: sFieldDiscount := 'ShipTo LIKE '''; end; // case. end // TabDiscountID. else if (CurrentTabID = TabDiscountedRateID) then begin case nSelection of 0: sFieldDiscountedRate := 'ServiceTypeID = '; 1: sFieldDiscountedRate := 'Code LIKE '''; 2: sFieldDiscountedRate := 'ServiceType LIKE '''; 3: sFieldDiscountedRate := 'CustomerID = '; 4: sFieldDiscountedRate := 'ShipTo LIKE '''; end; // case. end // TabDiscountedRateID. else if (CurrentTabID = TabDubiousResolutionID) then begin case nSelection of 0: sFieldDubiousResolution := 'ID = '; 1: sFieldDubiousResolution := 'Description LIKE '''; end; // case. end // TabDubiousResolutionID. else if (CurrentTabID = TabDubiousResultID) then begin case nSelection of 0: sFieldDubiousResult := 'ID = '; 1: sFieldDubiousResult := 'BatchID = '; 2: sFieldDubiousResult := 'ServiceID LIKE '''; 3: sFieldDubiousResult := 'ShipTo LIKE '''; 4: sFieldDubiousResult := 'UserLogin LIKE '''; 5: sFieldDubiousResult := 'DubiousResolution LIKE '''; 6: sFieldDubiousResult := 'DubiousType LIKE '''; 7: sFieldDubiousResult := 'Code LIKE '''; end; // case. end // TabDubiousResultID. else if (CurrentTabID = TabDubiousTypeID) then begin case nSelection of 0: sFieldDubiousType := 'ID = '; 1: sFieldDubiousType := 'Description LIKE '''; end; // case. end // TabDubiousTypeID. else if (CurrentTabID = TabDubiousValidResolutionID) then begin case nSelection of 0: sFieldDubiousValidResolution := 'ID = '; 1: sFieldDubiousValidResolution := 'DubiousTypeID = '; 2: sFieldDubiousValidResolution := 'DubiousType LIKE '''; 3: sFieldDubiousValidResolution := 'DubiousResolutionID = '; 4: sFieldDubiousValidResolution := 'Resolution LIKE '''; end; // case. end // TabDubiousValidResolutionID. else if (CurrentTabID = TabElementID) then begin case nSelection of 0: sFieldElement := 'ID = '; 1: sFieldElement := 'ElementCode LIKE '''; 2: sFieldElement := 'Description LIKE '''; 3: sFieldElement := 'CustomerID = '; 4: sFieldElement := 'ShipTo LIKE '''; 5: sFieldElement := 'ServiceGroupID = '; 6: sFieldElement := 'PlatinumUpdate = '; 7: sFieldElement := 'ReportGroupID = '; end; // case. end // TabElementID. else if (CurrentTabID = TabFunctionID) then begin case nSelection of 0: sFieldFunction := 'ID = '; 1: sFieldFunction := 'Description LIKE '''; end; // case. end // TabFunctionID. else if (CurrentTabID = TabGroupID) then begin case nSelection of 0: sFieldGroup := 'ID = '; 1: sFieldGroup := 'Description LIKE '''; 2: sFieldGroup := 'CustomerID = '; 3: sFieldGroup := 'ShipTo LIKE '''; end; // case. end // TabGroupID. else if (CurrentTabID = TabLocationID) then begin case nSelection of 0: sFieldLocation := 'ID = '; 1: sFieldLocation := 'Description LIKE '''; end; // case. end // TabLocationID. else if (CurrentTabID = TabOriginID) then begin case nSelection of 0: sFieldOrigin := 'ID = '; 1: sFieldOrigin := 'Description LIKE '''; end; // case. end // TabOriginID. else if (CurrentTabID = TabParameterID) then begin case nSelection of 0: sFieldParameter := 'Parm LIKE '''; 1: sFieldParameter := 'ParmField LIKE '''; 2: sFieldParameter := 'ParmText LIKE '''; 3: sFieldParameter := 'ParmDescription LIKE '''; end; // case. end // TabParameterID. else if (CurrentTabID = TabPersonID) then begin case nSelection of 0: sFieldPerson := 'ID = '; 1: sFieldPerson := 'Person LIKE '''; 2: sFieldPerson := 'EmailAddress LIKE '''; end; // case. end // TabPersonID. else if (CurrentTabID = TabProgramID) then begin case nSelection of 0: sFieldProgram := 'ID = '; 1: sFieldProgram := 'Description LIKE '''; end; // case. end // TabProgramID. else if (CurrentTabID = TabRateID) then begin case nSelection of 0: sFieldRate := 'ID = '; 1: sFieldRate := 'ServiceTypeID = '; 2: sFieldRate := 'Code LIKE '''; 3: sFieldRate := 'ServiceType LIKE '''; 4: sFieldRate := 'RateDescription LIKE '''; 5: sFieldRate := 'LastUpdatedBy LIKE '''; end; // case. end // TabRateID. else if (CurrentTabID = TabRateDescriptionID) then begin case nSelection of 0: sFieldRateDescription := 'ID = '; 1: sFieldRateDescription := 'Description LIKE '''; end; // case. end // TabRateDescriptionID. else if (CurrentTabID = TabServiceIDID) then begin case nSelection of 0: sFieldServiceID := 'ID = '; 1: sFieldServiceID := 'ServiceID LIKE '''; 2: sFieldServiceID := 'Service LIKE '''; 3: sFieldServiceID := 'Jobno LIKE '''; 4: sFieldServiceID := 'ServiceTypeID = '; 5: sFieldServiceID := 'Code LIKE '''; 6: sFieldServiceID := 'ServiceType LIKE '''; 7: sFieldServiceID := 'SACCnumber LIKE '''; 8: sFieldServiceID := 'Description LIKE '''; 9: sFieldServiceID := 'SupplierAccountID = '; 10: sFieldServiceID := 'AccountNo LIKE '''; 11: sFieldServiceID := 'CustomerID = '; 12: sFieldServiceID := 'ShipTo LIKE '''; 13: sFieldServiceID := 'Customer LIKE '''; 14: sFieldServiceID := 'CustomerCentreID = '; 15: sFieldServiceID := 'CustomerCentre LIKE '''; 16: sFieldServiceID := 'CustomerActivityID = '; 17: sFieldServiceID := 'CustomerActivity LIKE '''; 18: sFieldServiceID := 'CustomerElementID = '; 19: sFieldServiceID := 'CustomerElement LIKE '''; 20: sFieldServiceID := 'CustomerSubledgerID = '; 21: sFieldServiceID := 'CustomerSubledger LIKE '''; 22: sFieldServiceID := 'PayType LIKE '''; 23: sFieldServiceID := 'CentreID = '; 24: sFieldServiceID := 'Centre LIKE '''; 25: sFieldServiceID := 'ActivityID = '; 26: sFieldServiceID := 'Activity LIKE '''; 27: sFieldServiceID := 'ElementID = '; 28: sFieldServiceID := 'Element LIKE '''; 29: sFieldServiceID := 'SubledgerID = '; 30: sFieldServiceID := 'Subledger LIKE '''; 31: sFieldServiceID := 'LocationID = '; 32: sFieldServiceID := 'Location LIKE '' '; 33: sFieldServiceID := 'PersonID = '; 34: sFieldServiceID := 'Person LIKE '''; 35: sFieldServiceID := 'ApplicationID = '; 36: sFieldServiceID := 'Application LIKE '''; 37: sFieldServiceID := 'UpEnd LIKE '''; 38: sFieldServiceID := 'UpMDF LIKE '''; 39: sFieldServiceID := 'DownEnd LIKE '''; 40: sFieldServiceID := 'DownMDF LIKE '''; end; // case. end // TabServiceIDID. else if (CurrentTabID = TabServiceKpiID) then begin // 100314 RJC. case nSelection of 0: sFieldServiceKpi := 'ID = '; 1: sFieldServiceKpi := 'KpiNumber LIKE '''; 2: sFieldServiceKpi := 'Description LIKE '''; 3: sFieldServiceKpi := 'ResponseHours LIKE '''; 4: sFieldServiceKpi := 'RestorationHours LIKE '''; 5: sFieldServiceKpi := 'Availability LIKE '''; 6: sFieldServiceKpi := 'CoreHours LIKE '''; 7: sFieldServiceKpi := 'AfterHours LIKE '''; 8: sFieldServiceKpi := 'TravelTime LIKE '''; 9: sFieldServiceKpi := 'FaultDetect LIKE '''; end; // case. end // TabServiceKpiID. else if (CurrentTabID = TabServiceSplitID) then begin case nSelection of 0: sFieldServiceSplit := 'ID = '; 1: sFieldServiceSplit := 'ServiceID = '; 2: sFieldServiceSplit := 'ServiceID_Desc LIKE '''; 3: sFieldServiceSplit := 'CustomerID = '; 4: sFieldServiceSplit := 'ShipTo LIKE '''; 5: sFieldServiceSplit := 'CallPercentage = '''; 6: sFieldServiceSplit := 'RentPercentage = '''; 7: sFieldServiceSplit := 'OtherPercentage = '''; end; // case. end // TabServiceSplitID. else if (CurrentTabID = TabServiceSystemID) then begin case nSelection of 0: sFieldServiceSystem := 'ServiceTypeID = '; 1: sFieldServiceSystem := 'Code LIKE '''; 2: sFieldServiceSystem := 'ServiceType LIKE '''; 3: sFieldServiceSystem := 'SupplierID = '; 4: sFieldServiceSystem := 'SupplierName LIKE '''; 5: sFieldServiceSystem := 'SystemID = '; 6: sFieldServiceSystem := 'System LIKE '''; 7: sFieldServiceSystem := 'BatchTypeID = '; 8: sFieldServiceSystem := 'BatchTypeDescription LIKE '''; 9: sFieldServiceSystem := 'ValidAccountNumberID = '; 10: sFieldServiceSystem := 'AccountNo LIKE '''; end; // case. end // TabServiceSystemID. else if (CurrentTabID = TabServiceTypeID) then begin case nSelection of 0: sFieldServiceType := 'ID = '; 1: sFieldServiceType := 'Code LIKE '''; 2: sFieldServiceType := 'Description LIKE '''; 3: sFieldServiceType := 'SupplierID = '; 4: sFieldServiceType := 'SupplierName LIKE '''; 5: sFieldServiceType := 'RevenueElementID = '; 6: sFieldServiceType := 'RevenueElement LIKE '''; 7: sFieldServiceType := 'ExpenseElementID = '; 8: sFieldServiceType := 'ExpenseElement LIKE '''; 9: sFieldServiceType := 'AdminFee = '; 10: sFieldServiceType := 'SystemID = '; 11: sFieldServiceType := 'System LIKE '''; 12: sFieldServiceType := 'ExportToTims = '; 13: sFieldServiceType := 'ServiceSplit = '; 14: sFieldServiceType := 'VRTServiceType = '; 15: sFieldServiceType := 'ExpectedRent = '; 16: sFieldServiceType := 'NoCalls = '; 17: sFieldServiceType := 'Active = '; end; // case. end // TabServiceTypeID. else if (CurrentTabID = TabStatusID) then begin case nSelection of 0: sFieldStatus := 'ID = '; 1: sFieldStatus := 'ServiceTypeID = '; 2: sFieldStatus := 'ServiceType LIKE '''; 3: sFieldStatus := 'RateDescription LIKE '''; end; // case. end // TabStatusID. else if (CurrentTabID = TabSubledgerID) then begin case nSelection of 0: sFieldSubledger := 'ID = '; 1: sFieldSubledger := 'Description LIKE '''; 2: sFieldSubledger := 'CustomerID = '; 3: sFieldSubledger := 'ShipTo LIKE '''; 4: sFieldSubledger := 'StartDate = '''; 5: sFieldSubledger := 'EndDate = '''; 6: sFieldSubledger := 'Active = '; end; // case. end // TabSubledgerID. else if (CurrentTabID = TabSupplierID) then begin case nSelection of 0: sFieldSupplier := 'ID = '; 1: sFieldSupplier := 'SupplierName LIKE '''; 2: sFieldSupplier := 'PlatinumVendorID LIKE '''; 3: sFieldSupplier := 'PlatinumUpdate = '; 4: sFieldSupplier := 'VicTrack = '; 5: sFieldSupplier := 'Address01 LIKE '''; 6: sFieldSupplier := 'TransactionTypeID = '; 7: sFieldSupplier := 'System LIKE '''; end; // case. end // TabSupplierID. else if (CurrentTabID = TabSupplierServiceCodeID) then begin case nSelection of 0: sFieldSupplierServiceCode := 'ID = '; 1: sFieldSupplierServiceCode := 'Code LIKE '''; 2: sFieldSupplierServiceCode := 'AmountCategory LIKE '''; 3: sFieldSupplierServiceCode := 'Description LIKE '''; 4: sFieldSupplierServiceCode := 'TransactionTypeDesc LIKE '''; 5: sFieldSupplierServiceCode := 'TransactionTypeID = '; 6: sFieldSupplierServiceCode := 'TransactionType LIKE '''; 7: sFieldSupplierServiceCode := 'SupplierID = '; 8: sFieldSupplierServiceCode := 'SupplierName LIKE '''; end; // case. end // TabSupplierServiceCodeID. else if (CurrentTabID = TabSystemID) then begin case nSelection of 0: sFieldSystem := 'ID = '; 1: sFieldSystem := 'System LIKE '''; 2: sFieldSystem := 'BatchTypeID = '; 3: sFieldSystem := 'BatchType LIKE '''; end; // case. end // TabSystemID. else if (CurrentTabID = TabTransactionTypeID) then begin case nSelection of 0: sFieldTransactionType := 'ID = '; 1: sFieldTransactionType := 'Description LIKE '''; 2: sFieldTransactionType := 'TransactionGroupID = '; 3: sFieldTransactionType := 'TransactionGroup LIKE '''; 4: sFieldTransactionType := 'SystemID = '; 5: sFieldTransactionType := 'System LIKE '''; end; // case. end // TabTransactionTypeID. else if (CurrentTabID = TabTransactionGroupID) then begin case nSelection of 0: sFieldTransactionGroup := 'ID = '; 1: sFieldTransactionGroup := 'Description LIKE '''; end; // case. end // TabTransactionGroupID. else if (CurrentTabID = TabUserID) then begin case nSelection of 0: sFieldUser := 'ID = '; 1: sFieldUser := 'UserLogin LIKE '''; // 2: sFieldUser := 'Password LIKE '''; 2: sFieldUser := 'FirstName LIKE '''; 3: sFieldUser := 'Surname LIKE '''; end; // case. end // TabUserID. else if (CurrentTabID = TabUserFunctionID) then begin case nSelection of 0: sFieldUserFunction := 'UserLogin LIKE '''; 1: sFieldUserFunction := 'Password LIKE '''; 2: sFieldUserFunction := 'FirstName LIKE '''; 3: sFieldUserFunction := 'SurName LIKE '''; end; // case. end // TabUserFunctionID. else if (CurrentTabID = TabValidAccountID) then begin case nSelection of 0: sFieldValidAccount := 'ID = '; 1: sFieldValidAccount := 'AccountNo LIKE '''; 2: sFieldValidAccount := 'BatchTypeID = '; 3: sFieldValidAccount := 'BatchType LIKE '''; 4: sFieldValidAccount := 'Active = '; end; // case. { end // TabValidAccountID. else if (CurrentTabID = TabValidAccountID) then begin case nSelection of 0: sFieldValidAccount := 'ServiceTypeID = '; 1: sFieldValidAccount := 'Code LIKE '''; 2: sFieldValidAccount := 'SupplierID = '; 3: sFieldValidAccount := 'SupplierName LIKE '''; 4: sFieldValidAccount := 'SystemID = '; 5: sFieldValidAccount := 'System LIKE '''; 6: sFieldValidAccount := 'BatchTypeID = '; 7: sFieldValidAccount := 'BatchTypeDescription LIKE '''; 8: sFieldValidAccount := 'ValidAccountNumberID = '; 9: sFieldValidAccount := 'AccountNo LIKE '''; end; // case. } end; // TabValidAccountID. end; // FieldChange(). procedure TMainForm.cbFieldChange(Sender: TObject); begin SetFieldNumberValue(SysPageControl.ActivePage, cbField.ItemIndex); edtValue.SetFocus; end; // cbFieldChange(). procedure TMainForm.btnClearClick(Sender: TObject); begin SetFieldNumberValue(SysPageControl.ActivePage, -1); SetEditValue(SysPageControl.ActivePage, ''); end; // btnClearClick. procedure TMainForm.ActionTabClose(Sender: TObject); begin if SysPageControl.Visible then begin CloseTab(SysPageControl.ActivePage); if (SysPageControl.PageCount = 0) then begin SysPageControl.Visible := False; end; end; end; procedure TMainForm.ActionExit(Sender: TObject); begin Close; end; procedure TMainForm.SysPageControlChange(Sender: TObject); var TabPage : TTabSheet; qControl : TQuery; lActive : boolean; i : integer; begin if SysPageControl.Visible and (SysPageControl.ActivePage <> Nil) then begin TabPage := SysPageControl.ActivePage; TabPageID := CurrentTabPageID; cbField.Items := GetComboBoxItems(TabPageID); edtValue.Text := GetEditValue(TabPage); cbField.ItemIndex := GetFieldNumberValue(TabPage); if (cbField.ItemIndex = -1) then cbField.Text := ''; cbActive.Checked := GetActiveValue(TabPage); cbNotActive.Checked := GetNotActiveValue(TabPage); dbNavigator.DataSource := CurrentDataSource(TabPageID); dbNavigator.Visible := True; panelTopOfTab.Visible := True; qControl := CurrentQuery(TabPageID); lActive := False; if (qControl <> nil) then with qControl do for i := 0 to (FieldCount - 1) do if (Fields[i].FieldName = 'Active') then begin lActive := True; break; end; cbActive.Visible := lActive; cbNotActive.Visible := lActive; end else begin dbNavigator.Visible := False; panelTopOfTab.Visible := False; cbActive.Visible := False; cbNotActive.Visible := False; end; // if SysPageControl.Visible and..then begin. end; // SysPageControlChange. procedure TMainForm.cbActiveClick(Sender: TObject); begin SetActiveValue(SysPageControl.ActivePage, cbActive.Checked); end; procedure TMainForm.cbNotActiveClick(Sender: TObject); begin SetNotActiveValue(SysPageControl.ActivePage, cbNotActive.Checked); end; procedure TMainForm.mnuMainFilePrinterSetupClick(Sender: TObject); begin MainPrinterSetupDialog.Execute; end; // mnuMainFilePrinterSetupClick. procedure TMainForm.mnuHelpAboutClick(Sender: TObject); var AboutForm : TAboutBox; begin AboutForm := TAboutBox.Create(self); AboutForm.ShowModal; AboutForm.Free; end; procedure TMainForm.mnuFilePrintSetupClick(Sender: TObject); begin MainPrinterSetupDialog.Execute; end; procedure TMainForm.ActionPrintCurrentTab(Sender: TObject); var qryPrint : TQuery; sHeader : string; // BM : TBookmark; begin if SysPageControl.Visible then begin qryPrint := CurrentQuery(TabPageID); sHeader := CurrentTable(TabPageID); if (UpperCase(sHeader) <> 'EMPTY') then begin if (Length(Trim(cbField.Text))=0) or (Length(Trim(edtValue.Text))=0) then sHeader := sHeader+' - Unfiltered View' else sHeader := sHeader+' - Filtered on '+cbField.Text+' = '+edtValue.Text; if (TabPageID=TabServiceIDID) then PrintDataSet(RxDBGridServiceID.DataSource.DataSet, sHeader) else PrintQuery(qryPrint, sHeader); end; end; // if PageControl1.Visible then begin..else.. end; // ActionPrintCurrentTab. procedure TMainForm.ActionFileCurrentTab(Sender: TObject); var qryFile : TQuery; sFileName : string; // BM : TBookmark; begin if SysPageControl.Visible then begin if (CurrentTabPageID = TabServiceIDID) then begin if (MessageDlg('Export only for tServiceID with "TQ_" services?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then begin qryFile := TQuery.Create(SELF); with qryFile do begin DatabaseName := 'dbPPdata'; SQL.Add('SELECT dbo.tServiceID.ServiceID, dbo.tServiceType.Code, '+ 'dbo.tCustomer.ShipTo, dbo.tGroup.Description AS Grp,'); SQL.Add(' dbo.tDepartment.Description AS Dept'); SQL.Add('FROM dbo.tServiceType INNER JOIN dbo.tServiceID '+ 'ON dbo.tServiceType.ID = dbo.tServiceID.ServiceTypeID'); SQL.Add(' INNER JOIN dbo.tDepartment'); SQL.Add(' INNER JOIN dbo.tCentre '+ 'ON dbo.tDepartment.ID = dbo.tCentre.DepartmentID'); SQL.Add(' INNER JOIN dbo.tGroup '+ 'ON dbo.tDepartment.GroupID = dbo.tGroup.ID'); SQL.Add(' INNER JOIN dbo.tCustomer '+ 'ON dbo.tGroup.CustomerID = dbo.tCustomer.ID'); SQL.Add(' ON dbo.tServiceID.CustomerCentreID = dbo.tCentre.ID'); SQL.Add('WHERE (dbo.tServiceType.Code LIKE ''TQ%'') AND '+ '(dbo.tServiceID.Active = 1)'); SQL.Add('ORDER BY dbo.tServiceID.ServiceID'); Open; sFileName := 'user'; end; // qryFile. end else begin qryFile := CurrentQuery(CurrentTabPageID); sFileName := CurrentTable(CurrentTabPageID); end; end else begin qryFile := CurrentQuery(CurrentTabPageID); sFileName := CurrentTable(CurrentTabPageID); end; FileQuery(qryFile, sFileName); end; // if PageControl1.Visible then begin..else.. end; // ActionFileCurrentTab. procedure TMainForm.mnuFileExitClick(Sender: TObject); begin Close; end; procedure TMainForm.mnuToolsSelectMainDatabaseItemClick(Sender: TObject); begin DM.SetDatabaseSet(False); TestDatabaseFlag := TestForTestDB; lblTestData.Visible := TestDatabaseFlag; end; procedure TMainForm.ActionReportCPIAdjustment(Sender: TObject); var qryFile : TQuery; sFileName : string; sCPI : string; begin // GetParameter('CPIpercentage', 'sCPI'); qryFile := TQuery.Create(SELF); with qryFile do begin // Database := 'dbPPdata'; SQL.Add('SELECT *'); SQL.Add('FROM '); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); SQL.Add(''); end; // qryFile. sFileName := 'CPI Adjustment '+ DateToStr(Now); FileQuery(qryFile, sFileName); end; // ActionReportCPIAdjustment. procedure TMainForm.mnuToolsSelectTestDatabaseItemClick(Sender: TObject); begin DM.SetDatabaseSet(True); TestDatabaseFlag := TestForTestDB; lblTestData.Visible := TestDatabaseFlag; end; // mnuToolsSelectTestDatabaseItemClick. end.