⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unidacdemoform.pas

📁 devent UniDAC 2.003 include sources
💻 PAS
字号:
{$I DacDemo.inc}

unit UniDacDemoForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DemoForm, Menus, ImgList, StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin,
  DBAccess, UniDacVcl, Db, Uni, DAScript, UniScript,
{$IFDEF FPC}
  LResources,
{$ENDIF}
{$IFNDEF CLR}
  OracleUniProvider,
  SQLServerUniProvider,
  InterBaseUniProvider,
  MySQLUniProvider,
  PostgreSQLUniProvider
{$ELSE}
  System.ComponentModel,
  Devart.UniDac.Oracle.OracleUniProvider,
  Devart.UniDac.SQLServer.SQLServerUniProvider,
  Devart.UniDac.InterBase.InterBaseUniProvider,
  Devart.UniDac.MySQL.MySQLUniProvider,
  Devart.UniDac.PostgreSQL.PostgreSQLUniProvider
{$ENDIF}
  ;

type
  TUniDACForm = class(TDemoForm)
    UniConnection: TUniConnection;
    UniConnectDialog: TUniConnectDialog;
    scCreate_InterBase: TUniScript;
    scCreate_Oracle: TUniScript;
    scDrop: TUniScript;
    scCreate_SQLServer: TUniScript;
    scDrop_InterBase: TUniScript;
    scCreate_MySQL: TUniScript;
    scCreate_PgSQL: TUniScript;
    scDrop_PgSQL: TUniScript;
    procedure cbDebugClick(Sender: TObject);
    procedure lbAboutClick(Sender: TObject); override;
  private
    { Private declarations }
  protected
    function GetConnection: TCustomDAConnection; override;
    function ApplicationTitle: string; override;
    function ProductName: string; override;
    procedure RegisterDemos; override;
  public
    function ProductColor: TColor; override;
    procedure ExecCreateScript; override;
    procedure ExecDropScript; override;
  end;

var
  UniDACForm: TUniDACForm;

implementation

uses
{$IFNDEF LINUX}
{$IFDEF CRDBGRID}
  CRDBGrid,
{$ENDIF}
{$ENDIF}
{$IFNDEF FPC}
  Pictures,
{$ENDIF}
  CachedUpdates, FilterAndIndex, MasterDetail, Query, Sql, StoredProc,
  Table, Text, UpdateSQL, VTable, UniDacAbout;

{$IFNDEF FPC}
{$IFDEF CLR}
{$R *.nfm}
{$ENDIF}
{$IFDEF WIN32}
{$R *.dfm}
{$ENDIF}
{$IFDEF LINUX}
{$R *.xfm}
{$ENDIF}
{$ENDIF}

function TUniDACForm.GetConnection: TCustomDAConnection;
begin
  Result := UniConnection;
end;

function TUniDACForm.ProductColor: TColor;
begin
  Result := $00FF0000;
end;

procedure TUniDACForm.ExecCreateScript;
begin
  if UniConnection.ProviderName = 'Oracle' then
    scCreate_Oracle.Execute
  else
  if UniConnection.ProviderName = 'InterBase' then
    scCreate_InterBase.Execute
  else
  if UniConnection.ProviderName = 'SQL Server' then
    scCreate_SQLServer.Execute
  else
  if UniConnection.ProviderName = 'MySQL' then
    scCreate_MySQL.Execute
  else
  if UniConnection.ProviderName = 'PostgreSQL' then
    scCreate_PgSQL.Execute;
end;

procedure TUniDACForm.ExecDropScript;
begin
  if UniConnection.ProviderName = 'InterBase' then
    scDrop_InterBase.Execute
  else
  if UniConnection.ProviderName = 'PostgreSQL' then
    scDrop_PgSQL.Execute
  else
    scDrop.Execute;
end;

function TUniDACForm.ApplicationTitle: string;
begin
  Result := 'Universal Data Access Components demos';
end;

function TUniDACForm.ProductName: string;
begin
  Result := 'UniDAC';
end;

