📄 otherinfounit.~pas
字号:
begin
if combobox2.Text='' then
begin
showmessage('还没有输入作者名?');
combobox2.SetFocus;
exit;
end;
with DM do
begin
OtherInfo.SQL.Text:='select auth_name form auth_info where auth_name=:in0';
OtherInfo.Parameters.ParamByName('in0').Value:=combobox2.Text;
OtherInfo.Prepared;
OtherInfo.Open;
if OtherInfo.RecordCount=0 then
begin
showmessage('数据库中没有这个作者信息');
OtherInfo.Close;
combobox2.SetFocus;
exit;
end;
ADOConn.BeginTrans;
try
OtherInfo.SQL.Text:='update auth_info set auth_email=:in0,auth_remark='+
':in1 where auth_name=:in2';
Otherinfo.Parameters.ParamByName('in0').Value:=edit6.Text;
Otherinfo.Parameters.ParamByName('in1').Value:=memo1.Text;
Otherinfo.Parameters.ParamByName('in2').Value:=combobox2.Text;
OtherInfo.Prepared;
OtherInfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
OtherInfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn5Click(Sender: TObject);
begin
if combobox2.Text='' then
begin
showmessage('还没有输入作者名?');
combobox2.SetFocus;
exit;
end;
with DM do
begin
OtherInfo.SQL.Text:='select auth_name form auth_info where auth_name=:in0';
OtherInfo.Parameters.ParamByName('in0').Value:=combobox2.Text;
OtherInfo.Prepared;
OtherInfo.Open;
if OtherInfo.RecordCount=1 then
begin
showmessage('数据库中已经存在这个作者信息');
OtherInfo.Close;
combobox2.SetFocus;
exit;
end;
ADOConn.BeginTrans;
try
OtherInfo.SQL.Text:='insert into auth_info(auth_name,auth_email,auth_remark)'+
' values(:in0,:in1,:in2)';
Otherinfo.Parameters.ParamByName('in0').Value:=combobox2.Text;
Otherinfo.Parameters.ParamByName('in1').Value:=edit6.Text;
Otherinfo.Parameters.ParamByName('in2').Value:=memo1.Text;
OtherInfo.Prepared;
OtherInfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
OtherInfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn4Click(Sender: TObject);
var
i:byte;
begin
if combobox2.Text='' then
begin
showmessage('还没有输入作者名?');
combobox2.SetFocus;
exit;
end;
with DM do
begin
OtherInfo.SQL.Text:='select auth_name form auth_info where auth_name=:in0';
OtherInfo.Parameters.ParamByName('in0').Value:=combobox2.Text;
OtherInfo.Prepared;
OtherInfo.Open;
if OtherInfo.RecordCount=0 then
begin
showmessage('数据库中没有这个作者信息');
OtherInfo.Close;
combobox2.SetFocus;
exit;
end;
if MessageDlg('确定要删除吗?',mtConfirmation,[mbyes,mbno],0)=mrno then
exit;
ADOConn.BeginTrans;
try
OtherInfo.SQL.Text:='delete auth_info where auth_name=:in0';
Otherinfo.Parameters.ParamByName('in0').Value:=combobox2.Text;
OtherInfo.Prepared;
OtherInfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
OtherInfo.Close;
end;
for i:=0 to TabSheet1.ComponentCount-1 do//清空所有的编辑框
if (TabSheet1.Components[i] is TEdit) or (TabSheet1.Components[i] is TCombobox) or (TabSheet1.Components[i] is TMemo) then
TEdit(TabSheet1.Components[i]).Text:='';
end;
procedure TOtherInfoForm.TabSheet3MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar3.Panels[1].Text:='';
end;
procedure TOtherInfoForm.BitBtn9MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar3.Panels[1].Text:='更新数据库中已存在的类型';
end;
procedure TOtherInfoForm.BitBtn8MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar3.Panels[1].Text:='添加新的类型名到数据库中';
end;
procedure TOtherInfoForm.BitBtn7MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar3.Panels[1].Text:='从数据库中删除已存在的类型名';
end;
procedure TOtherInfoForm.BitBtn12MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar3.Panels[1].Text:='从数据库中取得所有类型名来刷新列表';
end;
procedure TOtherInfoForm.ComboBox3Change(Sender: TObject);
begin
with dm do
begin
Otherinfo.SQL.Text:='select type_gen,type_typ from book_type where type_sno=:in0';
Otherinfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
Otherinfo.Prepared;
Otherinfo.Open;
if otherinfo.RecordCount=1 then
begin
combobox4.Text:=Otherinfo.Fields[0].AsString;
combobox5.Text:=otherinfo.Fields[1].AsString;
end;
Otherinfo.Close;
end;
end;
procedure TOtherInfoForm.ComboBox4Change(Sender: TObject);
var
typstr:TStrings;
begin
typstr:=TStringList.Create;
try
typstr:=DM.GetTypeTyp(combobox4.Text);
combobox5.Items.Assign(typstr);
combobox5.ItemIndex:=0;
finally
typstr.Free;
end;
end;
procedure TOtherInfoForm.ComboBox5Change(Sender: TObject);
begin
with DM do
begin
Otherinfo.SQL.Text:='select type_sno from book_type where type_gen=:in0 and type_typ=:in1';
Otherinfo.Parameters.ParamByName('in0').Value:=combobox4.Text;
Otherinfo.Parameters.ParamByName('in1').Value:=combobox5.Text;
Otherinfo.Prepared;
Otherinfo.Open;
if Otherinfo.RecordCount=1 then
combobox3.Text:=Otherinfo.Fields[0].asstring;
Otherinfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn12Click(Sender: TObject);
var
typstr:TStrings;
begin
typstr:=TStringList.Create;
try
typstr:=DM.GetTypeSno;
combobox3.Items.Clear;
combobox3.Items.Assign(typstr);
combobox3.ItemIndex:=0;
finally
typstr.Free;
end;
end;
procedure TOtherInfoForm.BitBtn9Click(Sender: TObject);
begin
if combobox3.Text='' then
begin
showmessage('还没有输入类型编号');
combobox3.SetFocus;
exit;
end;
with dm do
begin
otherinfo.SQL.Text:='select type_sno from book_type where bype_sno=:in0';
otherinfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
otherinfo.Prepared;
otherinfo.Open;
if otherinfo.RecordCount=0 then
begin
showmessage('无此类型号');
combobox3.SetFocus;
otherinfo.Close;
exit;
end;
otherinfo.Close;
ADOConn.BeginTrans;
try
otherinfo.SQL.Text:='update book_type set type_gen=:in0,type_typ=:in1 '+
' where type_sno=:in2';
otherinfo.Parameters.ParamByName('in0').Value:=combobox4.Text;
otherinfo.Parameters.ParamByName('in1').Value:=combobox5.Text;
otherinfo.Parameters.ParamByName('in2').Value:=combobox3.Text;
otherinfo.Prepared;
otherinfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
otherinfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn8Click(Sender: TObject);
begin
if combobox3.Text='' then
begin
showmessage('还没有输入类型编号');
combobox3.SetFocus;
exit;
end;
with dm do
begin
otherinfo.SQL.Text:='select type_sno from book_type where bype_sno=:in0';
otherinfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
otherinfo.Prepared;
otherinfo.Open;
if otherinfo.RecordCount=1 then
begin
showmessage('此类型号已存在');
combobox3.SetFocus;
otherinfo.Close;
exit;
end;
otherinfo.Close;
ADOConn.BeginTrans;
try
otherinfo.SQL.Text:='insert into book_type(type_sno,type_gen,type_typ) '+
' values(:in0,:in1,:in2)';
otherinfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
otherinfo.Parameters.ParamByName('in1').Value:=combobox4.Text;
otherinfo.Parameters.ParamByName('in2').Value:=combobox5.Text;
otherinfo.Prepared;
otherinfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
otherinfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn7Click(Sender: TObject);
var
i:byte;
begin
if combobox3.Text='' then
begin
showmessage('还没有输入类型号');
combobox3.SetFocus;
exit;
end;
with DM do
begin
OtherInfo.SQL.Text:='select type_sno form book_type where type_sno=:in0';
OtherInfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
OtherInfo.Prepared;
OtherInfo.Open;
if OtherInfo.RecordCount=0 then
begin
showmessage('数据库中没有这个类型号');
OtherInfo.Close;
combobox3.SetFocus;
exit;
end;
if MessageDlg('确定要删除吗?',mtConfirmation,[mbyes,mbno],0)=mrno then
exit;
ADOConn.BeginTrans;
try
OtherInfo.SQL.Text:='delete book_type where type_smp=:in0';
Otherinfo.Parameters.ParamByName('in0').Value:=combobox3.Text;
OtherInfo.Prepared;
OtherInfo.ExecSQL;
ADOConn.CommitTrans;
except
ADOConn.RollbackTrans;
raise;
end;
OtherInfo.Close;
end;
for i:=3 to TabSheet3.ComponentCount-1 do
if TabSheet3.Components[i] is TCombobox then
TCombobox(TabSheet3.Components[i]).Text:='';
end;
procedure TOtherInfoForm.WMNCpaint(var Msg: TWMNCPaint);
begin
inherited;
Draw(OtherInfoForm);
end;
procedure TOtherInfoForm.ReadType(Sender: TObject);
begin
with DM do
begin
Otherinfo.SQL.Text:='select * from read_type';
Otherinfo.Prepared;
otherinfo.Open;
listview1.Items.Clear;
while not otherinfo.Eof do
begin
with listview1.Items.Add do
begin
caption:=otherinfo.Fields[0].AsString;
subitems.Add(otherinfo.Fields[1].AsString);
end;
otherinfo.Next;
end;
otherinfo.Close;
end;
end;
procedure TOtherInfoForm.BitBtn13Click(Sender: TObject);
begin
readtype(sender);
end;
procedure TOtherInfoForm.ListView1Click(Sender: TObject);
begin
if listview1.Selected<>nil then
begin
edit41.Text:=listview1.Selected.Caption;
edit42.Text:=listview1.Selected.SubItems.Text;
end;
end;
procedure TOtherInfoForm.BitBtn14Click(Sender: TObject);
begin
if (edit41.Text='') or (edit42.Text='') then
begin
showmessage('没有输入!');
edit41.SetFocus;
exit;
end;
with DM do
begin
Case radiogroup1.ItemIndex of
0: begin
if not DM.ValReadType(trim(edit41.Text)) then
begin
showmessage('无此类型编号');
exit;
end;
otherinfo.SQL.Text:='update read_type set book_num=:in0 where type_sno=:in1';
otherinfo.Parameters[0].Value:=trim(edit42.Text);
end;
1: begin
if dm.ValReadType(trim(edit41.Text)) then
begin
showmessage('此类型编号已经存在');
exit;
end;
otherinfo.SQL.Text:='insert into read_type(type_sno,book_num) values(:in0,:in1)';
otherinfo.Parameters[0].Value:=trim(edit41.Text);
otherinfo.Parameters[1].Value:=trim(edit42.Text);
end;
2: begin
if not dm.ValReadType(Trim(edit41.Text)) then
begin
showmessage('无此类型编号');
exit;
end;
if messagedlg('真的要删除吗?',mtConfirmation,[mbyes,mbno],0)=mrno then
exit;
otherinfo.sql.Text:='delete from read_type where type_sno=:in0';
otherinfo.Parameters[0].Value:=trim(edit41.Text);
end;
end;
Otherinfo.Prepared;
otherinfo.ExecSql;
showmessage('数据更新成功!');
otherinfo.close;
end;
readtype(sender);
end;
procedure TOtherInfoForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
OtherInfoForm:=nil;
Action:=caFree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -