Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 13 - Project CustLookup

Project Structure

CustLookup.dpr
program CustLookup;

uses
  Forms,
  LookupForm in 'LookupForm.pas' {FormLookup};

{$R *.RES}

begin
  Application.CreateForm(TFormLookup, FormLookup);
  Application.Run;
end.
LookupForm.pas
unit LookupForm;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  StdCtrls, Forms, DBCtrls, DB, DBGrids, DBTables, ExtCtrls, DBLookup,
  Grids, Mask;

type
  TFormLookup = class(TForm)
    ScrollBox: TScrollBox;
    Label1: TLabel;
    EditOrderNo: TDBEdit;
    Label3: TLabel;
    EditSaleDate: TDBEdit;
    Label4: TLabel;
    EditShipToContact: TDBEdit;
    Label5: TLabel;
    EditShipToAddr: TDBEdit;
    Label6: TLabel;
    EditShipToAddr2: TDBEdit;
    Label7: TLabel;
    EditShipToCity: TDBEdit;
    Label8: TLabel;
    EditShipToState: TDBEdit;
    Label9: TLabel;
    EditShipToZip: TDBEdit;
    Label10: TLabel;
    EditShipToCountry: TDBEdit;
    Label11: TLabel;
    EditPaymentMethod: TDBEdit;
    Label12: TLabel;
    EditItemsTotal: TDBEdit;
    DBNavigator: TDBNavigator;
    Panel1: TPanel;
    DataSourceOrders: TDataSource;
    Panel2: TPanel;
    QueryOrders: TQuery;
    Label13: TLabel;
    DataSourceCustomer: TDataSource;
    TableCustomers: TTable;
    DBLookupComboBox1: TDBLookupComboBox;
    DBText1: TDBText;
    Label2: TLabel;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FormLookup: TFormLookup;

implementation

{$R *.DFM}

