📄 unit8.pas
字号:
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, ComCtrls;
type
Ttianjia = class(TForm)
GroupBox2: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
GroupBox1: TGroupBox;
Button1: TButton;
Button2: TButton;
Label14: TLabel;
Edit14: TEdit;
Edit15: TEdit;
Label15: TLabel;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DateTimePicker1: TDateTimePicker;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure DateTimePicker1Change(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
tianjia: Ttianjia;
implementation
{$R *.dfm}
procedure Ttianjia.Button2Click(Sender: TObject);
var
aa:integer;
begin
aa:=application.MessageBox('真的要取消添加?','提示信息',Mb_ICONQUESTION+MB_OKCANCEL);
if aa=1 then
begin
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
edit8.Text:='';
edit9.Text:='';
edit10.Text:='';
edit11.Text:='';
edit12.Text:='';
edit13.Text:='';
edit14.Text:='';
edit15.Text:='';
close;
end;
end;
procedure Ttianjia.Button1Click(Sender: TObject);
begin
if Edit2.text='' then
begin//a
application.MessageBox('请输入员工号!','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit2.SetFocus;
exit;
end;//a
adoquery1.SQL.Clear;
adoquery1.SQL.add('select * from Info where zhigongnum=:num');
adoquery1.Parameters.ParamByName('num').Value:=edit2.Text;
adoquery1.Active:=true;
if adoquery1.Recordset.RecordCount=1 then
begin//执行这里说明已有了
application.MessageBox('员工号已存在,请再次填写!','提示信息',Mb_ICONexclamaTION+MB_OK);
edit2.Text:='';
edit2.SetFocus;
exit;
end; //执行这里说明已有了
if Edit3.text='' then
begin//a
application.MessageBox('请输入姓名','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit3.SetFocus;
exit;
end;//a
if Edit4.text='' then
begin//a
application.MessageBox('请输入性别','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit4.SetFocus;
exit;
end;//a
if Edit5.text='' then
begin//a
application.MessageBox('请输入出生年月','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit5.SetFocus;
exit;
end;//a
if Edit6.text='' then
begin//a
application.MessageBox('请输入身份证号','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit6.SetFocus;
exit;
end;//a
if Edit7.text='' then
begin//a
application.MessageBox('请输入联系电话','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit7.SetFocus;
exit;
end;//a
if Edit8.text='' then
begin//a
application.MessageBox('请输入通信地址','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit8.SetFocus;
exit;
end;//a
if Edit9.text='' then
begin//a
application.MessageBox('请输入工资','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit9.SetFocus;
exit;
end;//a
if Edit10.text='' then
begin//a
application.MessageBox('请输入工作部门','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit10.SetFocus;
exit;
end;//a
if Edit11.text='' then
begin//a
application.MessageBox('请输入职务','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit11.SetFocus;
exit;
end;//a
if Edit12.text='' then
begin//a
application.MessageBox('请输入专业','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit12.SetFocus;
exit;
end;//a
if Edit13.text='' then
begin//a
application.MessageBox('请输入备注','提示信息',Mb_ICONexclamaTION+MB_OK);
Edit13.SetFocus;
exit;
end;//a
ADOQuery1.SQL.Text:='insert into Info(zhigongnum,Name,Sex,Birthday,ID,Phone,Address,Salary,Unit,Duty,Speciality,Notee,Operator,Stamp)'+
'values(:zhigongnum,:Name,:Sex,:Birthday,:ID,:Phone,:Address,:Salary,:Unit,:Duty,:Speciality,:Notee,:Operator,:Stamp)';
ADOQuery1.Parameters.ParamByName('zhigongnum').Value:=edit2.Text;
ADOQuery1.Parameters.ParamByName('Name').Value:=edit3.Text;
ADOQuery1.Parameters.ParamByName('Sex').Value:=edit4.Text;
ADOQuery1.Parameters.ParamByName('Birthday').Value:=edit5.Text;
ADOQuery1.Parameters.ParamByName('ID').Value:=edit6.Text;
ADOQuery1.Parameters.ParamByName('Phone').Value:=edit7.Text;
ADOQuery1.Parameters.ParamByName('Address').Value:=edit8.Text;
ADOQuery1.Parameters.ParamByName('Salary').Value:=edit9.Text;
ADOQuery1.Parameters.ParamByName('Unit').Value:=edit10.Text;
ADOQuery1.Parameters.ParamByName('Duty').Value:=edit11.Text;
ADOQuery1.Parameters.ParamByName('Speciality').Value:=edit12.Text;
ADOQuery1.Parameters.ParamByName('Notee').Value:=edit13.Text;
ADOQuery1.Parameters.ParamByName('Operator').Value:=edit14.Text;
ADOQuery1.Parameters.ParamByName('Stamp').Value:=edit15.Text;
ADOQuery1.ExecSQL;
ADOQuery1.Close;
application.MessageBox('添加成功','提示信息',Mb_ICONexclamaTION+MB_OK);
close;
end;
procedure Ttianjia.DateTimePicker1Change(Sender: TObject);
begin
Edit5.Text:=datetostr(datetimepicker1.Date);
end;
procedure Ttianjia.FormClose(Sender: TObject; var Action: TCloseAction);
begin
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
edit8.Text:='';
edit9.Text:='';
edit10.Text:='';
edit11.Text:='';
edit12.Text:='';
edit13.Text:='';
edit14.Text:='';
edit15.Text:='';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -