📄 unit35.pas
字号:
unit Unit35;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls,IdGlobal;
type
TForm35 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
employeeid: TEdit;
Button3: TButton;
GroupBox2: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
employeename: TEdit;
gender: TComboBox;
edu: TComboBox;
politic: TComboBox;
married: TComboBox;
birthday: TDateTimePicker;
idcard: TEdit;
jointime: TDateTimePicker;
employeerank: TComboBox;
workgroup: TComboBox;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function isInteger(s:string):boolean;
public
{ Public declarations }
end;
var
Form35: TForm35;
implementation
uses Unit6, Unit7;
{$R *.dfm}
procedure TForm35.FormCreate(Sender: TObject);
begin
{初始化生日和入会时间}
birthDay.Date:=now;
joinTime.Date:=now;
{没验证员工编号前不可修改}
button1.Enabled:=false;
end;
procedure TForm35.Button2Click(Sender: TObject);
begin
form6.table1.Close;
close;
end;
procedure TForm35.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form6.table1.Close;
end;
procedure TForm35.Button3Click(Sender: TObject);
var
flag:boolean;
i:integer;
begin
{验证员工编号的合法性}
if isInteger(employeeId.Text)=false then
begin
messageDlg('输入编号不合法',mtWarning,[mbOk],0);
activeControl:=employeeId;
exit;
end;
{验证员工编号的存在性}
flag:=false;
with form6.table1 do
begin
open;
first;
while not eof do
begin
if fieldByName('员工编号').AsString=employeeId.Text then
begin
flag:=true;
break;
end;
next;
end;
if flag=false then//员工不存在
begin
messageDlg('输入编号不存在',mtWarning,[mbOk],0);
button1.Enabled:=false;
exit;
end;
end;
button1.Enabled:=true;
{显示此员工的信息}
with form6.table1 do
begin
employeeName.Text:=fieldByName('员工姓名').asString;
i:=gender.Items.IndexOf(fieldByName('性别').asString);
gender.ItemIndex:=i;
idcard.Text:=fieldByName('身份证号').asString;
i:=edu.Items.IndexOf(fieldByName('学历').asString);
edu.ItemIndex:=i;
birthDay.Date:=fieldByName('生日').AsDateTime;
joinTime.Date:=fieldByName('聘任日期').AsDateTime;
i:=politic.Items.IndexOf(fieldByName('政治面貌').asString);
politic.ItemIndex:=i;
i:=married.Items.IndexOf(fieldByName('婚姻状况').asString);
married.ItemIndex:=i;
i:=employeerank.Items.IndexOf(fieldByName('员工等级').asString);
employeerank.ItemIndex:=i;
i:=workgroup.Items.IndexOf(fieldByName('工作部门').asString);
workgroup.ItemIndex:=i;
end;
end;
procedure TForm35.Button1Click(Sender: TObject);
var
i:integer;
id:integer;
begin
i:=messageDlg('确定要删除员工记录?',mtWarning,[mbYes,mbNo],0);
if i=6 then
begin
{记录要删除记录的关键字}
id:=strtoint(employeeId.Text);
{删除这一条记录}
form6.table1.Delete;
{清屏并且删除按钮不可用}
employeeId.Text:='';
employeeName.Text:='';
gender.ItemIndex:=0;
idcard.Text:='';
edu.ItemIndex:=0;
birthDay.Date:=now;
joinTime.Date:=now;
politic.ItemIndex:=0;
married.ItemIndex:=0;
employeerank.ItemIndex:=0;
workgroup.ItemIndex:=0;
activeControl:=employeeId;
{让数据控件dbGrid1同步显示}
with form7.sqlemployee do
begin
close;
sql.Clear;
sql.Add('select * from employee');
open;
end;
end;
end;
function Tform35.isInteger(s: string): boolean;
var
i:integer;
begin
i:=1;
if length(s)=0 then
begin
result:=false;
exit;
end;
while i<=length(s) do
begin
if (isNumeric(s[i])=false) then
begin
result:=false;
exit;
end;
i:=i+1;
end;
result:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -