Marco Web Center

[an error occurred while processing this directive]

Home: Code Repository: Mastering Delphi 5

Project THINPLUS

Project Structure


THINPLUS.DPR

program ThinPlus;

uses
  Forms,
  ThinForm in 'ThinForm.pas' {ClientForm},
  QueForm in 'QueForm.pas' {FormQuery};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TClientForm, ClientForm);
  Application.CreateForm(TFormQuery, FormQuery);
  Application.Run;
end.

THINFORM.PAS

unit ThinForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DBClient, MConnect, SConnect, Db, Grids, DBGrids, StdCtrls, ObjBrkr;

type
  TClientForm = class(TForm)
    Connection: TSocketConnection;
    cds: TClientDataSet;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ButtonFetch: TButton;
    Button1: TButton;
    CheckBox1: TCheckBox;
    Edit2: TEdit;
    Edit3: TEdit;
    cdsDet: TClientDataSet;
    DataSource2: TDataSource;
    DBGrid2: TDBGrid;
    cdsCustNo: TFloatField;
    cdsCompany: TStringField;
    cdsAddr1: TStringField;
    cdsAddr2: TStringField;
    cdsCity: TStringField;
    cdsState: TStringField;
    cdsZip: TStringField;
    cdsCountry: TStringField;
    cdsPhone: TStringField;
    cdsFAX: TStringField;
    cdsTaxRate: TFloatField;
    cdsContact: TStringField;
    cdsLastInvoiceDate: TDateTimeField;
    cdsTableOrders: TDataSetField;
    Button2: TButton;
    procedure ButtonFetchClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure ConnectionAfterConnect(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ClientForm: TClientForm;

implementation

uses QueForm;

{$R *.DFM}

procedure TClientForm.ButtonFetchClick(Sender: TObject);
begin
  ButtonFetch.Caption := IntToStr (cds.GetNextPacket);
end;

procedure TClientForm.Button1Click(Sender: TObject);
begin
  cds.ApplyUpdates (-1);
end;

procedure TClientForm.CheckBox1Click(Sender: TObject);
begin
  cds.Active := Checkbox1.Checked;
  cdsDet.Active := Checkbox1.Checked;
  Connection.Connected := Checkbox1.Checked;
end;

procedure TClientForm.ConnectionAfterConnect(Sender: TObject);
begin
  Connection.AppServer.Login (Edit2.Text, Edit3.Text);
end;

procedure TClientForm.Button2Click(Sender: TObject);
begin
  FormQuery.Show;
end;

end.

QUEFORM.PAS

unit QueForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, StdCtrls, Grids, DBGrids, DBClient;

type
  TFormQuery = class(TForm)
    cdsQuery: TClientDataSet;
    DBGrid1: TDBGrid;
    EditParam: TEdit;
    btnParam: TButton;
    DataSource1: TDataSource;
    Label1: TLabel;
    procedure btnParamClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormQuery: TFormQuery;

implementation

uses ThinForm;

{$R *.DFM}

procedure TFormQuery.btnParamClick(Sender: TObject);
begin
  cdsQuery.Close;
  cdsQuery.Params[0].AsString := EditParam.Text;
  cdsQuery.Open;
  Caption := 'Data sent at ' + TimeToStr (
    TDateTime (cdsQuery.GetOptionalParam('Time')));
  Label1.Caption := 'Param ' +
    cdsQuery.GetOptionalParam('Param');
end;

end.

THINFORM.DFM

object ClientForm: TClientForm
  Left = 265
  Top = 160
  Width = 510
  Height = 465
  Caption = 'ThinPlus'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object DBGrid1: TDBGrid
    Left = 32
    Top = 72
    Width = 457
    Height = 185
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object ButtonFetch: TButton
    Left = 280
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Fetch'
    TabOrder = 1
    OnClick = ButtonFetchClick
  end
  object Button1: TButton
    Left = 368
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Apply'
    TabOrder = 2
    OnClick = Button1Click
  end
  object CheckBox1: TCheckBox
    Left = 152
    Top = 16
    Width = 97
    Height = 17
    Caption = 'Connect'
    TabOrder = 3
    OnClick = CheckBox1Click
  end
  object Edit2: TEdit
    Left = 16
    Top = 8
    Width = 121
    Height = 21
    TabOrder = 4
    Text = 'marco'
  end
  object Edit3: TEdit
    Left = 16
    Top = 32
    Width = 121
    Height = 21
    TabOrder = 5
    Text = 'marco'
  end
  object DBGrid2: TDBGrid
    Left = 32
    Top = 264
    Width = 457
    Height = 161
    DataSource = DataSource2
    TabOrder = 6
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object Button2: TButton
    Left = 320
    Top = 40
    Width = 75
    Height = 25
    Caption = 'Query'
    TabOrder = 7
    OnClick = Button2Click
  end
  object Connection: TSocketConnection
    ServerGUID = '{E31849A9-4A82-11D3-B9F1-00000100A27B}'
    ServerName = 'AppSPlus.AppServerPlus'
    AfterConnect = ConnectionAfterConnect
    Address = '127.0.0.1'
    Left = 56
    Top = 112
  end
  object cds: TClientDataSet
    Aggregates = <>
    AggregatesActive = True
    PacketRecords = 10
    Params = <>
    ProviderName = 'ProviderCustomer'
    RemoteServer = Connection
    Left = 144
    Top = 104
    object cdsCustNo: TFloatField
      FieldName = 'CustNo'
    end
    object cdsCompany: TStringField
      FieldName = 'Company'
      Size = 30
    end
    object cdsAddr1: TStringField
      FieldName = 'Addr1'
      Size = 30
    end
    object cdsAddr2: TStringField
      FieldName = 'Addr2'
      Size = 30
    end
    object cdsCity: TStringField
      FieldName = 'City'
      Size = 15
    end
    object cdsState: TStringField
      FieldName = 'State'
    end
    object cdsZip: TStringField
      FieldName = 'Zip'
      Size = 10
    end
    object cdsCountry: TStringField
      FieldName = 'Country'
    end
    object cdsPhone: TStringField
      FieldName = 'Phone'
      Size = 15
    end
    object cdsFAX: TStringField
      FieldName = 'FAX'
      Size = 15
    end
    object cdsTaxRate: TFloatField
      FieldName = 'TaxRate'
    end
    object cdsContact: TStringField
      FieldName = 'Contact'
    end
    object cdsLastInvoiceDate: TDateTimeField
      FieldName = 'LastInvoiceDate'
    end
    object cdsTableOrders: TDataSetField
      FieldName = 'TableOrders'
      IncludeObjectField = False
    end
  end
  object DataSource1: TDataSource
    DataSet = cds
    Left = 232
    Top = 104
  end
  object cdsDet: TClientDataSet
    Aggregates = <>
    DataSetField = cdsTableOrders
    FieldDefs = <
      item
        Name = 'OrderNo'
        DataType = ftFloat
      end
      item
        Name = 'CustNo'
        Attributes = [faRequired]
        DataType = ftFloat
      end
      item
        Name = 'SaleDate'
        DataType = ftDateTime
      end
      item
        Name = 'ShipDate'
        DataType = ftDateTime
      end
      item
        Name = 'EmpNo'
        Attributes = [faRequired]
        DataType = ftInteger
      end
      item
        Name = 'ShipToContact'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'ShipToAddr1'
        DataType = ftString
        Size = 30
      end
      item
        Name = 'ShipToAddr2'
        DataType = ftString
        Size = 30
      end
      item
        Name = 'ShipToCity'
        DataType = ftString
        Size = 15
      end
      item
        Name = 'ShipToState'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'ShipToZip'
        DataType = ftString
        Size = 10
      end
      item
        Name = 'ShipToCountry'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'ShipToPhone'
        DataType = ftString
        Size = 15
      end
      item
        Name = 'ShipVIA'
        DataType = ftString
        Size = 7
      end
      item
        Name = 'PO'
        DataType = ftString
        Size = 15
      end
      item
        Name = 'Terms'
        DataType = ftString
        Size = 6
      end
      item
        Name = 'PaymentMethod'
        DataType = ftString
        Size = 7
      end
      item
        Name = 'ItemsTotal'
        DataType = ftCurrency
      end
      item
        Name = 'TaxRate'
        DataType = ftFloat
      end
      item
        Name = 'Freight'
        DataType = ftCurrency
      end
      item
        Name = 'AmountPaid'
        DataType = ftCurrency
      end>
    IndexDefs = <
      item
        Name = 'CustIndex'
        Fields = 'CustNo'
      end>
    Params = <>
    StoreDefs = True
    Left = 144
    Top = 168
  end
  object DataSource2: TDataSource
    DataSet = cdsDet
    Left = 232
    Top = 176
  end
end

QUEFORM.DFM

object FormQuery: TFormQuery
  Left = 426
  Top = 341
  Width = 490
  Height = 288
  Caption = 'FormQuery'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 288
    Top = 24
    Width = 32
    Height = 13
    Caption = 'Label1'
  end
  object DBGrid1: TDBGrid
    Left = 40
    Top = 48
    Width = 417
    Height = 201
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object EditParam: TEdit
    Left = 40
    Top = 16
    Width = 121
    Height = 21
    TabOrder = 1
    Text = 'US'
  end
  object btnParam: TButton
    Left = 184
    Top = 16
    Width = 75
    Height = 25
    Caption = 'Apply Param'
    TabOrder = 2
    OnClick = btnParamClick
  end
  object cdsQuery: TClientDataSet
    Aggregates = <>
    Params = <
      item
        DataType = ftString
        Name = 'Country'
        ParamType = ptUnknown
        Value = 'US'
      end>
    ProviderName = 'ProviderQuery'
    RemoteServer = ClientForm.Connection
    Left = 304
    Top = 16
  end
  object DataSource1: TDataSource
    DataSet = cdsQuery
    Left = 376
    Top = 16
  end
end