📄 dep.pas
字号:
unit dep;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, base, ExtCtrls, SUIForm, SUIButton, SUIPageControl,
SUITabControl, DB, StdCtrls, SUIEdit, Grids, DBGridEh, SUIComboBox;
type
Tfrmdepset = class(Tbaseform)
suiPageControl1: TsuiPageControl;
suiTabSheet1: TsuiTabSheet;
suiTabSheet2: TsuiTabSheet;
btnclose: TsuiButton;
DBGridEh1: TDBGridEh;
edtdep: TsuiEdit;
btnnew: TsuiButton;
btndel: TsuiButton;
dsdep: TDataSource;
dsmajor: TDataSource;
DBGridEh2: TDBGridEh;
edtmajor: TsuiEdit;
cbxdep: TsuiComboBox;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
suiButton3: TsuiButton;
procedure btncloseClick(Sender: TObject);
procedure btnnewClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btndelClick(Sender: TObject);
procedure suiTabSheet2Enter(Sender: TObject);
procedure suiButton1Click(Sender: TObject);
procedure suiButton2Click(Sender: TObject);
private
procedure iniform;
{ Private declarations }
public
{ Public declarations }
end;
var
frmdepset: Tfrmdepset;
implementation
uses dm, pub, umain, adodb;
{$R *.dfm}
procedure Tfrmdepset.btncloseClick(Sender: TObject);
begin
inherited;
close;
end;
procedure tfrmdepset.iniform;
begin
edtdep.Clear;
edtmajor.Clear;
cbxdep.ItemIndex:=-1;
end;
procedure Tfrmdepset.btnnewClick(Sender: TObject);
begin
inherited;
if trim(edtdep.Text)='' then
begin
application.MessageBox('请输入系名称!','提示',mb_ok+mb_iconinformation);
edtdep.SetFocus;
exit;
end;
frmmain.adc.BeginTrans;
try
with codedm.adqdep do
begin
sql.Clear;
sql.Add('insert into dep (dep) values (:v1)');
parameters.ParamByName('v1').Value :=trim(edtdep.Text);
execsql;
end;
frmmain.adc.CommitTrans;
application.MessageBox('记录保存成功!','提示',mb_ok+mb_iconinformation);
pub.showrecord(codedm.adqdep,'*','dep','id');
iniform;
except
frmmain.adc.RollbackTrans;
raise;
application.MessageBox('记录保存失败!','警告',mb_ok+mb_iconwarning);
pub.showrecord(codedm.adqdep,'*','dep','id');
end;
end;
procedure Tfrmdepset.FormCreate(Sender: TObject);
begin
inherited;
pub.showrecord(codedm.adqdep,'*','dep','id');
pub.showrecord(codedm.adqmajor,'*','major','id');
end;
procedure Tfrmdepset.btndelClick(Sender: TObject);
begin
inherited;
if codedm.adqdep.IsEmpty then
begin
application.MessageBox('系信息表为空!','提示',mb_ok+mb_iconinformation);
exit;
end;
if application.MessageBox('确定要删除这条记录?','提示',mb_yesno+mb_iconquestion)=idyes then
codedm.adqdep.Delete;
end;
procedure Tfrmdepset.suiTabSheet2Enter(Sender: TObject);
var tmp:tadoquery;
begin
inherited;
cbxdep.Clear;
tmp:=tadoquery.Create(nil);
tmp.ConnectionString:=frmmain.adc.ConnectionString;
try
pub.showrecord(tmp,'*','dep','id');
while not tmp.Eof do
begin
cbxdep.Items.Add(tmp.fieldbyname('dep').AsString);
tmp.Next;
end;
finally
tmp.Free;
end;
end;
procedure Tfrmdepset.suiButton1Click(Sender: TObject);
begin
inherited;
if (trim(edtmajor.Text)='')or(cbxdep.Text='') then
begin
application.MessageBox('信息不完整!','提示',mb_ok+mb_iconinformation);
exit;
end;
frmmain.adc.BeginTrans;
try
with codedm.adqmajor do
begin
sql.Clear;
sql.Add('insert into major (dep,major) values (:v1,:v2)');
parameters.ParamByName('v1').Value :=cbxdep.Text;
parameters.ParamByName('v2').Value :=trim(edtmajor.Text);
execsql;
end;
frmmain.adc.CommitTrans;
application.MessageBox('记录保存成功!','提示',mb_ok+mb_iconinformation);
pub.showrecord(codedm.adqmajor,'*','major','id');
iniform;
except
frmmain.adc.RollbackTrans;
raise;
application.MessageBox('记录保存失败!','提示',mb_ok+mb_iconwarning);
pub.showrecord(codedm.adqmajor,'*','major','id');
end;
end;
procedure Tfrmdepset.suiButton2Click(Sender: TObject);
begin
inherited;
if codedm.adqmajor.IsEmpty then
begin
application.MessageBox('专业信息表为空!','提示',mb_ok+mb_iconinformation);
exit;
end;
if application.MessageBox('确定要删除这条记录?','提示',mb_yesno+mb_iconquestion)=idyes then
codedm.adqmajor.Delete;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -