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

📄 bookdocuform.pas

📁 图书管理系统,使用Delphi开发,数据库为Microsoft SQL Server 2
💻 PAS
字号:
unit BookDocuForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Unit2, ADODB, ImgList, DB, ExtCtrls, StdCtrls, Buttons,
  ComCtrls, ToolWin, Grids, DBGrids, DBCtrls, Mask;

type
  TBookDocu = class(TParent)
    ADOQuery2: TADOQuery;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    DBEdit9: TDBEdit;
    DBEdit10: TDBEdit;
    DBEdit11: TDBEdit;
    DBComboBox1: TDBComboBox;
    DBComboBox2: TDBComboBox;
    DBComboBox3: TDBComboBox;
    DBMemo1: TDBMemo;
    DBCheckBox1: TDBCheckBox;
    procedure FormActivate(Sender:TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure DBCheckBox1Click(Sender: TObject);
    procedure DBEdit10KeyPress(Sender: TObject; var Key: Char);
    procedure DBEdit9KeyPress(Sender: TObject; var Key: Char);
    procedure ToolButton6Click(Sender: TObject);
    procedure DataSource1DataChange(Sender: TObject; Field: TField);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  BookDocu: TBookDocu;
  isChecked: integer;

implementation

{$R *.dfm}
uses
DataMod;

//
procedure TBookDocu.FormActivate(Sender: TObject);
var
name:string;
begin
  inherited;
  //
  adoquery2.Close;
  adoquery2.SQL.Clear;
  adoquery2.SQL.Add('select PublishingCompany_Name from PublishingCompany');
  adoquery2.Open;
  dbcombobox2.Items.Clear;
  while not adoquery2.Eof do
    begin
      name:=adoquery2.fieldByName('PublishingCompany_Name').AsString;
      dbcombobox2.Items.Add(name);
      adoquery2.Next;
    end;
  //
  adoquery2.Close;
  adoquery2.SQL.Clear;
  adoquery2.SQL.Add('select BookType_TypeName from BookType');
  adoquery2.Open;
  dbcombobox1.Items.Clear;
  while not adoquery2.Eof do
    begin
      name:=adoquery2.fieldByName('BookType_TypeName').AsString;
      dbcombobox1.Items.Add(name);
      adoquery2.Next;
    end;
    //
  //
  adoquery2.Close;
  adoquery2.SQL.Clear;
  adoquery2.SQL.Add('select BookShelf_Name from BookShelf');
  adoquery2.Open;
  dbcombobox3.Items.Clear;
  while not adoquery2.Eof do
    begin
      name:=adoquery2.fieldByName('BookShelf_Name').AsString;
      dbcombobox3.Items.Add(name);
      adoquery2.Next;
    end;
end;



procedure TBookDocu.ToolButton5Click(Sender: TObject);
var
  maxnum:integer;
  newnum:string;
begin
  inherited;
  //
  adoquery2.Close;
  adoquery2.SQL.Clear;
  adoquery2.SQL.Add('select max(BookInfo_No) 最大编号 from BookInfo');
  adoquery2.Open;
  maxnum:=adoquery2.FieldByName('最大编号').AsInteger;
  maxnum:=maxnum+1;
  newnum:=inttostr(maxnum);
  if length(newnum)=1 then
    dbedit2.Text:='000000'+newnum;
  if length(newnum)=2 then
    dbedit2.Text:='00000'+newnum;
  if length(newnum)=3 then
    dbedit2.Text:='0000'+newnum;
  if length(newnum)=4 then
    dbedit2.Text:='000'+newnum;
  if length(newnum)=5 then
    dbedit2.Text:='00'+newnum;
  if length(newnum)=6 then
    dbedit2.Text:='0'+newnum;
  //
  dbcombobox2.SelText:=dbcombobox2.Items.Strings[0];
  //
  ischecked:=0;
end;

//



procedure TBookDocu.ToolButton8Click(Sender: TObject);
begin
//
  if isChecked=0 then
    begin
      showmessage('未选择是否注销,请重新选择');
      exit;
    end;
//
  inherited;
//
  isChecked:=0;
end;

//
procedure TBookDocu.DBCheckBox1Click(Sender: TObject);
begin
  inherited;
   isChecked:=(isChecked)or(1);
end;

procedure TBookDocu.DBEdit10KeyPress(Sender: TObject; var Key: Char);
var
input:char;
begin
  inherited;
  input:=key;
  if (key>=#30)and(key<=#39) then
    dbEdit10.Text:=dbedit10.Text+input;
end;

//
procedure TBookDocu.DBEdit9KeyPress(Sender: TObject; var Key: Char);
var
input:char;
begin
  inherited;
  input:=key;
  if (key>=#30)and(key<=#39) then
    dbEdit9.Text:=dbedit9.Text+input;
end;


procedure TBookDocu.ToolButton6Click(Sender: TObject);
begin
  inherited;
//
panel1.Enabled:=true;
isChecked:=1;
end;

procedure TBookDocu.DataSource1DataChange(Sender: TObject; Field: TField);
begin
  inherited;
//
dbgrid1.Columns[0].Width:=96;
dbgrid1.Columns[1].Width:=48;
dbgrid1.Columns[2].Width:=128;
dbgrid1.Columns[3].Width:=128;
dbgrid1.Columns[4].Width:=80;
dbgrid1.Columns[5].Width:=80;
dbgrid1.Columns[6].Width:=80;
dbgrid1.Columns[7].Width:=96;
dbgrid1.Columns[8].Width:=80;
dbgrid1.Columns[9].Width:=80;
dbgrid1.Columns[10].Width:=80;
dbgrid1.Columns[11].Width:=80;
dbgrid1.Columns[12].Width:=80;
dbgrid1.Columns[13].Width:=48;
dbgrid1.Columns[14].Width:=48;
dbgrid1.Columns[15].Width:=48;

end;

procedure TBookDocu.BitBtn1Click(Sender: TObject);
var
condition:integer;
begin
  inherited;
  condition:=7;
  if label3.Visible=false then
    condition:=(condition)and(3);
  if label4.Visible=false then
    condition:=(condition)and(5);
  if label5.Visible=false then
    condition:=(condition)and(6);

  if condition=7 then
    begin
      adoquery1.Close;
      adoquery1.SQL.Clear;
      adoquery1.SQL.Add('select * from '+adotable1.TableName);
      adoquery1.SQL.Add('where(BookInfo_BarCode like ''%'+edit1.Text+'%'')');
      adoquery1.SQL.Add('and(BookInfo_No like ''%'+edit2.Text+'%'')');
      adoquery1.SQL.Add('and(BookInfo_BookName like ''%'+edit3.Text+'%'')');
      adoquery1.Open;
      //
      adotable1.Clone(adoquery1,ltUnspecified);
    end;

  if condition=6 then //
    begin
      adoquery1.Close;
      adoquery1.SQL.Clear;
      adoquery1.SQL.Add('select * from '+adotable1.TableName);
      adoquery1.SQL.Add('where(BookInfo_BarCode like ''%'+edit2.Text+'%'')');
      adoquery1.SQL.Add('and(BookInfo_No like''%'+edit2.Text+'%'')');
      adoquery1.Open;
      //
      adoquery1.Clone(adoquery1,ltUnspecified);
    end;

  if condition=4 then //
    begin
      adoquery1.Close;
      adoquery1.SQL.Add('select * from '+adotable1.TableName);
      adoquery1.SQL.Add(' where(BookInfo_BarCode like ''%'+edit1.Text+'%'')');
      adoquery1.Open;
      //
      adotable1.Clone(adoquery1,ltUnspecified);
    end;
end;

end.

⌨️ 快捷键说明

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