📄 mainform.pas
字号:
DM.ADOQuery2.Parameters.ParamByName('logtime').Value:=DateToStr(date)+' '+TimeToStr(now);
DM.ADOQuery2.ExecSQL;
end;
end;
end
else
begin
Application.MessageBox('信息有错或未完整','错误',MB_OK+MB_ICONWARNING);
end;
end;
procedure TForm_main.TabSheet3Show(Sender: TObject);
begin
chart_date;
end;
procedure TForm_main.chart_date();
begin
DM.ADOQuery1.SQL.Clear;
DM.ADOQuery1.SQL.Add('select * from BookType');
DM.ADOQuery1.Open;
Series1.Clear;
while not DM.ADOQuery1.Eof do
begin
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select count(*) as t from Book where BType='+QuotedStr(DM.ADOQuery1.fieldbyname('BookType').AsString));
DM.ADOQuery2.Open;
Series1.add(DM.ADOQuery2.fieldbyname('t').AsInteger,DM.ADOQuery1.fieldbyname('BType').AsString);
DM.ADOQuery1.Next;
end;
DM.ADOQuery1.SQL.Clear;
DM.ADOQuery1.SQL.Add('select top 10 BLendTimes,BName from Book order by BLendTimes desc');
DM.ADOQuery1.Open;
Series2.Clear;
while not DM.ADOQuery1.Eof do
begin
Series2.Add(DM.ADOQuery1.fieldbyname('BLendTimes').AsInteger,DM.ADOQuery1.fieldbyname('BName').AsString);
DM.ADOQuery1.Next;
end;
end;
procedure TForm_main.BitBtn6Click(Sender: TObject);
begin
chart_date;
end;
procedure TForm_main.Timer2Timer(Sender: TObject);
begin
DM.ADOQuery3.Requery();
DM.ADOQuery4.Requery();
end;
procedure TForm_main.TabSheet4Show(Sender: TObject);
begin
DM.ADOQuery3.SQL.Clear;
DM.ADOQuery3.SQL.Add('select * from return_log');
DM.ADOQuery3.Open;
DM.ADOQuery4.SQL.Clear;
DM.ADOQuery4.SQL.Add('select * from lend_log');
DM.ADOQuery4.Open;
Timer2.Enabled:=True;
DBGrid3.Columns[0].Title.Caption:='类型';
DBGrid3.Columns[1].Title.Caption:='书号';
DBGrid3.Columns[2].Title.Caption:='书名';
DBGrid3.Columns[3].Title.Caption:='学号';
DBGrid3.Columns[4].Title.Caption:='姓名';
DBGrid3.Columns[5].Title.Caption:='时间';
DBGrid3.Columns[0].Width:=40;
DBGrid3.Columns[1].Width:=80;
DBGrid3.Columns[2].Width:=80;
DBGrid3.Columns[3].Width:=80;
DBGrid3.Columns[4].Width:=50;
DBGrid3.Columns[5].Width:=120;
DBGrid4.Columns[0].Title.Caption:='类型';
DBGrid4.Columns[1].Title.Caption:='书号';
DBGrid4.Columns[2].Title.Caption:='书名';
DBGrid4.Columns[3].Title.Caption:='学号';
DBGrid4.Columns[4].Title.Caption:='姓名';
DBGrid4.Columns[5].Title.Caption:='时间';
DBGrid4.Columns[0].Width:=40;
DBGrid4.Columns[1].Width:=80;
DBGrid4.Columns[2].Width:=80;
DBGrid4.Columns[3].Width:=80;
DBGrid4.Columns[4].Width:=50;
DBGrid4.Columns[5].Width:=120;
end;
procedure TForm_main.TabSheet4Hide(Sender: TObject);
begin
Timer2.Enabled:=False;
end;
procedure TForm_main.BitBtn3Click(Sender: TObject);
begin
if BitBtn3.Caption='完成' then
begin
try
DM.ADOConnection1.BeginTrans;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('update book set BName='+ QuotedStr(ED_ED_Bname.Text)+' ,BPress='+ QuotedStr(ED_ED_BPress.Text)+' ,BPrice='+ QuotedStr(ED_ED_BPrice.Text)+' ,BWriter='+ QuotedStr(ED_ED_BWriter.Text)+' where BType+BNum='+QuotedStr(Lab_BID.Caption));
DM.ADOQuery2.ExecSQL;
DM.ADOConnection1.CommitTrans;
except
ShowMessage('出错');
DM.ADOConnection1.RollbackTrans;
end;
DBGrid2.Enabled:=True;
bitbtn3.Enabled:=False;
DM.ADOQuery1.Requery();
DBGrid2.Enabled:=False;
ShowMessage('success');
end;
if BitBtn3.Caption='修改' then
begin
ED_ED_Bname.Visible:=True;
ED_ED_BWriter.Visible:=True;
ED_ED_BPress.Visible:=True;
ED_ED_BPrice.Visible:=True;
BitBtn3.Caption:='完成';
BitBtn4.Caption:='退出修改';
bitbtn3.Enabled:=False;
DBGrid2.Enabled:=False;
end;
end;
procedure TForm_main.BitBtn4Click(Sender: TObject);
begin
if BitBtn4.Caption='删除' then
begin
if Application.MessageBox(Pchar('你确定要删除吗?'),'是否删除',MB_OKCANCEL+MB_ICONWARNING)=1 then
try
DM.ADOConnection1.BeginTrans;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('delete from book where BType+BNum='+QuotedStr(Lab_BID.Caption));
DM.ADOQuery2.ExecSQL;
DM.ADOConnection1.CommitTrans;
DM.ADOQuery1.Requery();
ShowMessage('删除成功');
except
ShowMessage('出错回滚');
DM.ADOConnection1.RollbackTrans;
end;
end;
if BitBtn4.Caption='退出修改' then
begin
ED_ED_Bname.Visible:=False;
ED_ED_BWriter.Visible:=False;
ED_ED_BPress.Visible:=False;
ED_ED_BPrice.Visible:=False;
BitBtn3.Caption:='修改';
BitBtn4.Caption:='删除';
bitbtn3.Enabled:=True;
DBGrid2.Enabled:=True;
DM.ADOQuery1.Requery();
end;
end;
procedure TForm_main.ED_ED_BnameChange(Sender: TObject);
begin
BitBtn3.Enabled:=True;
end;
procedure TForm_main.ED_ED_BPressChange(Sender: TObject);
begin
BitBtn3.Enabled:=True;
end;
procedure TForm_main.ED_ED_BWriterChange(Sender: TObject);
begin
BitBtn3.Enabled:=True;
end;
procedure TForm_main.ED_ED_BPriceChange(Sender: TObject);
begin
BitBtn3.Enabled:=True;
end;
procedure TForm_main.BitBtn5Click(Sender: TObject);
var
ED_name,ED_grade,ED_sex,ED_series,ED_class,ED_branch,ED_num,sqlstr:string;
begin
if BitBtn5.Caption='完成修改' then
begin
ED_name:=ED_ED_name.Text;
ED_grade:=CB_ED_grade.Items.Strings[CB_ED_grade.itemindex];
ED_series:=format('%.3d',[CB_ED_series.itemindex+1]);
ED_branch:=format('%.2d',[CB_ED_branch.itemindex+1]);
ED_class:=inttostr(CB_ED_class.ItemIndex+1);
ED_num:=Format('%.2d',[strtoint(ED_ED_num.Text)]);
if CB_ED_sex.itemindex=0 then
begin
ED_sex:='1';
end
else
begin
ED_sex:='0';
end;
sqlstr:='update stu set StuName='+QuotedStr(ED_name)+
' ,StuSex='+QuotedStr(ED_sex)+
' ,StuGrade='+QuotedStr(ED_grade)+
' ,StuSeries='+QuotedStr(ED_series)+
' ,StuBranch='+QuotedStr(ED_branch)+
' ,StuClass='+QuotedStr(ED_class)+
' ,StuNum='+QuotedStr(ED_num)+
' where StuGrade+StuSeries+StuBranch+StuClass+StuNum='+QuotedStr(DM.ADOQuery1.fieldbyname('StuID').AsString);
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add(sqlstr);
DM.ADOQuery2.ExecSQL;
DBGrid1.Enabled:=True;
DM.ADOQuery1.Requery();
DBGrid1.Enabled:=False;
ShowMessage('修改成功');
BitBtn5.Enabled:=False;
end;
if BitBtn5.Caption='修改' then
begin
ED_ED_name.Text:=DM.ADOQuery1.fieldbyname('StuName').AsString;
if DM.ADOQuery1.FieldByName('StuSex').AsString='True' then
begin
CB_ED_sex.Itemindex:=0;
end
else
begin
CB_ED_sex.Itemindex:=1;
end;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select * from SeriesType');
DM.ADOQuery2.Open;
CB_ED_series.Items.Clear;
while not Dm.ADOQuery2.Eof do
begin
CB_ED_series.Items.Add(DM.ADOQuery2.fieldbyname('SType').AsString);
DM.ADOQuery2.Next;
end;
CB_ED_series.ItemIndex:=CB_ED_series.Items.IndexOf(Lab_Series.Caption);
str_SType:='00'+inttostr(CB_ED_series.itemindex+1);
// Format('%.5d',[strtoint(strtemp)+1]);
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select BRType from BranchType where SeriesType='+QuotedStr(str_SType));
DM.ADOQuery2.Open;
CB_ED_branch.Items.Clear;
while not Dm.ADOQuery2.Eof do
begin
CB_ED_branch.Items.Add(DM.ADOQuery2.fieldbyname('BRType').AsString);
DM.ADOQuery2.Next;
end;
CB_ED_branch.ItemIndex:=CB_ED_branch.Items.IndexOf(Lab_SType.Caption);
ED_ED_num.Visible:=True;
ED_ED_name.Visible:=True;
CB_ED_sex.Visible:=True;
CB_ED_series.Visible:=True;
CB_ED_branch.Visible:=True;
CB_ED_class.Visible:=True;
CB_ED_grade.Visible:=True;
CB_ED_grade.ItemIndex:=CB_ED_grade.Items.IndexOf(Lab_Grade.Caption);
CB_ED_class.ItemIndex:=CB_ED_class.Items.IndexOf(Lab_class.Caption);
str_SType:=Format('%.3d',[CB_ED_series.ItemIndex+1]);
str_BRtype:=Format('%.2d',[CB_ED_branch.ItemIndex+1]);
str_Grade:=Format('%.2d',[CB_ED_grade.ItemIndex+2]);
str_class:=inttostr(CB_ED_class.ItemIndex+1);
str_num:=leftstr(Lab_Num.Caption,2);
int_Sex:=1;
ED_ED_num.Text:=str_num;
Lab_StuID.Caption:=str_Grade+str_SType+str_BRtype+str_class+str_Num;
BitBtn5.Caption:='完成修改';
BitBtn7.Caption:='退出修改';
BitBtn5.Enabled:=False;
DBGrid1.Enabled:=False;
end;
end;
procedure TForm_main.BitBtn7Click(Sender: TObject);
begin
if BitBtn7.Caption='删除' then
begin
if Application.MessageBox(Pchar('你确定要删除吗?'),'是否删除',MB_OKCANCEL+MB_ICONWARNING)=1 then
try
DM.ADOConnection1.BeginTrans;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('delete from Stu where StuGrade+StuSeries+StuBranch+StuClass+StuNum='+QuotedStr(DM.ADOQuery1.fieldbyname('StuID').AsString));
DM.ADOQuery2.ExecSQL;
DM.ADOConnection1.CommitTrans;
DM.ADOQuery1.Requery();
ShowMessage('删除成功');
except
ShowMessage('出错回滚');
DM.ADOConnection1.RollbackTrans;
end;
end;
if BitBtn7.Caption='退出修改' then
begin
ED_ED_num.Visible:=False;
ED_ED_name.Visible:=False;
CB_ED_sex.Visible:=False;
CB_ED_series.Visible:=False;
CB_ED_branch.Visible:=False;
CB_ED_class.Visible:=False;
CB_ED_grade.Visible:=False;
BitBtn5.Caption:='修改';
BitBtn7.Caption:='删除';
DBGrid1.Enabled:=True;
BitBtn5.Enabled:=True;
DM.ADOQuery1.Requery();
end;
end;
procedure TForm_main.CB_ED_gradeChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
str_Grade:=CB_ED_grade.Items.Strings[CB_ED_grade.itemindex];
Lab_StuID.Caption:=str_Grade+str_SType+str_BRtype+str_class+str_Num;
end;
procedure TForm_main.CB_ED_seriesChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select SeriesType from SeriesType where SType='+QuotedStr(CB_ED_series.Items.Strings[CB_ED_series.Itemindex]));
DM.ADOQuery2.Open;
str_SType:=DM.ADOQuery2.fieldbyname('SeriesType').AsString;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select BRType from BranchType where SeriesType='+QuotedStr(str_SType));
DM.ADOQuery2.Open;
CB_ED_branch.Items.Clear;
while not Dm.ADOQuery2.Eof do
begin
CB_ED_branch.Items.Add(DM.ADOQuery2.fieldbyname('BRType').AsString);
DM.ADOQuery2.Next;
end;
CB_ED_branch.ItemIndex:=0;
Lab_StuID.Caption:=str_Grade+str_SType+str_BRtype+str_class+str_Num;
end;
procedure TForm_main.CB_ED_branchChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
DM.ADOQuery2.SQL.Clear;
DM.ADOQuery2.SQL.Add('select * from BranchType where BRType='+QuotedStr(CB_ED_branch.Items.Strings[CB_ED_branch.Itemindex]));
DM.ADOQuery2.Open;
str_BRtype:=DM.ADOQuery2.fieldbyname('BranchType').AsString;
Lab_StuID.Caption:=str_Grade+str_SType+str_BRtype+str_class+str_Num;
end;
procedure TForm_main.CB_ED_classChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
str_class:=inttostr(CB_ED_class.Itemindex+1);
Lab_StuID.Caption:=str_Grade+str_SType+str_BRtype+str_class+str_Num;
end;
procedure TForm_main.ED_ED_nameChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
end;
procedure TForm_main.CB_ED_sexChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
end;
procedure TForm_main.ED_ED_numChange(Sender: TObject);
begin
BitBtn5.Enabled:=True;
end;
procedure TForm_main.menu_aboutClick(Sender: TObject);
begin
Form_about:=TForm_about.Create(self);
Form_about.ShowModal;
Form_about.Free;
end;
procedure TForm_main.FormShow(Sender: TObject);
begin
Lab_BName.Caption:='';
Lab_BID.Caption:='';
Lab_Bool.Caption:='';
Lab_BStu.Caption:='';
Lab_BType.Caption:='';
Lab_BMoney.Caption:='';
Lab_BDays.Caption:='';
Lab_BStuID.Caption:='';
Lab_BODay.Caption:='';
Lab_BLendDate.Caption:='';
Lab_BPress.Caption:='';
Lab_BPrice.Caption:='';
Lab_BWriter.Caption:='';
Lab_Find.Caption:='';
Lab_StuClass.Caption:='';
Lab_StuName.Caption:='';
Lab_StuID.Caption:='';
Lab_ClassInfo.Caption:='';
Lab_Series.Caption:='';
Lab_Grade.Caption:='';
Lab_class.Caption:='';
Lab_booknum.Caption:='';
Lab_SType.Caption:='';
Lab_Num.Caption:='';
Lab_return_price.Caption:='';
Lab_return_writer.Caption:='';
Lab_return_Press.Caption:='';
Lab_return_BType.Caption:='';
Lab_return_StuName.Caption:='';
Lab_return_StuSex.Caption:='';
Lab_return_classinfo.Caption:='';
Lab_return_StuBook.Caption:='';
Lab_return_BName.Caption:='';
Lab_lend_BType.Caption:='';
Lab_lend_press.Caption:='';
Lab_lend_writer.Caption:='';
Lab_lend_price.Caption:='';
Lab_lend_StuName.Caption:='';
Lab_lend_Classinfo.Caption:='';
Lab_lend_StuBook.Caption:='';
Lab_lend_StuSex.Caption:='';
Lab_lend_BName.Caption:='';
Lab_Insert_StuID.Caption:='';
Lab_Sex.Caption:='';
statusbar1.Panels[0].Text:='当前操作员:'+DM.str_user;
end;
procedure TForm_main.FormCreate(Sender: TObject);
begin
DM:=TDM.Create(self);
Form_login:=TForm_login.Create(self);
if Form_login.ShowModal <> mrYes then
begin
Application.Terminate;
end;
Form_login.Free;
end;
function Clear_Chinese(Str:string):string;
var
i:integer;
temp:string;
begin
i:=1;
while i<=Length(Str) do
begin
if Ord(Str[i])<128 then
temp:=temp+Str[i];
Inc(i);
end;
Result:=temp;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -