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

📄 mysqllinks.pas

📁 MYSQL 连接控件 MYSQL 连接控件
💻 PAS
字号:
//	Author:			Jacques Venter, jacques@scibit.com
//	Copyright:		1999,2000,2001,2002,2003,2004 SciBit - Scientific Bitware (Pty) Ltd
//	Version:			2004.1.1.0
//	History:       MasterDetail Field Editor
//						2000.0.1.1
//							First release
//
//   Licensing
//
//       Copyright (c) 1998-2004 SciBit - Scientific Bitware (Pty) Ltd
//       ALL RIGHTS RESERVED
//
//  The entire contents of this file is protected by South African and
//  International Copyright Laws. Unauthorized reproduction,
//  reverse-engineering, and distribution of all or any portion of
//  the code contained in this file is strictly prohibited and may
//  result in severe civil and criminal penalties and will be
//  prosecuted to the maximum extent possible under the law.
//
//  RESTRICTIONS
//
//  THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES
//  (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE
//  SECRETS OF SCIBIT (Pty) Ltd. THE REGISTERED DEVELOPER IS
//  LICENSED TO DISTRIBUTE THE SOURCECODE AND ALL
//  ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY.
//
//  THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED
//  FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE
//  COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE
//  AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT
//  AND PERMISSION FROM SciBit - Scientific Bitware (Pty) Ltd
//
//  CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON
//  ADDITIONAL RESTRICTIONS.
//
//*******************************************************************
unit MySQLLinks;

interface
{$I product.inc}
uses
	SysUtils, Classes, MySQLDataset, DB,
  {$IFDEF MSWINDOWS}
  Windows, Forms, Controls, StdCtrls, ExtCtrls, Buttons;
	{$ELSE}
	QGraphics, QForms, QControls, QStdCtrls, QExtCtrls, QButtons;
  {$ENDIF}

type

{ TLink Fields }

  TLinkFields = class(TForm)
    DetailList: TListBox;
    MasterList: TListBox;
    BindList: TListBox;
    Label30: TLabel;
    Label31: TLabel;
    Label2: TLabel;
    Bevel1: TBevel;
    AddButton: TButton;
    DeleteButton: TButton;
    ClearButton: TButton;
    Button1: TButton;
    procedure AddButtonClick(Sender: TObject);
    procedure UnLinkButtonClick(Sender: TObject);
    procedure DeleteButtonClick(Sender: TObject);
    procedure ClearButtonClick(Sender: TObject);
    procedure DetailListClick(Sender: TObject);
  private
    Dataset: TMySQLDatasetBase;
    procedure Initialize;
  public
    function Edit: string;
  end;

function EditMasterFields(ADataset: TMySQLDatasetBase): string;

implementation
{$IFDEF MSWINDOWS}
{$R *.dfm}
	uses Dialogs;
{$ELSE}
{$R *.xfm}
	uses QDialogs;
{$ENDIF}

function EditMasterFields(ADataset: TMySQLDatasetBase): string;
begin
	if not Assigned(ADataset.DataSource) and not Assigned(ADataset.DataSource.Dataset) then begin
  	MessageDlg('Please assign a Mastersource and Mastersource dataset',mtError,[mbOK],0);
     Exit;
  end;
	with TLinkFields.Create(nil) do
  try
     Dataset := ADataset;
  	Result := Edit;
  finally
  	Free;
  end;
end;

{ TLinkFields }

function TLinkFields.Edit;
begin
  Initialize;
  if ShowModal = mrOK then
  begin
    Result := BindList.Items.CommaText;
  end
  else
    Result := '';
end;

procedure TLinkFields.Initialize;
begin
  DetailList.Items.CommaText := Dataset.FieldList.CommaText;
  BindList.Items.CommaText := Dataset.GetMasterFields;
	if Assigned(Dataset.DataSource) and Assigned(Dataset.DataSource.Dataset) then MasterList.Items.CommaText := Dataset.GetDataSource.DataSet.FieldList.CommaText;
end;

procedure TLinkFields.AddButtonClick(Sender: TObject);
begin
	if (DetailList.ItemIndex<0) or (MasterList.ItemIndex<0) then Exit;
  BindList.Items.Add(DetailList.Items[DetailList.ItemIndex]+'='+MasterList.Items[MasterList.ItemIndex]);
end;

procedure TLinkFields.UnLinkButtonClick(Sender: TObject);
begin
	MasterList.Items.Clear;
  BindList.Items.Clear;
	MasterList.ItemIndex := -1;
end;

procedure TLinkFields.DeleteButtonClick(Sender: TObject);
begin
	if (BindList.ItemIndex<0) then Exit;
  BindList.Items.Delete(BindList.ItemIndex);
end;

procedure TLinkFields.ClearButtonClick(Sender: TObject);
begin
  BindList.Items.Clear;
end;

procedure TLinkFields.DetailListClick(Sender: TObject);
begin
	if (DetailList.ItemIndex<0) then Exit;
  MasterList.ItemIndex := MasterList.Items.IndexOf(DetailList.Items[DetailList.ItemIndex])
end;

end.

⌨️ 快捷键说明

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