四川大学图书管理系统!sql+c++实现

源代码在线查看: bookmanage.pas

软件大小: 783 K
上传用户: wanglp094
关键词: sql 大学 图书管理
下载地址: 免注册下载 普通下载 VIP

相关代码

				unit BookManage;
				
				interface
				
				uses
				  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
				  Dialogs, ExtCtrls, StdCtrls, Grids, DBGrids, Mask, DBCtrls;
				
				type
				  TBookManageForm = class(TForm)
				    DBGrid1: TDBGrid;
				    Label1: TLabel;
				    Button1: TButton;
				    GroupBox1: TGroupBox;
				    Button3: TButton;
				    Label2: TLabel;
				    Label3: TLabel;
				    Label4: TLabel;
				    Label5: TLabel;
				    Label6: TLabel;
				    Label7: TLabel;
				    Label8: TLabel;
				    Label9: TLabel;
				    Label10: TLabel;
				    DBGrid2: TDBGrid;
				    Button5: TButton;
				    Edit1: TEdit;
				    Edit2: TEdit;
				    Edit3: TEdit;
				    Edit4: TEdit;
				    Edit5: TEdit;
				    Edit6: TEdit;
				    Edit8: TEdit;
				    Edit7: TEdit;
				    procedure FormShow(Sender: TObject);
				    procedure Button1Click(Sender: TObject);
				    procedure Button3Click(Sender: TObject);
				    procedure Button5Click(Sender: TObject);
				    procedure FormClose(Sender: TObject; var Action: TCloseAction);
				  private
				    { Private declarations }
				  public
				    { Public declarations }
				  end;
				
				var
				  BookManageForm: TBookManageForm;
				  BookId, NumOfBook, LendOfBook,Publish,BookName,ISBN,Writer,BookSort,Time : String;
				  PC : String;
				  DT : TDateTime;
				  NumOfBook_I, LendOfBook_I : Integer;
				
				implementation
				
				uses Login, Main, Data;
				
				{$R *.dfm}
				
				procedure TBookManageForm.FormShow(Sender: TObject);
				begin
				  DBGrid1.DataSource := Data.DataModule.BookManage1DS;
				  DBGrid2.DataSource := Data.DataModule.BookManage2DS;
				  if (Main.Purview[3]=1) and (Main.Choose=6) then //入库
				    begin
				      GroupBox1.Caption := '新书入库';
				      Label1.Caption := '新书表';
				      Label10.Caption := '在库图书表';
				      Button1.Visible := True;
				      Button1.Enabled := True;
				      Button3.Visible := False;
				      Button3.Enabled := False;
				      Button5.Caption := '入库';
				
				      with Data.DataModule.BookManage1 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('select 图书编号,书名,分类,作者,出版社,ISBN,数量,到书时间,批次,操作员 from 新书');
				          Open;
				        end;
				      with Data.DataModule.BookManage2 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('select 图书编号,书名,分类,作者,出版社,ISBN,在库数量,剩余数量,被借阅次数,入库时间,操作员 from 在库图书');
				          Open;
				        end
				    end
				  else if (Main.Purview[4]=1) and (Main.Choose=7) then //注销
				    begin
				      GroupBox1.Caption := '旧书注销';
				      Label1.Caption := '在库图书表';
				      Label10.Caption := '旧书表';
				      Button1.Visible := False;
				      Button1.Enabled := False;
				      Button3.Visible := True;
				      Button3.Enabled := True;
				      Button5.Caption := '注销';
				
				      with Data.DataModule.BookManage1 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('select 图书编号,书名,分类,作者,出版社,ISBN,在库数量,剩余数量,被借阅次数,入库时间,操作员 from 在库图书');
				          Open;
				        end;
				      with Data.DataModule.BookManage2 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('select 图书编号,书名,分类,作者,出版社,ISBN,数量,删除时间,操作员 from 旧书');
				          Open;
				        end
				    end;
				end;
				
				procedure TBookManageForm.Button1Click(Sender: TObject);
				begin
				  BookId := Edit1.Text;
				  BookName := Edit2.Text;
				  Writer := Edit3.Text;
				  BookSort := Edit4.Text;
				  Publish := Edit5.Text;
				  ISBN := Edit6.Text;
				  NumOfBook := Edit7.Text;
				  PC := Edit8.Text;
				  DT := Date();
				  Time := datetostr(DT);
				  with Data.DataModule.BookManage1 do
				    begin
				      if (Edit1.Text'') and (Edit2.Text'') and (Edit3.Text'') and (Edit4.Text'') and (Edit5.Text'') and (Edit6.Text'') and (Edit7.Text'') and (Edit8.Text'') then
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('insert into 新书(图书编号,数量,到书时间,批次,书名,作者,出版社,ISBN,分类,操作员)');
				          SQL.Add('values(');
				          SQL.Add('''' + BookId + '''' );
				          SQL.Add(',');
				          SQL.Add(NumOfBook);
				          SQL.Add(',');
				          SQL.Add('''' + Time + '''');
				          SQL.Add(',');
				          SQL.Add('''' + PC + '''');
				          SQL.Add(',');
				          SQL.Add('''' + BookName + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Writer + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Publish + '''');
				          SQL.Add(',');
				          SQL.Add('''' + ISBN + '''');
				          SQL.Add(',');
				          SQL.Add('''' + BookSort + '''');
				          SQL.Add(',');
				          SQL.Add(Login.UseId);
				          SQL.Add(')');
				          ExecSQL;
				          Close;
				          SQL.Clear;
				          SQL.Add('select * from 新书');
				          Open;
				        end
				      else
				        Application.MessageBox('图书信息不能为空','错误信息',MB_OK+MB_ICONEXCLAMATION);
				    end;
				  //清空控件内容
				  Edit1.Clear;
				  Edit2.Clear;
				  Edit3.Clear;
				  Edit4.Clear;
				  Edit5.Clear;
				  Edit6.Clear;
				  Edit7.Clear;
				  Edit8.Clear;
				end;
				
				procedure TBookManageForm.Button3Click(Sender: TObject);
				begin
				  //删除旧书
				  with Data.DataModule.BookManage2 do
				    begin
				      BookId := FieldByName('图书编号').AsString;
				      Close;
				      SQL.Clear;
				      SQL.Add('delete from 旧书 where 图书编号=''' + BookId + '''');
				      ExecSQL;
				      Close;
				      SQL.Clear;
				      SQL.Add('select * from 旧书');
				      Open;
				    end;
				  Edit1.Clear;
				  Edit2.Clear;
				  Edit3.Clear;
				  Edit4.Clear;
				  Edit5.Clear;
				  Edit6.Clear;
				  Edit7.Clear;
				  Edit8.Clear;
				end;
				
				procedure TBookManageForm.Button5Click(Sender: TObject);
				begin
				  if Main.Choose=6 then //入库操作
				    begin
				      //在新书表中删除记录
				      with Data.DataModule.BookManage1 do
				        begin
				          BookId := FieldByName('图书编号').AsString;
				          BookName := FieldByName('书名').AsString;
				          Writer := FieldByName('作者').AsString;
				          BookSort := FieldByName('分类').AsString;
				          ISBN := FieldByName('ISBN').AsString;
				          Publish := FieldByName('出版社').AsString;
				          NumOfBook := FieldByName('数量').AsString;
				          LendOfBook := NumOfBook;
				          DT := Date();
				          Time := datetostr(DT);
				          Close;
				          SQL.Clear;
				          SQL.Add('delete from 新书 where 图书编号 = ''' + BookId + '''');
				          ExecSQL;
				          Close;
				          SQL.Clear;
				          SQL.Add('select * from 新书');
				          Open;
				        end;
				      //在在库图书表中插入记录
				      with Data.DataModule.BookManage2 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('insert into 在库图书 values(');
				          SQL.Add('''' + BookId + '''');
				          SQL.Add(',');
				          SQL.Add(NumOfBook);
				          SQL.Add(',');
				          SQL.Add(LendOfBook);
				          SQL.Add(',');
				          SQL.Add('''' + Time + '''');
				          SQL.Add(',0,');
				          SQL.Add(Login.UseId);
				          SQL.Add(',');
				          SQL.Add('''' + BookName + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Writer + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Publish + '''');
				          SQL.Add(',');
				          SQL.Add('''' + ISBN + '''');
				          SQL.Add(',');
				          SQL.Add('''' + BookSort + '''');
				          SQL.Add(')');
				          ExecSQL;
				          Close;
				          SQL.Clear;
				          SQL.Add('select * from 在库图书');
				          Open;
				        end;
				    end
				  else if Main.Choose=7 then //注销操作
				    begin
				      //从在库图书表中删除记录
				      with Data.DataModule.BookManage1 do
				        begin
				          BookId := FieldByName('图书编号').AsString;
				          BookName := FieldByName('书名').AsString;
				          Writer := FieldByName('作者').AsString;
				          BookSort := FieldByName('分类').AsString;
				          ISBN := FieldByName('ISBN').AsString;
				          Publish := FieldByName('出版社').AsString;
				          NumOfBook := FieldByName('在库数量').AsString;
				          DT := Date();
				          Time := datetostr(DT);
				          Close;
				          SQL.Clear;
				          SQL.Add('delete from 在库图书 where 图书编号 = ''' + BookId + '''');
				          ExecSQL;
				          Close;
				          SQL.Clear;
				          SQL.Add('select * from 在库图书');
				          Open;
				        end;
				      //在旧书表中插入记录
				      with Data.DataModule.BookManage2 do
				        begin
				          Close;
				          SQL.Clear;
				          SQL.Add('insert into 旧书 values(');
				          SQL.Add('''' + BookId + '''');
				          SQL.Add(',');
				          SQL.Add(NumOfBook);
				          SQL.Add(',');
				          SQL.Add('''' + Time + '''');
				          SQL.Add(',');
				          SQL.Add('''' + BookName + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Writer + '''');
				          SQL.Add(',');
				          SQL.Add('''' + Publish + '''');
				          SQL.Add(',');
				          SQL.Add('''' + ISBN + '''');
				          SQL.Add(',');
				          SQL.Add('''' + BookSort + '''');
				          SQL.Add(',');
				          SQL.Add(Login.UseId);
				          SQL.Add(')');
				          ExecSQL;
				          Close;
				          SQL.Clear;
				          SQL.Add('select * from 旧书');
				          Open;
				        end;
				    end;
				end;
				
				procedure TBookManageForm.FormClose(Sender: TObject;
				  var Action: TCloseAction);
				begin
				  Edit1.Clear;
				  Edit2.Clear;
				  Edit3.Clear;
				  Edit4.Clear;
				  Edit5.Clear;
				  Edit6.Clear;
				  Edit7.Clear;
				  Edit8.Clear;
				end;
				
				end.
							

相关资源