Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 6

Chapter 13 - 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;
    dsOrders: TDataSource;
    Panel2: TPanel;
    Panel3: TPanel;
    QueryOrders: TQuery;
    QueryItems: TQuery;
    dsItems: TDataSource;
    Label2: TLabel;
    DBEdit1: TDBEdit;
  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 m/d query'
  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 = dsOrders
      VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast]
      Ctl3D = False
      ParentCtl3D = False
      TabOrder = 0
    end
  end
  object Panel2: TPanel
    Left = 0
    Top = 35
    Width = 487
    Height = 174
    Align = alTop
    BevelInner = bvLowered
    BorderWidth = 4
    Caption = 'Panel2'
    TabOrder = 1
    object ScrollBox: TScrollBox
      Left = 6
      Top = 6
      Width = 475
      Height = 162
      HorzScrollBar.Margin = 6
      VertScrollBar.Margin = 6
      Align = alClient
      BorderStyle = bsNone
      TabOrder = 0
      object Label1: TLabel
        Left = 254
        Top = 9
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'OrderNo'
        FocusControl = EditOrderNo
      end
      object Label3: TLabel
        Left = 254
        Top = 37
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'SaleDate'
        FocusControl = EditSaleDate
      end
      object Label4: TLabel
        Left = 6
        Top = 43
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToContact'
        FocusControl = EditShipToContact
      end
      object Label5: TLabel
        Left = 6
        Top = 65
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToAddr1'
        FocusControl = EditShipToAddr
      end
      object Label6: TLabel
        Left = 254
        Top = 63
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToAddr2'
        FocusControl = EditShipToAddr2
      end
      object Label7: TLabel
        Left = 6
        Top = 89
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToCity'
        FocusControl = EditShipToCity
      end
      object Label8: TLabel
        Left = 254
        Top = 87
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToState'
        FocusControl = EditShipToState
      end
      object Label9: TLabel
        Left = 6
        Top = 113
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToZip'
        FocusControl = EditShipToZip
      end
      object Label10: TLabel
        Left = 254
        Top = 111
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ShipToCountry'
        FocusControl = EditShipToCountry
      end
      object Label11: TLabel
        Left = 6
        Top = 137
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'PaymentMethod'
        FocusControl = EditPaymentMethod
      end
      object Label12: TLabel
        Left = 254
        Top = 135
        Width = 89
        Height = 13
        Alignment = taRightJustify
        AutoSize = False
        Caption = 'ItemsTotal'
        FocusControl = EditItemsTotal
      end
      object Label2: TLabel
        Left = 57
        Top = 20
        Width = 35
        Height = 13
        Caption = 'CustNo'
        FocusControl = DBEdit1
      end
      object EditOrderNo: TDBEdit
        Left = 349
        Top = 6
        Width = 50
        Height = 21
        Color = clWindow
        DataField = 'OrderNo'
        DataSource = dsOrders
        TabOrder = 0
      end
      object EditSaleDate: TDBEdit
        Left = 349
        Top = 34
        Width = 50
        Height = 21
        Color = clWindow
        DataField = 'SaleDate'
        DataSource = dsOrders
        TabOrder = 1
      end
      object EditShipToContact: TDBEdit
        Left = 101
        Top = 40
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToContact'
        DataSource = dsOrders
        TabOrder = 2
      end
      object EditShipToAddr: TDBEdit
        Left = 101
        Top = 62
        Width = 150
        Height = 21
        Color = clWindow
        DataField = 'ShipToAddr1'
        DataSource = dsOrders
        TabOrder = 3
      end
      object EditShipToAddr2: TDBEdit
        Left = 349
        Top = 60
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToAddr2'
        DataSource = dsOrders
        TabOrder = 4
      end
      object EditShipToCity: TDBEdit
        Left = 101
        Top = 86
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToCity'
        DataSource = dsOrders
        TabOrder = 5
      end
      object EditShipToState: TDBEdit
        Left = 349
        Top = 84
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToState'
        DataSource = dsOrders
        TabOrder = 6
      end
      object EditShipToZip: TDBEdit
        Left = 101
        Top = 110
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToZip'
        DataSource = dsOrders
        TabOrder = 7
      end
      object EditShipToCountry: TDBEdit
        Left = 349
        Top = 108
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ShipToCountry'
        DataSource = dsOrders
        TabOrder = 8
      end
      object EditPaymentMethod: TDBEdit
        Left = 101
        Top = 134
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'PaymentMethod'
        DataSource = dsOrders
        TabOrder = 9
      end
      object EditItemsTotal: TDBEdit
        Left = 349
        Top = 132
        Width = 100
        Height = 21
        Color = clWindow
        DataField = 'ItemsTotal'
        DataSource = dsOrders
        TabOrder = 10
      end
      object DBEdit1: TDBEdit
        Left = 102
        Top = 16
        Width = 64
        Height = 21
        Color = clWindow
        DataField = 'CustNo'
        DataSource = dsOrders
        TabOrder = 11
      end
    end
  end
  object Panel3: TPanel
    Left = 0
    Top = 209
    Width = 487
    Height = 162
    Align = alClient
    BevelInner = bvLowered
    BorderWidth = 4
    Caption = 'Panel3'
    TabOrder = 2
    object DBGrid1: TDBGrid
      Left = 6
      Top = 6
      Width = 475
      Height = 150
      Align = alClient
      BorderStyle = bsNone
      DataSource = dsItems
      TabOrder = 0
      TitleFont.Charset = DEFAULT_CHARSET
      TitleFont.Color = clBlack
      TitleFont.Height = -11
      TitleFont.Name = 'MS Sans Serif'
      TitleFont.Style = []
    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 QueryItems: TQuery
    Active = True
    DatabaseName = 'DBDEMOS'
    DataSource = dsOrders
    RequestLive = True
    SQL.Strings = (
      'Select'
      '  items."OrderNo",'
      '  items."ItemNo",'
      '  items."PartNo",'
      '  items."Qty"'
      'From items'
      'Where'
      '  "items"."OrderNo" =:"OrderNo"')
    Left = 234
    Top = 5
    ParamData = <
      item
        DataType = ftFloat
        Name = 'OrderNo'
        ParamType = ptUnknown
      end>
  end
  object dsOrders: TDataSource
    DataSet = QueryOrders
    Left = 183
    Top = 5
  end
  object dsItems: TDataSource
    DataSet = QueryItems
    Left = 285
    Top = 5
  end
end