procedure TUniDACForm.RegisterDemos;
begin
  Demos.RegisterCategory('UniDAC Demo', 'UniDAC Demo');

  Demos.RegisterCategory('Working with components', 'Working with components'); // peculiarities of TreeView under Kilyx
{$IFNDEF LINUX}
{$IFDEF CRDBGRID}
  Demos.RegisterDemo('CRDBGrid', 'Using TCRDBGrid component', 'Demonstrates how to work with the TCRDBGrid component. Shows off the main TCRDBGrid features, like filtering, searching, stretching, using compound headers, and more.', 'Working with components',  TCRDBGridFrame, 1);
{$ENDIF}
{$ENDIF}
  Demos.RegisterDemo('Query', 'Using TUniQuery component', 'Demonstrates working with TUniQuery, which is one of the most useful UniDAC components. Includes many TUniQuery usage scenarios. Demonstrates how to execute queries in both standard and NonBlocking mode' +
    ' and how to edit data and export it to XML files. Note: This is a very good introductory demo. We recommend starting here when first becoming familiar with UniDAC.', 'Working with components', TQueryFrame, 2);
  Demos.RegisterDemo('Sql', 'Using TUniSQL component', 'Uses TUniSQL to execute SQL statements, and generate stored procedures calls and execute them. Demonstrates how to work with parameters in SQL.', 'Working with components', TSqlFrame, 3);
  Demos.RegisterDemo('StoredProc', 'Using TUniStoredProc component', 'Demonstrates working with the TUniStoredProc component. Lets the user generate and invoke different types of stored procedure calls. Users can choose the type of procedure to be generated, ' + 'specify parameter types, and execute the procedure with different parameter values. Shows how to use the TUniStoredProc object to get a DataSet from a stored procedure that returns a record set.', 'Working with components', TStoredProcFrame, 4);
  Demos.RegisterDemo('Table', 'Using TUniTable component', 'Demonstrates how to use TUniTable to work with data from a single table on the server without manually writing any SQL queries. Performs server-side data sorting and filtering and retrieves results for browsing and editing.', 'Working with components', TTableFrame, 5);
  Demos.RegisterDemo('UpdateSQL', 'Using TUniUpdateSQL component', 'Demonstrates using the TUniUpdateSQL component to customize update commands. Lets you optionally use TUniQuery objects for carrying out insert, delete, query, and update commands.', 'Working with components', TUpdateSQLFrame, 6);
  Demos.RegisterDemo('VirtualTable', 'Using TVirtualTable component', 'Demonstrates working with the TVirtualTable component. This sample shows how to fill virtual dataset with data from other datasets, filter data by a given criteria, locate specified records, perform file operations, and change data and table structure.', 'Working with components', TVirtualTableFrame, 7, 'VTable');

  Demos.RegisterCategory('General demos', 'General demos');                       // peculiarities of TreeView under Kilyx
  Demos.RegisterDemo('CachedUpdates', 'Cached updates, transaction control', 'Demonstrates how to perform the most important tasks of working with data in CachedUpdates mode, including highlighting uncommitted changes, managing transactions, and committing changes in a batch.', 'General demos', TCachedUpdatesFrame, 1);
  Demos.RegisterDemo('FilterAndIndex', 'Using Filter and IndexFieldNames', 'Demonstrates UniDAC''s local storage functionality. This sample shows how to perform local filtering, sorting and locating by multiple fields, including by calculated and lookup fields.', 'General demos', TFilterAndIndexFrame, 1);
  Demos.RegisterDemo('MasterDetail', 'Master/detail relationship', 'Uses UniDAC functionality to work with master/detail relationships. This sample shows how to use local master/detail functionality. Demonstrates different kinds of master/detail linking, inluding linking by SQL, by simple fields, and by calculated fields.', 'General demos', TMasterDetailFrame, 1);
{$IFNDEF FPC}
  Demos.RegisterDemo('Pictures', 'Working with BLOB field', 'Uses UniDAC functionality to work with graphics. The sample demonstrates how to retrieve binary data from database and display it on visual components. Sample also shows how to load and save pictures to files and to the database.', 'General demos', TPicturesFrame, 1);
{$ENDIF}
  Demos.RegisterDemo('Text', 'Working with the Text fields', 'Uses UniDAC functionality to work with text. The sample demonstrates how to retrieve text data from database and display it on visual components. Sample also shows how to load and save text to files and to the database.', 'General demos', TTextFrame, 1);

