unit SysServiceRecord; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, dbtables, Mask, ToolEdit, CurrEdit; type TSysServiceRecordForm = class(TForm) edtNo: TEdit; lblNo: TLabel; lblBearerID: TLabel; edtBearerID: TEdit; lblUpMDF: TLabel; edtUpMDF: TEdit; lblCost: TLabel; lblPart: TLabel; edtPart: TEdit; lblBearerName: TLabel; edtBearername: TEdit; lblUpEnd: TLabel; edtUpEnd: TEdit; lblCost100: TLabel; lblModemType: TLabel; lblDownMDF: TLabel; edtDownMDF: TEdit; lblDownEnd: TLabel; edtDownEnd: TEdit; lblInvoiced: TLabel; lblDrawing: TLabel; edtDrawing: TEdit; lblSpeed: TLabel; lblCh: TLabel; edtCh: TEdit; lblMux: TLabel; edtMux: TEdit; lblMake: TLabel; edtMake: TEdit; lblAuthority: TLabel; btnOk: TButton; btnCancel: TButton; lblLineLength: TLabel; edtLineLength: TEdit; edtCost: TCurrencyEdit; edtCost100: TCurrencyEdit; edtInvoiced: TCurrencyEdit; cbMnemonic: TComboBox; lblMnemonic: TLabel; cbModemTypeDescription: TComboBox; cbSpeedDescription: TComboBox; cbAuthorityDescription: TComboBox; procedure FormCreate(Sender: TObject); procedure btnOkClick(Sender: TObject); procedure btnCancelClick(Sender: TObject); private { Private declarations } ValueRecordStatus : boolean; aMnemonicID : array of integer; aModemTypeID : array of integer; aSpeedID : array of integer; aAuthorityID : array of integer; public { Public declarations } protected procedure SetRecordStatus(const Value: boolean); function GetRecordStatus: boolean; procedure SetFormCaptionName(const Value: string); function GetFormCaptionName: string; procedure SetUpMDF(const Value: string); function GetUpMDF: string; procedure SetUpEnd(const Value: string); function GetUpEnd: string; procedure SetDownMDF(const Value: string); function GetDownMDF: string; procedure SetDownEnd(const Value: string); function GetDownEnd: string; procedure SetLineLength(const Value: string); function GetLineLength: string; procedure SetCost(const Value: Currency); function GetCost: Currency; procedure SetCost100(const Value: Currency); function GetCost100: Currency; procedure SetInvoiced(const Value: Currency); function GetInvoiced: Currency; procedure SetNo(const Value: string); function GetNo: string; procedure SetPart(const Value: string); function GetPart: string; procedure SetDrawing(const Value: string); function GetDrawing: string; procedure SetMuxLink(const Value: string); function GetMuxLink: string; procedure SetServiceLink(const Value: string); function GetServiceLink: string; procedure SetMux(const Value: string); function GetMux: string; procedure SetCh(const Value: string); function GetCh: string; procedure SetMake(const Value: string); function GetMake: string; procedure SetBearerID(const Value: integer); function GetBearerID: integer; procedure SetBearerName(const Value: string); function GetBearerName: string; procedure SetSpeedID(const Value: integer); function GetSpeedID: integer; // procedure SetSpeedName(const Value: string); // function GetSpeedName: string; procedure SetModemTypeID(const Value: integer); function GetModemTypeID: integer; // procedure SetModemTypeName(const Value: string); // function GetModemTypeName: string; // procedure SetLineID(const Value: integer); // function GetLineID: integer; procedure SetLineName(const Value: string); function GetLineName: string; procedure SetAuthorityID(const Value: integer); function GetAuthorityID: integer; // procedure SetAuthorityName(const Value: string); // function GetAuthorityName: string; // procedure SetVirtualCableID(const Value: integer); // function GetVirtualCableID: integer; // procedure SetVirtualCableName(const Value: string); // function GetVirtualCableName: string; procedure SetMnemonicID(const Value: integer); function GetMnemonicID: integer; published property RecordStatus: boolean read GetRecordStatus write SetRecordStatus; property FormCaptionName: string read GetFormCaptionName write SetFormCaptionName; property UpMDF: string read GetUpMDF write SetUpMDF; property UpEnd: string read GetUpEnd write SetUpEnd; property DownMDF: string read GetDownMDF write SetDownMDF; property DownEnd: string read GetDownEnd write SetDownEnd; property LineLength: string read GetLineLength write SetLineLength; property No: string read GetNo write SetNo; property Part: string read GetPart write SetPart; property Cost: Currency read GetCost write SetCost; property Cost100: Currency read GetCost100 write SetCost100; property Invoiced: Currency read GetInvoiced write SetInvoiced; property Drawing: string read GetDrawing write SetDrawing; property Make: string read GetMake write SetMake; property Ch: string read GetCh write SetCh; property MuxLink: string read GetMuxLink write SetMuxLink; property Mux: string read GetMux write SetMux; property ServiceLink: string read GetServiceLink write SetServiceLink; property BearerID: integer read GetBearerID write SetBearerID; property BearerName: string read GetBearerName write SetBearerName; property SpeedID: integer read GetSpeedID write SetSpeedID; // property SpeedName: string read GetSpeedName write SetSpeedName; property ModemTypeID: integer read GetModemTypeID write SetModemTypeID; // property ModemTypeName: string read GetModemTypeName write SetModemTypeName; // property LineID: integer read GetLineID write SetLineID; property LineName: string read GetLineName write SetLineName; property AuthorityID: integer read GetAuthorityID write SetAuthorityID; // property AuthorityName: string read GetAuthorityName write SetAuthorityName; // property VirtualCableID: integer read GetVirtualCableID write SetVirtualCableID; property VirtualCableName: string read GetVirtualCableName write SetVirtualCableName; property MnemonicID: integer read GetMnemonicID write SetMnemonicID; end; var SysServiceRecordForm: TSysServiceRecordForm; implementation uses SysEditServiceID; {$R *.DFM} procedure TSysServiceRecordForm.FormCreate(Sender: TObject); var q : TQuery; ncount : integer; begin q := TQuery.Create(SELF); q.DatabaseName := 'dbPPdata'; //****************** Mnemonic *********************** // First, set a dimension on the array of options for aMnemonicID. q.SQL.Add('SELECT Count(*) AS nMax'); q.SQL.Add('FROM tServiceMnemonic'); q.SQL.Add('WHERE Active = 1'); q.Open; if not q.Eof then SetLength(aMnemonicID, 1 + q.FieldByName('nMax').AsInteger); q.Close; q.SQL.Clear; q.SQL.Add('SELECT ID, ServiceCode, Description'); q.SQL.Add('FROM tServiceMnemonic'); q.SQL.Add('WHERE Active = 1'); q.SQL.Add('ORDER BY ServiceCode'); q.Open; if not q.Eof then begin nCount := 0; cbMnemonic.Items.Add(''); // Allows user to NOT select a KPI. aMnemonicID[nCount] := 0; while not q.Eof do begin cbMnemonic.Items.Add(q.FieldByName('ServiceCode').AsString + ' - '+ q.FieldByName('Description').AsString); Inc(nCount); aMnemonicID[nCount] := q.FieldByName('ID').AsInteger; q.Next; end; // while. end; // q.Eof. //****************** rModem *************************** q.Close; q.SQL.Clear; q.SQL.Add('SELECT Count(*) AS nMax'); q.SQL.Add('FROM rModem'); q.Open; if not q.Eof then SetLength(aModemTypeID, 1+ q.FieldByName('nMax').AsInteger); q.Close; q.SQL.Clear; q.SQL.Add('SELECT ID, RTRIM(CAST(TextValue AS varchar)) AS "Description"'); q.SQL.Add('FROM rModem'); q.SQL.Add('ORDER BY TextValue'); q.Open; if not q.Eof then begin nCount := 0; cbModemTypeDescription.Items.Add(''); // Allows user to NOT select a value. aModemTypeID[nCount] := 0; while not q.Eof do begin cbModemTypeDescription.Items.Add(q.FieldByName('Description').AsString); Inc(nCount); aModemTypeID[nCount] := q.FieldByName('ID').AsInteger; q.Next; end; // while. end; // q.Eof. //*************** rBearerSpeed *************************** q.Close; q.SQL.Clear; q.SQL.Add('SELECT Count(*) AS nMax'); q.SQL.Add('FROM rBearerSpeed'); q.Open; if not q.Eof then SetLength(aSpeedID, 1 + q.FieldByName('nMax').AsInteger); q.Close; q.SQL.Clear; q.SQL.Add('SELECT ID, RTRIM(CAST(TextValue AS varchar)) AS Description'); q.SQL.Add('FROM rBearerSpeed'); q.SQL.Add('ORDER BY TextValue'); q.Open; if not q.Eof then begin nCount := 0; cbSpeedDescription.Items.Add(''); // Allows user to NOT select a value. aSpeedID[nCount] := 0; while not q.Eof do begin cbSpeedDescription.Items.Add(q.FieldByName('Description').AsString); Inc(nCount); aSpeedID[nCount] := q.FieldByName('ID').AsInteger; q.Next; end; // while. end; // q.Eof. //******************* Authority ************************* q.Close; q.SQL.Clear; q.SQL.Add('SELECT Count(*) AS nMax'); q.SQL.Add('FROM tCableInst'); q.Open; if not q.Eof then SetLength(aAuthorityID, 1+q.FieldByName('nMax').AsInteger); q.Close; q.SQL.Clear; q.SQL.Add('SELECT ID, RTRIM(CAST(AuthNo AS varchar)) AS "Description"'); q.SQL.Add('FROM tCableInst'); q.SQL.Add('ORDER BY AuthNo'); q.Open; if not q.Eof then begin nCount := 0; cbAuthorityDescription.Items.Add(''); // Allows user to NOT select a value. aAuthorityID[nCount] := 0; while not q.Eof do begin cbAuthorityDescription.Items.Add(q.FieldByName('Description').AsString); Inc(nCount); aAuthorityID[nCount] := q.FieldByName('ID').AsInteger; q.Next; end; // while. end; // q.Eof. //********************** end ******************************* RecordStatus := False; end; procedure TSysServiceRecordForm.SetRecordStatus(const Value: boolean); begin ValueRecordStatus := Value; end; // SetRecordStatus. function TSysServiceRecordForm.GetRecordStatus: boolean; begin Result := ValueRecordStatus; end; // GetRecordStatus. procedure TSysServiceRecordForm.SetFormCaptionName(const Value: string); begin Caption := 'Service Record for '+Trim(Value); end; // SetFormCaptionName. function TSysServiceRecordForm.GetFormCaptionName: string; begin Result := Copy(Caption, 20, 20); end; // GetFormCaptionName. procedure TSysServiceRecordForm.SetUpMDF(const Value: string); begin edtUpMDF.Text := Trim(Value); end; // SetUpMDF. function TSysServiceRecordForm.GetUpMDF: string; begin Result := Trim(edtUpMDF.Text); end; // GetUpMDF. procedure TSysServiceRecordForm.SetUpEnd(const Value: string); begin edtUpEnd.Text := Trim(Value); end; // SetUpEnd. function TSysServiceRecordForm.GetUpEnd: string; begin Result := Trim(edtUpEnd.Text); end; // GetUpEnd. procedure TSysServiceRecordForm.SetDownMDF(const Value: string); begin edtDownMDF.Text := Trim(Value); end; // SetDownMDF. function TSysServiceRecordForm.GetDownMDF: string; begin Result := Trim(edtDownMDF.Text); end; // GetDownMDF. procedure TSysServiceRecordForm.SetDownEnd(const Value: string); begin edtDownEnd.Text := Trim(Value); end; // SetDownEnd. function TSysServiceRecordForm.GetDownEnd: string; begin Result := Trim(edtDownEnd.Text); end; // GetDownEnd. procedure TSysServiceRecordForm.SetLineLength(const Value: string); begin edtLineLength.Text := Trim(Value); end; // SetLineLength. function TSysServiceRecordForm.GetLineLength: string; begin Result := Trim(edtLineLength.Text); end; // GetLineLength. procedure TSysServiceRecordForm.SetCost(const Value: Currency); begin edtCost.Text := CurrToStr(Value); end; // SetCost. function TSysServiceRecordForm.GetCost: Currency; begin // Result := StrToCurr(edtCost.Text); Result := edtCost.Value; end; // GetCost. procedure TSysServiceRecordForm.SetCost100(const Value: Currency); begin // edtCost100.Text := CurrToStr(Value); edtCost100.Value := Value; end; // SetCost100. function TSysServiceRecordForm.GetCost100: Currency; begin // Result := StrToCurr(edtCost100.Text); Result := edtCost100.Value; end; // GetCost100. procedure TSysServiceRecordForm.SetInvoiced(const Value: Currency); begin // edtInvoiced.Text := CurrToStr(Value); edtInvoiced.Value := Value; end; // SetInvoiced. function TSysServiceRecordForm.GetInvoiced: Currency; begin // Result := StrToCurr(edtInvoiced.Text); Result := edtInvoiced.Value; end; // GetInvoiced. procedure TSysServiceRecordForm.SetNo(const Value: string); begin edtNo.Text := Trim(Value); end; // SetNo. function TSysServiceRecordForm.GetNo: string; begin Result := Trim(edtNo.Text); end; // GetNo. procedure TSysServiceRecordForm.SetPart(const Value: string); begin edtPart.Text := Trim(Value); end; // SetPart. function TSysServiceRecordForm.GetPart: string; begin Result := Trim(edtPart.Text); end; // GetPart. procedure TSysServiceRecordForm.SetDrawing(const Value: string); begin edtDrawing.Text := Trim(Value); end; // SetDrawing. function TSysServiceRecordForm.GetDrawing: string; begin Result := Trim(edtDrawing.Text); end; // GetDrawing. procedure TSysServiceRecordForm.SetMake(const Value: string); begin edtMake.Text := Trim(Value); end; // SetMake. function TSysServiceRecordForm.GetMake: string; begin Result := Trim(edtMake.Text); end; // GetMake. procedure TSysServiceRecordForm.SetCh(const Value: string); begin edtCh.Text := Trim(Value); end; // SetCh. function TSysServiceRecordForm.GetCh: string; begin Result := Trim(edtCh.Text); end; // GetCh. procedure TSysServiceRecordForm.SetMuxLink(const Value: string); begin // edtMuxLink.Text := Trim(MuxLink); end; // SetMuxLink. function TSysServiceRecordForm.GetMuxLink: string; begin // Result := Trim(edtMuxLink.Text); end; // GetMuxLink. procedure TSysServiceRecordForm.SetServiceLink(const Value: string); begin // edtServiceLink.Text := Trim(Value); end; // SetServiceLink. function TSysServiceRecordForm.GetServiceLink: string; begin // Result := Trim(edtServiceLink.Text); end; // GetServiceLink. procedure TSysServiceRecordForm.SetMux(const Value: string); begin edtMux.Text := Trim(Value); end; // SetMux. function TSysServiceRecordForm.GetMux: string; begin Result := Trim(edtMux.Text); end; // GetMux. procedure TSysServiceRecordForm.SetBearerID(const Value: integer); {var iCount : integer;} begin edtBearerID.Text := IntToStr(BearerID); { if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbBearerDescription.Items.Count - 1 do begin if (aBearerID[iCount] = Value) then begin cbBearerDescription.ItemIndex := iCount; Original_BearerID := sSelected; break; end; end; end;} end; // SetBearerID. function TSysServiceRecordForm.GetBearerID: integer; var sValue : string; begin sValue := Trim(edtBearerID.Text); if (Length(sValue) = 0) then Result := 0 else Result := StrToInt(sValue); { nSelected := cbBearerDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbBearerDescription.Text)) = 0) then Result := 0 else Result := aBearerID[nSelected]; } end; // GetBearerID. procedure TSysServiceRecordForm.SetBearerName(const Value: string); begin edtBearerName.Text := Trim(Value); end; // SetBearerName. function TSysServiceRecordForm.GetBearerName: string; begin Result := Trim(edtBearerName.Text); end; // GetBearerName. procedure TSysServiceRecordForm.SetSpeedID(const Value: integer); var sSelected : string; iCount : integer; begin { edtSpeedID.Text := IntToStr(Value); } if (Value >= 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbSpeedDescription.Items.Count - 1 do begin if (aSpeedID[iCount] = Value) then begin cbSpeedDescription.ItemIndex := iCount; // Original_SpeedID := sSelected; break; end; end; end; end; // SetSpeedID. function TSysServiceRecordForm.GetSpeedID: integer; var nSelected : integer; begin { sValue := Trim(edtSpeedID.Text); if (Length(sValue) = 0) then Result := 0 else Result := StrToInt(sValue); } nSelected := cbSpeedDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbSpeedDescription.Text)) = 0) then Result := 0 else Result := aSpeedID[nSelected]; end; // GetSpeedID. {procedure TSysServiceRecordForm.SetSpeedName(const Value: string); begin edtSpeedName.Text := Trim(Value); end; // SetSpeedName. } {function TSysServiceRecordForm.GetSpeedName: string; begin Result := Trim(edtSpeedName.Text); end; // GetSpeedName. } procedure TSysServiceRecordForm.SetModemTypeID(const Value: integer); var sSelected : string; iCount : integer; begin { edtModemTypeID.Text := IntToStr(Value); } if (Value >= 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbModemTypeDescription.Items.Count - 1 do begin if (aModemTypeID[iCount] = Value) then begin cbModemTypeDescription.ItemIndex := iCount; // Original_ModemTypeID := sSelected; break; end; end; end; end; // SetModemTypeID. function TSysServiceRecordForm.GetModemTypeID: integer; var nSelected : integer; begin { sValue := Trim(edtModemTypeID.Text); if (Length(sValue) = 0) then Result := 0 else Result := StrToInt(sValue); } nSelected := cbModemTypeDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbModemTypeDescription.Text)) = 0) then Result := 0 else Result := aModemTypeID[nSelected]; end; // GetModemTypeID. {procedure TSysServiceRecordForm.SetModemTypeName(const Value: string); begin edtModemTypeName.Text := Trim(Value); end; // SetModemTypeName. } {function TSysServiceRecordForm.GetModemTypeName: string; begin Result := Trim(edtModemTypeName.Text); end; // GetModemTypeName. } { // NOT USED - SO FAR... procedure TSysServiceRecordForm.SetLineID(const Value: integer); var sSelected : string; iCount : integer; begin // edtLineID.Text := IntToStr(Value); if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbLineDescription.Items.Count - 1 do begin if (aLineID[iCount] = Value) then begin cbLineDescription.ItemIndex := iCount; Original_LineID := sSelected; break; end; end; end; end; // SetLineID. } { // NOT USED - SO FAR... function TSysServiceRecordForm.GetLineID: integer; var nSelected : integer; begin // Result := StrToInt(edtLineID.Text); nSelected := cbLineDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbLineDescription.Text)) = 0) then Result := 0 else Result := aLineID[nSelected]; end; // GetLineID. } procedure TSysServiceRecordForm.SetLineName(const Value: string); begin // edtLineName.Text := Trim(Value); end; // SetLineName. function TSysServiceRecordForm.GetLineName: string; begin // Result := Trim(edtLineName.Text); end; // GetLineName. {procedure TSysServiceRecordForm.SetApplicationID(const Value: integer); var sSelected : string; iCount : integer; begin if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbApplicationDescription.Items.Count - 1 do begin if (aApplicationID[iCount] = Value) then begin cbApplicationDescription.ItemIndex := iCount; if SetServiceID_Original_Values then Original_ApplicationID := sSelected; break; end; end; end; end; // SetApplicationID. function TSysServiceRecordForm.GetApplicationID: integer; var nSelected : integer; begin nSelected := cbApplicationDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbApplicationDescription.Text)) = 0) then Result := 0 else Result := aApplicationID[nSelected]; end; // GetApplicationID. } procedure TSysServiceRecordForm.SetAuthorityID(const Value: integer); var sSelected : string; iCount : integer; begin { edtAuthorityID.Text := IntToStr(Value); } if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbAuthorityDescription.Items.Count - 1 do begin if (aAuthorityID[iCount] = Value) then begin cbAuthorityDescription.ItemIndex := iCount; // Original_AuthorityID := sSelected; break; end; end; end; end; // SetAuthorityID. function TSysServiceRecordForm.GetAuthorityID: integer; var nSelected : integer; begin { sValue := Trim(edtAuthorityID.Text); if (Length(sValue) = 0) then Result := 0 else Result := StrToInt(sValue); } nSelected := cbAuthorityDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbAuthorityDescription.Text)) = 0) then Result := 0 else Result := aAuthorityID[nSelected]; end; // GetAuthorityID. { // NOT USED - SO FAR... procedure TSysServiceRecordForm.SetAuthorityName(const Value: string); begin edtAuthorityName.Text := Trim(AuthorityName); end; // SetAuthorityName. } { // NOT USED - SO FAR... function TSysServiceRecordForm.GetAuthorityName: string; begin Result := Trim(edtAuthorityName.Text); end; // GetAuthorityName. } { // NOT USED - SO FAR... procedure TSysServiceRecordForm.SetVirtualCableID(const Value: integer); var sSelected : string; iCount : integer; begin // edtVirtualCableID.Text := IntToStr(Value); if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbVirtualCableDescription.Items.Count - 1 do begin if (aVirtualCableID[iCount] = Value) then begin cbVirtualCableDescription.ItemIndex := iCount; Original_VirtualCableID := sSelected; break; end; end; end; end; // SetVirtualCableID. } { // NOT USED - SO FAR... function TSysServiceRecordForm.GetVirtualCableID: integer; var nSelected : integer; begin // Result := StrToInt(edtVirtualCableID.Text); nSelected := cbVirtualCableDescription.ItemIndex; if (nSelected < 0) or (Length(Trim(cbVirtualCableDescription.Text)) = 0) then Result := 0 else Result := aVirtualCableID[nSelected]; end; // GetVirtualCableID. } { // NOT USED - SO FAR... procedure TSysServiceRecordForm.SetVirtualCableName(const Value: string); begin // edtVirtualCableName.Text := Trim(Value); end; // SetVirtualCableName. } { // NOT USED - SO FAR... function TSysServiceRecordForm.GetVirtualCableName: string; begin // Result := Trim(edtVirtualCableName.Text); end; // GetVirtualCableName. } procedure TSysServiceRecordForm.SetMnemonicID(const Value: integer); var sSelected : string; iCount : integer; begin if (Value > 0) then begin sSelected := IntToStr(Value); for iCount := 0 to cbMnemonic.Items.Count - 1 do begin if (aMnemonicID[iCount] = Value) then begin cbMnemonic.ItemIndex := iCount; break; end; end; end; end; // SetMnemonicID. function TSysServiceRecordForm.GetMnemonicID: integer; var nSelected : integer; begin nSelected := cbMnemonic.ItemIndex; if (nSelected < 0) or (Length(Trim(cbMnemonic.Text)) = 0) then Result := 0 else Result := aMnemonicID[nSelected]; end; // GetMnemonicID. procedure TSysServiceRecordForm.btnOkClick(Sender: TObject); // Save data to the parent Form. begin RecordStatus := True; Hide; end; // btnOkClick. procedure TSysServiceRecordForm.btnCancelClick(Sender: TObject); begin RecordStatus := False; Hide; end; // btnCancelClick. end.