Excuse me what reason be?
CodePudding user response:
The unit Unit5;Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids;
Type
Taddnewbook=class (TForm)//the name of the class=class (parent class name)
Label1: TLabel;//class members, book number:
Label2: TLabel;//book name:
Label3: TLabel;//book type:
Label4: TLabel;//as:
Label5: TLabel;//press:
Label6: TLabel;//is in the library:
Label7: TLabel;//donors:
Edit1: TEdit;//display Numbers
Edit2: TEdit;//for the name of the book
ComboBox1: TComboBox;//for the book type
Edit3: TEdit;//to enter the author
ComboBox2: TComboBox;//for the press
ComboBox3: TComboBox;//whether to enter the library
Edit4: TEdit;//for the donor
DBGrid1: TDBGrid;//display the book table information
For: TButton;//add add
Button2: TButton;//close
Label8: TLabel;//caption attribute is "price:
"Edit5: TEdit;//add the book information for input prices
Procedure FormActivate (Sender: TObject);
Procedure FormCreate (Sender: TObject);
Procedure Button1Click (Sender: TObject);
Procedure Button2Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Addnewbook: Taddnewbook;
Implementation
USES unit3, unit2;//unit2 put data access controls for dm form corresponding unit, unit3 declared a global variable
{$R *. DFM}
//execution "add books" five edit box to 0, convenient user input
Procedure Taddnewbook. FormCreate (Sender: TObject);
The begin
Edit1. Text:=' ';//book number
Edit2. Text:=' ';//a book name
Edit3. Text:=' ';//the author
Edit4. Text:=' ';//donor
Edit5. Text:=' ';//price
end;
Procedure Taddnewbook. FormActivate (Sender: TObject);
Var
Newid: string;
The begin
//warehousing books after the largest number plus 1 automatically displayed in the edit box Edit1, as a newly added book number, the user cannot enter
DM. ADOQuery1. Close;
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. SQL. The Add (' select Max (bookid) as the bid from the book ');//the bid is the byname of function Max (bookid)
Dm. ADOQuery1. Open;
Newid:=dm. ADOQuery1. FieldValues [' bid '];
Edit1. Text:=inttostr (strtoint (newid) + 1);
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. Close;
//add the contents of the press table to show the press information in the combo box combobox2
DM. ADOQuery1. Close;
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. SQL. The Add (' select publisher from bpublisher ');//bpublisher list for press information
Dm. ADOQuery1. Open;
While not dm. ADOQuery1. Eof do
The begin
Combobox2. Items. The Add (dm) ADOQuery1) FieldValues [' publisher ']);
Dm. ADOQuery1. Next;
end;
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. Close;
//will book category in the table content added to the display book category in the combobox combobox1
DM. ADOQuery1. Close;
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. SQL. The Add (' select type from btype ');
Dm. ADOQuery1. Open;
While not dm. ADOQuery1. Eof do
The begin
Combobox1. Items. The Add (dm) ADOQuery1) FieldValues [' type ']);
Dm. ADOQuery1. Next;
end;
Dm. ADOQuery1. SQL. The Clear;
Dm. ADOQuery1. Close;
end;
Procedure Taddnewbook. Button1Click (Sender: TObject);
The begin
If (Edit1. Text<> ") and (Edit2. Text<> ") and (Edit3. Text<> ") and
(Edit4. Text<> ") and (Edit5. Text<> ") and (Combobox1. Text<> ") and (combobox2. Text<> ") and (combobox3. Text<> ") then
The begin
//Dm. ADOQuery1. Close;
//DM. ADOQuery1. SQL. The Clear;//remove the original SQL command
//DM. ADOQuery1. SQL. The add (' insert into the book ');//add a record in the book table
//dm. ADOQuery1. SQL. The Add (' values (: bookid, bookname, : type, author, : publisher, : state, : donate) ');
//dm. ADOQuery1. The Parameters. ParamByName (' bookid). Value:=Edit1. Text;
//dm. ADOQuery1. The Parameters. ParamByName (" bookname "). The Value:=Edit2. Text;
//dm. ADOQuery1. The Parameters. ParamByName (' type '). The Value:=Combobox1. Text;
//dm. ADOQuery1. The Parameters. ParamByName (' author '). The Value:=Edit3. Text;
//dm. ADOQuery1. The Parameters. ParamByName (" publisher "). The Value:=Combobox2. Text;
//dm. ADOQuery1. The Parameters. ParamByName (' state '). The Value:=combobox3. Text;
//dm. ADOQuery1. The Parameters. ParamByName (' donate '). The Value:=Edit4) Text;
//dm. ADOQuery1. The Parameters. ParamByName (' price '). The Value:=strtoint (Edit5. Text);//price
//dm. ADOQuery1. ExecSQL;
//dm. ADOQuery1. SQL. The Clear;
//dm. ADOTable1. Close;
Dm. AdoTable1. Open;
//dm. ADOQuery1. Close;
Dm. ADOTable1. AppendRecord ([edit1 Text, edit2. Text, combobox1. Text, edit3. Text,
Combobox2. Text, edit5. Text, combobox3. Text, edit4) Text]);
Edit1. Text:=inttostr (strtoint (Edit1. Text) + 1);//book number automatically add 1
Edit2. Text:=' ';
Edit3. Text:=' ';
Edit4. Text:=' ';
Combobox1. Text:=' ';
Combobox2. Text:=' ';
Combobox3. Text:=' ';
End
The else
Showmessage (' books relevant content cannot be empty).
end;
//close button
Procedure Taddnewbook. Button2Click (Sender: TObject);
The begin
close;
end;
end.
CodePudding user response:
The above is the source code,CodePudding user response:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull