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

📄 lingshu_chaxun.pas

📁 一个详实的图书信息管理系统
💻 PAS
字号:
unit LingShu_ChaXun;

interface

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

type
  Tlingshu_form = class(TForm)
    GroupBox1: TGroupBox;
    RadioButton2: TRadioButton;
    RadioButton1: TRadioButton;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    ComboBox1: TComboBox;
    BitBtn2: TBitBtn;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    ADOTable1: TADOTable;
    DBGrid1: TDBGrid;
    ADOTable2: TADOTable;
    GroupBox3: TGroupBox;
    Label2: TLabel;
    Edit1: TEdit;
    BitBtn1: TBitBtn;
    procedure FormActivate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure ComboBox1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure  initdbgrid();
  end;

var
  lingshu_form: Tlingshu_form;

  case_flag:integer;
implementation
 uses checkuser;

{$R *.dfm}



procedure Tlingshu_form.initdbgrid();
begin
    dbgrid1.Columns[0].Width:=80;
    dbgrid1.Columns[1].Width:=140;
    dbgrid1.Columns[2].Width:=140;
    dbgrid1.Columns[3].Width:=90;
    dbgrid1.Columns[4].Width:=100;
    dbgrid1.Columns[5].Width:=70;
    dbgrid1.Columns[6].Width:=70;
    dbgrid1.Columns[7].Width:=70;
    dbgrid1.Columns[8].Width:=70;
    dbgrid1.Columns[9].Width:=70;
    dbgrid1.Columns[10].Width:=100;
    dbgrid1.Columns[11].Width:=90;
    dbgrid1.Columns[12].Width:=150;
    dbgrid1.Columns[13].Width:=60;
    dbgrid1.Columns[14].Width:=100;
    dbgrid1.Columns[15].Width:=40;
end;


procedure Tlingshu_form.FormActivate(Sender: TObject);
begin
   //-----------------一定要先连接数据库---------------------
    ADOConnection1:=CheckUserForm.ADOConnection1;
    dbgrid1.DataSource:=DataSource1;

    DataSource1.DataSet:=adoquery1;
    adoquery1.Connection:=ADOConnection1;
    adoquery1.Close;
    adotable1.Connection:=ADOConnection1;


//------------------combobox中增加字段---------------
   adotable1.Close;
   adotable1.TableName:='班级表';
   adotable1.Active:=true;
   while not adotable1.Eof do
   begin
     combobox1.Items.Add(adotable1.fieldbyname('班级名').AsString);
     adotable1.Next;
   end;
    combobox1.Text:='';

    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('select * from 教材出入库历史表 ');
    adoquery1.Prepared;
    adoquery1.Active:=true;
    initdbgrid;
    edit1.Text:='共有'+inttostr(adoquery1.Recordset.RecordCount)+'条记录';
    dbgrid1.ReadOnly:=true;
   if adoquery1.Recordset.RecordCount<=0 then
      bitbtn1.Enabled:=false;
//----------------------模块的初始化-------------------
   radiobutton1.Checked:=true;
   combobox1.Text:='';
   case_flag:=1;
end;

procedure Tlingshu_form.BitBtn2Click(Sender: TObject);
begin
  close;
end;

procedure Tlingshu_form.ComboBox1Click(Sender: TObject);
begin
     case case_flag of
   1:
     begin
           adoquery1.Close;
           adoquery1.SQL.Clear;

           adoquery1.SQL.Add('select * from 教材出入库历史表 where 经办单位=:classname');
           adoquery1.Parameters.Clear;
           adoquery1.Parameters.AddParameter;
           adoquery1.Parameters[0].Name:='classname';
           adoquery1.Parameters[0].DataType:=ftstring;
           adoquery1.Parameters[0].Direction:=pdinput;
           adoquery1.Parameters[0].Value:=combobox1.Text;
           adoquery1.Prepared;
           adoquery1.Active:=true;
           initdbgrid;
           edit1.Text:='共有'+inttostr(adoquery1.Recordset.RecordCount)+'条记录';
      end;

   2:
   begin
           adoquery1.Close;
           adoquery1.SQL.Clear;

           adoquery1.SQL.Add('select * from 教材出入库历史表 where 经办单位=:name');
           adoquery1.Parameters.Clear;
           adoquery1.Parameters.AddParameter;
           adoquery1.Parameters[0].Name:='classname';
           adoquery1.Parameters[0].DataType:=ftstring;
           adoquery1.Parameters[0].Direction:=pdinput;
           adoquery1.Parameters[0].Value:=combobox1.Text;
           adoquery1.Prepared;
           adoquery1.Active:=true;
           initdbgrid;
           edit1.Text:='共有'+inttostr(adoquery1.Recordset.RecordCount)+'条记录';
   end;
   end;
end;

procedure Tlingshu_form.RadioButton1Click(Sender: TObject);
begin
     if radiobutton1.Checked then
   begin
     label1.Caption:='选择班级';
     label1.Width:=88;
     case_flag:=1;

   combobox1.Items.Clear;
   adotable1.Close;
   adotable1.TableName:='班级表';
   adotable1.Active:=true;
   while not adotable1.Eof do
    begin
     combobox1.Items.Add(adotable1.fieldbyname('班级名').AsString);
     adotable1.Next;
    end;
    combobox1.Text:='';
    adotable1.Close;

    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('select * from 教材出入库历史表');
    adoquery1.Prepared;
    adoquery1.Active:=true;
    if adoquery1.Recordset.RecordCount<=0 then
      bitbtn1.Enabled:=false
    else
      bitbtn1.Enabled:=true;

    initdbgrid;
    edit1.Text:='共有'+inttostr(adoquery1.Recordset.RecordCount)+'条记录';
   end;
end;

procedure Tlingshu_form.RadioButton2Click(Sender: TObject);
begin
    if radiobutton2.Checked then
   begin
     label1.Caption:='选择单位';
     label1.Width:=88;
     case_flag:=2;
     combobox1.Items.Clear;
     adotable1.Close;
     adotable1.TableName:='单位信息表';
     adotable1.Active:=true;
    while not adotable1.Eof do
    begin
     combobox1.Items.Add(adotable1.fieldbyname('单位名').AsString);
     adotable1.Next;
    end;
    combobox1.Text:='';
    adotable1.Close;
    adoquery1.Close;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('select * from 教材出入库历史表');
    adoquery1.Prepared;
    adoquery1.Active:=true;
    if adoquery1.Recordset.RecordCount<=0 then
      bitbtn1.Enabled:=false
    else
      bitbtn1.Enabled:=true;
    initdbgrid;
    edit1.Text:='共有'+inttostr(adoquery1.Recordset.RecordCount)+'条记录';
   end;
end;

procedure Tlingshu_form.BitBtn1Click(Sender: TObject);
begin
    if adoquery1.Recordset.RecordCount>0 then
           adoquery1.Delete;
end;

end.

⌨️ 快捷键说明

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