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 5

Project ORDERS

Project Structure


ORDERS.DPR

program Orders;

uses
  Forms,
  OrderF in 'OrderF.pas' {OrdersForm};

{$R *.RES}

begin
  Application.CreateForm(TOrdersForm, OrdersForm);
  Application.Run;
end.

ORDERF.PAS

unit OrderF;

interface

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

type
  TOrdersForm = 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;
    DBGrid1: TDBGrid;
    DBNavigator: TDBNavigator;
    Panel1: TPanel;
    DataSource1: TDataSource;
    Panel2: TPanel;
    Panel3: TPanel;
    Query1: TQuery;
    Query2: TQuery;
    DataSource2: TDataSource;
    Label13: TLabel;
    DataSource3: TDataSource;
    Table1: TTable;
    DBLookupComboBox1: TDBLookupComboBox;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  OrdersForm: TOrdersForm;

implementation

{$R *.DFM}

end.

ORDERF.DFM

object OrdersForm: TOrdersForm
  Left = 219
  Top = 144
  Width = 495
  Height = 398
  ActiveControl = Panel1
  Caption = 'Orders (with three data sources)'
  Font.Color = clBlack
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  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 = DataSource1
      VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast]
      Flat = False
      Ctl3D = False
      ParentCtl3D = False
      TabOrder = 0
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 35
    Width = 487
    Height = 206
    Align = alTop
    BevelInner = bvLowered
    BorderWidth = 4
    Caption = 'Panel2'
    TabOrder = 1
    object ScrollBox: TScrollBox
      Left = 6
      Top = 6
      Width = 475
      Height = 194
      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 EditOrderNo: TDBEdit
        Left = 349
        Top = 22
        Width = 50
        Height = 21
        DataField = 'OrderNo'
        DataSource = DataSource1
        MaxLength = 0
        TabOrder = 0
      end
      object EditSaleDate: TDBEdit
        Left = 349
        Top = 50
        Width = 50
        Height = 21
        DataField = 'SaleDate'
        DataSource = DataSource1
        MaxLength = 0
        TabOrder = 1
      end
      object EditShipToContact: TDBEdit
        Left = 101
        Top = 72
        Width = 100
        Height = 21
        DataField = 'ShipToContact'
        DataSource = DataSource1
        MaxLength = 20
        TabOrder = 2
      end
      object EditShipToAddr: TDBEdit
        Left = 101
        Top = 94
        Width = 150
        Height = 21
        DataField = 'ShipToAddr1'
        DataSource = DataSource1
        MaxLength = 30
        TabOrder = 3
      end
      object EditShipToAddr2: TDBEdit
        Left = 349
        Top = 92
        Width = 100
        Height = 21
        DataField = 'ShipToAddr2'
        DataSource = DataSource1
        MaxLength = 30
        TabOrder = 4
      end
      object EditShipToCity: TDBEdit
        Left = 101
        Top = 118
        Width = 100
        Height = 21
        DataField = 'ShipToCity'
        DataSource = DataSource1
        MaxLength = 15
        TabOrder = 5
      end
      object EditShipToState: TDBEdit
        Left = 349
        Top = 116
        Width = 100
        Height = 21
        DataField = 'ShipToState'
        DataSource = DataSource1
        MaxLength = 20
        TabOrder = 6
      end
      object EditShipToZip: TDBEdit
        Left = 101
        Top = 142
        Width = 100
        Height = 21
        DataField = 'ShipToZip'
        DataSource = DataSource1
        MaxLength = 10
        TabOrder = 7
      end
      object EditShipToCountry: TDBEdit
        Left = 349
        Top = 140
        Width = 100
        Height = 21
        DataField = 'ShipToCountry'
        DataSource = DataSource1
        MaxLength = 20
        TabOrder = 8
      end
      object EditPaymentMethod: TDBEdit
        Left = 101
        Top = 166
        Width = 100
        Height = 21
        DataField = 'PaymentMethod'
        DataSource = DataSource1
        MaxLength = 7
        TabOrder = 9
      end
      object EditItemsTotal: TDBEdit
        Left = 349
        Top = 164
        Width = 100
        Height = 21
        DataField = 'ItemsTotal'
        DataSource = DataSource1
        MaxLength = 0
        TabOrder = 10
      end
      object DBLookupComboBox1: TDBLookupComboBox
        Left = 101
        Top = 23
        Width = 169
        Height = 21
        DataField = 'CustNo'
        DataSource = DataSource1
        DropDownWidth = 300
        KeyField = 'CustNo'
        ListField = 'Company;CustNo'
        ListSource = DataSource3
        TabOrder = 11
      end
    end
  end
  object Panel3: TPanel
    Left = 0
    Top = 241
    Width = 487
    Height = 130
    Align = alClient
    BevelInner = bvLowered
    BorderWidth = 4
    Caption = 'Panel3'
    TabOrder = 2
    object DBGrid1: TDBGrid
      Left = 6
      Top = 6
      Width = 475
      Height = 118
      Align = alClient
      BorderStyle = bsNone
      DataSource = DataSource2
      TabOrder = 0
      TitleFont.Color = clBlack
      TitleFont.Height = -11
      TitleFont.Name = 'MS Sans Serif'
      TitleFont.Style = []
    end
  end
  object Query1: 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 Query2: TQuery
    Active = True
    DatabaseName = 'DBDEMOS'
    DataSource = DataSource1
    Params.Data = {01000100074F726465724E6F000608000000000000588F400000}
    RequestLive = True
    SQL.Strings = (
      'Select'
      '  items."OrderNo",'
      '  items."ItemNo",'
      '  items."PartNo",'
      '  items."Qty"'
      'From items'
      'Where'
      '  "items"."OrderNo" =:"OrderNo"')
    Left = 234
    Top = 5
  end
  object DataSource1: TDataSource
    DataSet = Query1
    Left = 183
    Top = 5
  end
  object DataSource2: TDataSource
    DataSet = Query2
    Left = 285
    Top = 5
  end
  object DataSource3: TDataSource
    DataSet = Table1
    Left = 392
    Top = 5
  end
  object Table1: TTable
    Active = True
    DatabaseName = 'DBDEMOS'
    IndexName = 'ByCompany'
    TableName = 'CUSTOMER.DB'
    Left = 336
    Top = 5
  end
end