end.
LookupForm.dfm
object FormLookup: TFormLookup
  Left = 221
  Top = 130
  Width = 495
  Height = 274
  ActiveControl = Panel1
  Caption = 'LookupCust'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 487
    Height = 35
    Align = alTop
    TabOrder = 0
    object DBNavigator: TDBNavigator
      Left = 16
      Top = 5
      Width = 104
      Height = 25
      DataSource = DataSourceOrders
      VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast]
      Ctl3D = False
      ParentCtl3D = False
      TabOrder = 0
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 35
    Width = 487
    Height = 212
    Align = alClient
    BevelInner = bvLowered
    BorderWidth = 4
    Caption = 'Panel2'
    TabOrder = 1
    object ScrollBox: TScrollBox
      Left = 6
      Top = 6
      Width = 475
      Height = 200
      HorzScrollBar.Margin = 6
      VertScrollBar.Margin = 6
      Align = alClient
      BorderStyle = bsNone
      TabOrder = 0
      object Label1: TLabel
        Left = 254
        Top = 25
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'OrderNo'
        FocusControl = EditOrderNo
      end
      object Label3: TLabel
        Left = 254
        Top = 53
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'SaleDate'
        FocusControl = EditSaleDate
      end
      object Label4: TLabel
        Left = 6
        Top = 75
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToContact'
        FocusControl = EditShipToContact
      end
      object Label5: TLabel
        Left = 6
        Top = 97
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToAddr1'
        FocusControl = EditShipToAddr
      end
      object Label6: TLabel
        Left = 254
        Top = 95
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToAddr2'
        FocusControl = EditShipToAddr2
      end
      object Label7: TLabel
        Left = 6
        Top = 121
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToCity'
        FocusControl = EditShipToCity
      end
      object Label8: TLabel
        Left = 254
        Top = 119
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToState'
        FocusControl = EditShipToState
      end
      object Label9: TLabel
        Left = 6
        Top = 145
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToZip'
        FocusControl = EditShipToZip
      end
      object Label10: TLabel
        Left = 254
        Top = 143
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToCountry'
        FocusControl = EditShipToCountry
      end
      object Label11: TLabel
        Left = 6
        Top = 169
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'PaymentMethod'
        FocusControl = EditPaymentMethod
      end
      object Label12: TLabel
        Left = 254
        Top = 167
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ItemsTotal'
        FocusControl = EditItemsTotal
      end
      object Label13: TLabel
        Left = 48
        Top = 27
        Width = 44
        Height = 13
        Caption = 'Customer'
      end
      object DBText1: TDBText
        Left = 102
        Top = 48
        Width = 65
        Height = 17
        DataField = 'CustNo'
        DataSource = DataSourceOrders
      end
      object Label2: TLabel
        Left = 56
        Top = 48
        Width = 35
        Height = 13
        Caption = 'CustNo'
      end
      object EditOrderNo: TDBEdit
        Left = 349
        Top = 22
        Width = 50
        Height = 21
        Color = clWindow
        DataField = 'OrderNo'
        DataSource = DataSourceOrders
        TabOrder = 0
      end
      object EditSaleDate: TDBEdit
        Left = 349
        Top = 50
        Width = 50
        Height = 21
        Color = clWindow
        DataField = 'SaleDate'
        DataSource = DataSourceOrders
        TabOrder = 1
      end
      object EditShipToContact: TDBEdit
        Left = 101
        Top = 72
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToContact'
        DataSource = DataSourceOrders
        TabOrder = 2
      end
      object EditShipToAddr: TDBEdit
        Left = 101
        Top = 94
        Width = 150
        Height = 21
        Color = clWindow
        DataField = 'ShipToAddr1'
        DataSource = DataSourceOrders
        TabOrder = 3
      end
      object EditShipToAddr2: TDBEdit
        Left = 349
        Top = 92
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToAddr2'
        DataSource = DataSourceOrders
        TabOrder = 4
      end
      object EditShipToCity: TDBEdit
        Left = 101
        Top = 118
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToCity'
        DataSource = DataSourceOrders
        TabOrder = 5
      end
      object EditShipToState: TDBEdit
        Left = 349
        Top = 116
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToState'
        DataSource = DataSourceOrders
        TabOrder = 6
      end
      object EditShipToZip: TDBEdit
        Left = 101
        Top = 142
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToZip'
        DataSource = DataSourceOrders
        TabOrder = 7
      end
      object EditShipToCountry: TDBEdit
        Left = 349
        Top = 140
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToCountry'
        DataSource = DataSourceOrders
        TabOrder = 8
      end
      object EditPaymentMethod: TDBEdit
        Left = 101
        Top = 166
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'PaymentMethod'
        DataSource = DataSourceOrders
        TabOrder = 9
      end
      object EditItemsTotal: TDBEdit
        Left = 349
        Top = 164
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ItemsTotal'
        DataSource = DataSourceOrders
        TabOrder = 10
      end
      object DBLookupComboBox1: TDBLookupComboBox
        Left = 101
        Top = 23
        Width = 169
        Height = 21
        Color = clWindow
        DataField = 'CustNo'
        DataSource = DataSourceOrders
        DropDownWidth = 300
        KeyField = 'CustNo'
        ListField = 'Company;CustNo'
        ListSource = DataSourceCustomer
        TabOrder = 11
      end
    end
  end
  object QueryOrders: TQuery
    Active = True
    DatabaseName = 'DBDEMOS'
    RequestLive = True
    SQL.Strings = (
      'Select'
      '  orders."OrderNo",'
      '  orders."CustNo",'
      '  orders."SaleDate",'
      '  orders."ShipToContact",'
      '  orders."ShipToAddr1",'
      '  orders."ShipToAddr2",'
      '  orders."ShipToCity",'
      '  orders."ShipToState",'
      '  orders."ShipToZip",'
      '  orders."ShipToCountry",'
      '  orders."PaymentMethod",'
      '  orders."ItemsTotal"'
      'From orders')
    Left = 132
    Top = 5
  end
  object DataSourceOrders: TDataSource
    DataSet = QueryOrders
    Left = 183
    Top = 5
  end
  object DataSourceCustomer: TDataSource
    DataSet = TableCustomers
    Left = 392
    Top = 5
  end
  object TableCustomers: TTable
    Active = True
    DatabaseName = 'DBDEMOS'
    IndexName = 'ByCompany'
    TableName = 'CUSTOMER.DB'
    Left = 336
    Top = 5
  end
end