📄 unitemployee.pas
字号:
end;
procedure TFrmEmployee.DBComboBox9Enter(Sender: TObject);
begin
GetItemList(Sender,'MMember');
end;
procedure TFrmEmployee.GetItemList(Sender: TObject; FieldName: String);
begin
DMMain.ADOQRS1.Close;
DMMain.ADOQRS1.SQL.Text:='select distinct '+FieldName+' from Employee where '+FieldName+' is not null or RTrim('+FieldName+')<>''''';
DMMain.ADOQRS1.Open;
with Sender as TDBComboBox do begin
Items.Clear;
while not DMMain.ADOQRS1.Eof do begin
Items.Add(Trim(DMMain.ADOQRS1.FieldByName(FieldName).AsString));
DMMain.ADOQRS1.Next;
end;
end;
end;
procedure TFrmEmployee.SpeedButton1Click(Sender: TObject);
begin
// 关闭窗口
if MessageBox(Handle,'请确认您的数据已经保存。'+#13+'您是否真的要退出?','系统信息',MB_YESNO+32)=IDYES then begin
if DBEdit1.Text<>'' then begin
if DMMain.adotblEmployee.Modified then DMMain.adotblEmployee.Post;
end else begin
if DMMain.adotblEmployee.Modified then DMMain.adotblEmployee.Cancel;
end;
Close;
end;
end;
procedure TFrmEmployee.DBEdit18Exit(Sender: TObject);
var
Y1,M1,D1:Word;
begin
// 参工日期合法性检验
if (Trim(DBEdit18.Text)<>'- -') and (Trim(DBEdit3.Text)<>'- -') then begin
DecodeDate(StrToDate(DBEdit3.Text),Y1,M1,D1);
if EncodeDate(Y1+18,M1,D1)>StrToDate(DBEdit18.Text) then begin
frmDialog:=TfrmDialog.Create(Application);
try
if frmDialog.ShowModal<>mrYes then
DBEdit18.SetFocus
else
DBComboBox10.SetFocus;
finally
frmDialog.Free;
end;
end;
end;
end;
procedure TFrmEmployee.DBEdit17Exit(Sender: TObject);
begin
// 入厂日期合法性检验
if (Trim(DBEdit18.Text)<>'- -') and (Trim(DBEdit17.Text)<>'- -') then begin
if StrToDate(DBEdit18.Text)>StrToDate(DBEdit17.Text) then begin
MessageBox(Handle,'入厂日期不得小于参工日期。','系统警告',48);
DBEdit17.SetFocus;
end;
end;
end;
procedure TFrmEmployee.DBComboBox2Change(Sender: TObject);
begin
if DBComboBox2.Text='已婚' then begin
DBComboBox7.Enabled:=true;
end else begin
DMMain.adotblEmployee.FieldByName('MPWork').AsString:='';
DBComboBox7.Enabled:=false;
end;
end;
procedure TFrmEmployee.DBEdit16Exit(Sender: TObject);
begin
// 离职日期合法性检验
if (Trim(DBEdit16.Text)<>'- -') and (Trim(DBEdit17.Text)<>'- -') then begin
if StrToDate(DBEdit17.Text)>StrToDate(DBEdit16.Text) then begin
MessageBox(Handle,'离职日期不得小于入厂日期。','系统警告',48);
DBEdit16.SetFocus;
end;
end;
end;
procedure TFrmEmployee.DBComboBox14Enter(Sender: TObject);
begin
GetItemList(Sender,'MRegPostalcode');
end;
procedure TFrmEmployee.DBComboBox15Enter(Sender: TObject);
begin
GetItemList(Sender,'MCurPostalcode');
end;
procedure TFrmEmployee.DBComboBox16Enter(Sender: TObject);
begin
GetItemList(Sender,'MNative');
end;
procedure TFrmEmployee.DBComboBox18Enter(Sender: TObject);
begin
DMMain.ADOQRS1.Close;
DMMain.ADOQRS1.SQL.Text:='select distinct MFAppellation from (';
DMMain.ADOQRS1.SQL.Add('select MFAppellation1 as MFAppellation from Employee where MFAppellation1 is not null or RTrim(MFAppellation1)<>''''');
DMMain.ADOQRS1.SQL.Add('union all');
DMMain.ADOQRS1.SQL.Add('select MFAppellation2 as MFAppellation from Employee where MFAppellation2 is not null or RTrim(MFAppellation2)<>''''');
DMMain.ADOQRS1.SQL.Add('union all');
DMMain.ADOQRS1.SQL.Add('select MFAppellation3 as MFAppellation from Employee where MFAppellation3 is not null or RTrim(MFAppellation3)<>''''');
DMMain.ADOQRS1.SQL.Add('union all');
DMMain.ADOQRS1.SQL.Add('select MFAppellation4 as MFAppellation from Employee where MFAppellation4 is not null or RTrim(MFAppellation4)<>''''');
DMMain.ADOQRS1.SQL.Add('union all');
DMMain.ADOQRS1.SQL.Add('select MFAppellation5 as MFAppellation from Employee where MFAppellation5 is not null or RTrim(MFAppellation5)<>''''');
DMMain.ADOQRS1.SQL.Add(')');
DMMain.ADOQRS1.Open;
with Sender as TDBComboBox do begin
Items.Clear;
while not DMMain.ADOQRS1.Eof do begin
Items.Add(Trim(DMMain.ADOQRS1.FieldByName('MFAppellation').AsString));
DMMain.ADOQRS1.Next;
end;
end;
end;
procedure TFrmEmployee.DBEdit21Exit(Sender: TObject);
begin
// 家庭收入合法性检验
try
if (Trim(DBEdit20.Text)<>'') and (Trim(DBEdit21.Text)<>'') and (StrToInt(DBEdit21.Text)<StrToInt(DBEdit20.Text)) then begin
MessageBox(Handle,'家庭收入不得小于月收入。','系统警告',48);
DBEdit21.SetFocus;
end;
except
raise Exception.Create('家庭收入格式非法!');
end;
end;
procedure TFrmEmployee.DBEdit20Exit(Sender: TObject);
begin
// 月收入合法性检验
try
if (Trim(DBEdit20.Text)<>'') and (Trim(DBEdit21.Text)<>'') and (StrToInt(DBEdit21.Text)<StrToInt(DBEdit20.Text)) then begin
MessageBox(Handle,'家庭收入不得小于月收入。','系统警告',48);
DBEdit21.SetFocus;
end;
except
raise Exception.Create('月收入格式非法!');
end;
end;
procedure TFrmEmployee.DBEdit6KeyPress(Sender: TObject; var Key: Char);
begin
if (Key<>#0) and not (Char(Key) in [^V,^X,^C,'0','1','2','3','4','5','6','7','8','9','x','X']) then begin
Key:=#0;
end;
end;
function TFrmEmployee.CheckIDCard(IDCard: String): Boolean;
var
Str,StrCRC:String;
I,CRC:Integer;
begin
Str:=Copy(IDCard,1,17);
CRC:=0;
for I:=18 downto 2 do
CRC:=CRC+(Round(IntPower(2,(I-1))) mod 11)*StrToInt(Copy(Str,19-I,1));
CRC:=CRC mod 11;
case CRC of
0:StrCRC:='1';
1:StrCRC:='0';
2:StrCRC:='X';
3:StrCRC:='9';
4:StrCRC:='8';
5:StrCRC:='7';
6:StrCRC:='6';
7:StrCRC:='5';
8:StrCRC:='4';
9:StrCRC:='3';
10:StrCRC:='2';
end;
Result:=StrCRC=IDCard[18];
end;
procedure TFrmEmployee.RaiseError;
begin
DBEdit6.SetFocus;
MessageBeep(0);
raise Exception.Create('身份证号码格式非法!');
end;
function TFrmEmployee.UpdateIDCard(OldIDCard: String): String;
var
Str,StrCRC:String;
I,CRC:Integer;
begin
Str:=Copy(OldIDCard,1,6)+'19'+Copy(OldIDCard,7,9);
CRC:=0;
for I:=18 downto 2 do
CRC:=CRC+(Round(IntPower(2,(I-1))) mod 11)*StrToInt(Copy(Str,19-I,1));
CRC:=CRC mod 11;
case CRC of
0:StrCRC:='1';
1:StrCRC:='0';
2:StrCRC:='X';
3:StrCRC:='9';
4:StrCRC:='8';
5:StrCRC:='7';
6:StrCRC:='6';
7:StrCRC:='5';
8:StrCRC:='4';
9:StrCRC:='3';
10:StrCRC:='2';
end;
Result:=Str+StrCRC;
end;
procedure TFrmEmployee.DBComboBox10Change(Sender: TObject);
begin
if DBComboBox10.Text='在岗' then begin
DMMain.adotblEmployee.FieldByName('MF5').AsString:='';
DBComboBox27.Enabled:=false;
end else begin
DBComboBox27.Enabled:=True;
end;
end;
procedure TFrmEmployee.DBNavigator1Click(Sender: TObject;
Button: TNavigateBtn);
begin
DBEdit1.SetFocus;
end;
procedure TFrmEmployee.DBComboBox1Change(Sender: TObject);
var
Y1,M1,D1,Y2,M2,D2:Word;
begin
// 计算离退休的年月
if (Trim(DBEdit3.Text)<>'') and (DBComboBox1.ItemIndex>=0) then begin
DecodeDate(StrToDate(DBEdit3.Text),Y2,M2,D2);
DecodeDate(Date,Y1,M1,D1);
D1:=(Y2+60-DBComboBox1.ItemIndex*10-Y1)*12+M2-M1;
Edit2.Text:=IntToStr(D1 div 12)+'年'+IntToStr(D1 mod 12)+'月';
end else begin
Edit2.Text:='';
end;
end;
procedure TFrmEmployee.DBNavigator2Click(Sender: TObject;
Button: TNavigateBtn);
begin
DBComboBox1Change(Sender);
end;
procedure TFrmEmployee.DBNavigator1BeforeAction(Sender: TObject;
Button: TNavigateBtn);
begin
if Button=nbPost then
DBEdit6Exit(Sender);
end;
procedure TFrmEmployee.DBMemo1Enter(Sender: TObject);
begin
FrmEmployee.KeyPreview:=false;
end;
procedure TFrmEmployee.DBMemo1Exit(Sender: TObject);
begin
FrmEmployee.KeyPreview:=true;
end;
procedure TFrmEmployee.DBEdit14Exit(Sender: TObject);
begin
if Trim(DBEdit14.Text)=Trim(DBEdit11.Text) then begin
DMMain.adotblEmployee.FieldByName('MCurPostalcode').AsString:=DBEdit28.Text;
DMMain.adotblEmployee.FieldByName('MCurArea').AsString:=DBComboBox11.Text;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -