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

📄 lookdatabaseform.~pas

📁 求是科技出版的《Delphi串口通信工程开发实例导航》所有的源代码。是一本很好的书。拿出来与大家共享。
💻 ~PAS
字号:
unit LookDatabaseForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DialogBaseForm, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids, Db, DBTables,
  ADODB;//使用其中的数据库

type
  TfrmLookDatabase = class(TfrmDialogBase)
    Panel2: TPanel;
    Panel3: TPanel;
    Label1: TLabel;
    cbxTableName: TComboBox;
    dsLook: TDataSource;
    DBGrid1: TDBGrid;
    tblTempCardUse: TADOTable;
    tblFixCardUse: TADOTable;
    tblFeeMaintain: TADOTable;
    tblGetFee: TADOTable;
    tblShiftRecord: TADOTable;
    procedure cbxTableNameChange(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmLookDatabase: TfrmLookDatabase;

implementation

uses
    GlobalUnit;
{$R *.DFM}

procedure TfrmLookDatabase.cbxTableNameChange(Sender: TObject);
var
    mConnection : TADOConnection;
begin
    //inherited;
    //======查看数据表有关的操作
    mConnection := GetRemoteConnection();
    if mConnection = nil then mConnection := GetLocalConnection();
    if mConnection = nil then
    begin

    end;

    with self do
    begin
        case cbxTableName.ItemIndex of
        0 : begin       //临时用户进出情况
            if tblTempCardUse.Active = False then
            begin
                tblTempCardUse.Connection := mConnection;
                tblTempCardUse.TableName := 'temp_card_use';
                try
                    tblTempCardUse.Active := True;
                    dsLook.DataSet := tblTempCardUse;
                except

                end;
            end;
            dsLook.DataSet := tblTempCardUse;
        end;

        1 : begin    //月票用户出入情况
            if tblFixCardUse.Active = False then
            begin
                tblFixCardUse.Connection := mConnection;
                tblFixCardUse.TableName := 'fix_card_use';
                try
                    tblFixCardUse.Active := True;
                except

                end;
            end;
            dsLook.DataSet := tblFixCardUse;
        end;

        2 : begin    //费用维护
            if tblFeeMaintain.Active = False then
            begin
                tblFeeMaintain.Connection := mConnection;
                tblFeeMaintain.TableName := 'fee_maintain';
                try
                    tblFeeMaintain.Active := True;
                except

                end;
            end;
            dsLook.DataSet := tblFeeMaintain;
        end;

        3 : begin    //收费记录
            if tblGetFee.Active = False then
            begin
                tblGetFee.Connection := mConnection;
                tblGetFee.TableName := 'get_fee';
                try
                    tblGetFee.Active := True;

                except

                end;
            end;
            dsLook.DataSet := tblGetFee;
        end;

        4 : begin    //上下岗记录
            if tblShiftRecord.Active = False then
            begin
                tblShiftRecord.Connection := mConnection;
                tblShiftRecord.TableName := 'shift_record';
                try
                    tblShiftRecord.Active := True;

                except

                end;
            end;
            dsLook.DataSet := tblShiftRecord;
        end;    //end case of 5

        end;   //end case itemindex
    end;
end;

procedure TfrmLookDatabase.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;

  try
      tblTempCardUse.Active := False;
  except
  end;

  try
       tblFixCardUse.Active := False;
  except
  end;


  try
       tblFeeMaintain.Active := False;
  except
  end;


  try
      tblGetFee.Active := False;
  except
  end;


  try
      tblShiftRecord.Active := False;
  except
  end;


end;

end.

⌨️ 快捷键说明

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