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

📄 impdlgadof.pas

📁 EMSAdvanced Export和Import工具
💻 PAS
字号:
unit ImpDlgADOF;

{$I demo.inc}

interface

uses
  Forms, Db, DBTables, Grids, DBGrids, StdCtrls, Classes, Controls, ExtCtrls,
  QImport2, ComCtrls, ADO_QImport2Wizard;

type
  TfmImpDlgADO = class(TForm)
    ADO_QImportWizard1: TADO_QImport2Wizard;
    Table1: TTable;
    Panel1: TPanel;
    btImport: TButton;
    DataSource1: TDataSource;
    chbUseBeforePost: TCheckBox;
    Button1: TButton;
    pcDestinations: TPageControl;
    tshDataSet: TTabSheet;
    dgrDataSet: TDBGrid;
    tshDBGrid: TTabSheet;
    tshListView: TTabSheet;
    tshStringGrid: TTabSheet;
    DBGrid: TDBGrid;
    ListView: TListView;
    StringGrid: TStringGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure btImportClick(Sender: TObject);
    procedure QImportWizard1AfterImport(Sender: TObject);
    procedure QImportWizard1BeforePost(Sender: TObject; Row: TQImportRow;
      var Accept: Boolean);
    procedure Button1Click(Sender: TObject);
    procedure pcDestinationsChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmImpDlgADO: TfmImpDlgADO;

implementation

uses SysUtils;

{$R *.DFM}

procedure TfmImpDlgADO.FormCreate(Sender: TObject);
begin
  Table1.DatabaseName := ExtractFilePath(Application.ExeName) + {$IFNDEF DEMO_EXE}'..\..\' +{$ENDIF} 'data\';
  Table1.TableName := 'country.db';
  Table1.Active := True;

  StringGrid.Cells[0, 0] := 'Name of Country';
  StringGrid.Cells[1, 0] := 'Capital of Country';
  StringGrid.Cells[2, 0] := 'Continent of Country';
  StringGrid.Cells[3, 0] := 'Area of Country';
  StringGrid.Cells[4, 0] := 'Population of Country';
end;

procedure TfmImpDlgADO.FormDestroy(Sender: TObject);
begin
  Table1.Active := False;
end;

procedure TfmImpDlgADO.btImportClick(Sender: TObject);
begin
  ADO_QImportWizard1.Execute;
end;

procedure TfmImpDlgADO.QImportWizard1AfterImport(Sender: TObject);
begin
  Table1.Close;
  Table1.Open;
end;

procedure TfmImpDlgADO.QImportWizard1BeforePost(Sender: TObject;
  Row: TQImportRow; var Accept: Boolean);
var
  i: integer;
begin
  if chbUseBeforePost.Checked then
    for i := 0 to Row.Count - 1 do
      if (Row[i].Name = 'Name') and (Row[i].Value = 'Argentina') then begin
        Accept := false;
        Exit;
      end;
end;

procedure TfmImpDlgADO.Button1Click(Sender: TObject);
var
  i, j: integer;
begin
  if (pcDestinations.ActivePage = tshDataSet) or
     (pcDestinations.ActivePage = tshDBGrid) then begin
   Table1.Close;
   try
     Table1.Exclusive := true;
     try
       Table1.EmptyTable;
     finally
       Table1.Exclusive := false;
     end;
   finally
     Table1.Open;
   end;
  end
  else if pcDestinations.ActivePage = tshListView then begin
    ListView.Items.BeginUpdate;
    try
      ListView.Items.Clear;
    finally
      ListView.Items.EndUpdate;
    end;
  end
  else if pcDestinations.ActivePage = tshStringGrid then begin
    for i := 1 to StringGrid.RowCount - 1 do
      for j := 0 to StringGrid.ColCount - 1 do
        StringGrid.Cells[j, i] := EmptyStr;
  end;
end;

procedure TfmImpDlgADO.pcDestinationsChange(Sender: TObject);
begin
  if pcDestinations.ActivePage = tshDataSet then
    ADO_QImportWizard1.ImportDestination := qidDataSet
  else if pcDestinations.ActivePage = tshDBGrid then
    ADO_QImportWizard1.ImportDestination := qidDBGrid
  else if pcDestinations.ActivePage = tshListView then
    ADO_QImportWizard1.ImportDestination := qidListView
  else if pcDestinations.ActivePage = tshStringGrid then
    ADO_QImportWizard1.ImportDestination := qidStringGrid;
end;

end.

⌨️ 快捷键说明

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