// Registering Supplementary Demo Projects

  Demos.RegisterCategory('Miscellaneous', '', -1, True);
{$IFDEF CLR}
  Demos.RegisterDemo('AspNet', 'An AspNet application', 'Uses UniDataAdapter to create a simple ASP .NET application.  This demo creates an ASP.NET application that lets you connect to a database and execute queries.' + '  Shows how to display query results in a DataGrid and send user changes back to the database.', 'Miscellaneous', nil, 1, '', True);
  Demos.RegisterDemo('WinForms', 'A WinForms application', 'Shows how to use UniDAC to create a  WinForm application.  This demo project creates a simple WinForms application and fills a data grid from an UniDataAdapter data source.', 'Miscellaneous', nil, 1, '', True);
{$ELSE}
  Demos.RegisterDemo('CBuilder', 'A demo for C++Builder', 'General demo project that shows how to create UniDAC-based applications with C++Builder. Lets you execute SQL scripts and work with result sets in a grid. This is one of the two UniDAC demos for C++Builder.', 'Miscellaneous', nil, 1, '', True);
  Demos.RegisterDemo('Dll', 'Working with DLLs', 'Demonstrates creating and loading DLLs for UniDAC-based projects. This demo project consists of two parts - an UniDll project that creates a DLL of a form that sends a query to the server and displays ' + 'its results, and an UniExe project that can be executed to display a form for loading and running this DLL.  Allows you to build a dll for one UniDAC-based project and load and test it from a separate application.', 'Miscellaneous', nil, 1, '', True);
  Demos.RegisterDemo('VirtualTableCB', 'Using VirtualTable in C++Builder', 'Demonstrates working with the TVirtualTable component. This sample shows how to fill virtual dataset with data from other datasets, filter data by a given criteria, locate specified ' + 'records, perform file operations, and change data and table structure. This is one of the two demo projects for C++Builder', 'Miscellaneous', nil, 1, '', True);
  Demos.RegisterCategory('', '', -1, True);
{$ENDIF}


(*
  Demos.RegisterCategory('TechnologySpecific', '', -1, True);
{$IFNDEF CLR}
  Demos.RegisterCategory('', '', -1, True);
{$ENDIF}
*)

{$IFNDEF CLR}
  Demos.RegisterCategory('ThirdParty', '', -1, True);
  Demos.RegisterDemo('FastReport', 'FastReport hint', 'Demonstrates how UniDAC can be used with FastReport components. This project consists of two parts. The first part is several packages that integrate UniDAC components into the FastReport editor.' + ' The second part is a demo application that lets you design and preview reports with UniDAC technology in the FastReport editor.', 'ThirdParty', nil, 1, '', True);
  Demos.RegisterCategory('', '', -1, True);
{$ENDIF}
end;

procedure TUniDACForm.cbDebugClick(Sender: TObject);
begin
  inherited;
  scCreate_Oracle.Debug := cbDebug.Checked;
  scCreate_InterBase.Debug := cbDebug.Checked;
  scCreate_SQLServer.Debug := cbDebug.Checked;
  scCreate_MySQL.Debug := cbDebug.Checked;
  scCreate_PgSQL.Debug := cbDebug.Checked;
  scDrop.Debug := cbDebug.Checked;
  scDrop_InterBase.Debug := cbDebug.Checked;
end;

procedure TUniDACForm.lbAboutClick(Sender: TObject);
begin
  inherited;
  UniDacAboutForm.ShowModal;
end;

{$IFDEF FPC}
initialization
  {$i UniDacDemoForm.lrs}
{$ENDIF}

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -