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

📄 unit3.pas

📁 图书管理 很好。很好 ado 多用户不错
💻 PAS
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, ComCtrls, Grids, DBGrids, StdCtrls, XPMenu;

type
  TForm3 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    GroupBox2: TGroupBox;
    DBGrid1: TDBGrid;
    XPMenu1: TXPMenu;
    StatusBar1: TStatusBar;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation
uses unit6,unit7;


{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
  sqlstr:string;
begin
   sqlstr:='select * from dangaan where (1=1)';
   if edit1.Text <>'' then
   sqlstr:=sqlstr+'and (姓名='''+edit1.text+''')';
   if edit2.text<>'' then
   sqlstr:=sqlstr+'and (学号='''+edit2.text+''')';
   if combobox1.Text<>'' then
   sqlstr:=sqlstr+'and (性别='''+combobox1.text+''')' ;
   if combobox2.Text <>'' then
   sqlstr:=sqlstr+'and (党团员='''+combobox2.text+''')' ;
   if  edit3.text<>'' then
   sqlstr:=sqlstr+'and (院系='''+edit3.text+''')';
   if edit4.text<>'' then
   sqlstr:=sqlstr+'and (籍贯='''+edit4.text+''')';
   if edit5.text<>'' then
   sqlstr:=sqlstr+'and (专业='''+edit5.text+''')';
   if edit6.text<>'' then
   sqlstr:=sqlstr+'and (电话号码='''+edit6.text+''')';
   dm.ADOQuery1.Close ;
   dm.ADOQuery1.SQL.Clear ;
   dm.ADOQuery1.SQL.Add(sqlstr);
   dm.ADOQuery1.Open ;
   Edit1.Text:='';
   Edit2.Text:='';
   Edit3.Text:='';
   Edit4.Text:='';
   Edit5.Text:='';
   Edit6.Text:='';
   combobox1.Text:='';
   combobox2.Text:='';
 statusbar1.Panels[0].Text:='总共找到 '+inttostr(dm.ADOQuery1.RecordCount)+' 条记录';

end;


procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := cafree;
end;

procedure TForm3.Button2Click(Sender: TObject);
begin
form7:=tform7.create(application);
form7.QuickRep1.Preview;
end;

procedure TForm3.FormCreate(Sender: TObject);
 var
 mypath:string;
begin
dm.ADOConnection1.Close;
MyPath:=ExtractFilePath(ParamStr(0));
  dm.ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
  MyPath+'db1.mdb;Persist Security Info=False';
 try
  dm.ADOConnection1.Open;

  except
   application.MessageBox('找不到数据库,引起该问题的原因是数据库文件可能被人为删除或改名.','无法打开数据库',0);
   application.Terminate;
  end;
end;

end.

⌨️ 快捷键说明

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