📄 ustainfo.pas
字号:
dteSDate.ReadOnly := aState;
dteEDate.ReadOnly := aState;
deTrcom.ReadOnly := aState;
deCerti.ReadOnly := aState;
if aState = true then
begin
dgTrain.Enabled := true;
deCourse.Color := clSkyBlue;
deDLimit.Color := clSkyBlue;
dteSDate.Color := clSkyBlue;
dteEDate.Color := clSkyBlue;
deTrcom.Color := clSkyBlue;
deCerti.Color := clSkyBlue;
end
else
begin
dgTrain.Enabled := false;
deCourse.SetFocus;
deCourse.Color := clWindow;
deDLimit.Color := clWindow;
dteSDate.Color := clWindow;
dteEDate.Color := clWindow;
deTrcom.Color := clWindow;
deCerti.Color := clWindow;
if aqStaInfo.State = dsInsert then
begin
dteSDate.Value := IncYear(Date(), -1);
dteEDate.Value := IncYear(Date(), -1);
end;
end;
end;
end;
end;
procedure TfrmStainfo.SetState(aCon: TSetState; aOtype: TOpeType);
begin
case aOtype of
otAdd, otEdit:
begin
tvPer.Enabled := false;
btnEdit.Visible := false;
btnInqu.Visible := false;
btnPrior.Visible := false;
btnNext.Visible := false;
btnDel.Visible := false;
btnPrint.Caption := '取 消';
btnClose.Visible := false;
SetState(aCon, false);
if aOtype = otAdd then
btnAdd.Caption := '提 交'
else
begin
btnAdd.Caption := '确 定';
end;
end;
otCancel:
begin
tvPer.Enabled := true;
btnEdit.Visible := true;
btnAdd.Caption := '添 加';
btnInqu.Visible := true;
btnPrior.Visible := true;
btnNext.Visible := true;
btnDel.Visible := true;
btnPrint.Caption := '打 印';
btnClose.Visible := true;
SetState(aCon, true);
if aqStaInfo.State in [dsEdit, dsInsert] then
begin
aqStaInfo.Cancel;
aqStaInfo.CancelBatch;
end;
end;
end;
end;
procedure TfrmStainfo.AddData(aCon: TSetState);
procedure UpdateRecord;
procedure FindTree(aNo: string);
var
i: Integer;
begin
for i := 0 to tvPer.Items.Count - 1 do
begin
if tvPer.Items[i].Data <> nil then
if Psid(tvPer.Items[i].Data)^.sNo = aNo then
begin
tvPer.Items[i].Selected := true;
tvPer.Setfocus;
Break;
end;
end;
end;
var
sNo: string;
begin
try
if pcSta.ActivePageIndex <> 0 then
aqStaInfo.FieldByName('sid').AsInteger := id
else
sNo := edtStano.Text;
aqStaInfo.Post;
aqStaInfo.UpdateBatch();
if aqStaInfo.RecordCount = 0 then
btnEdit.Enabled := false
else
btnEdit.Enabled := true;
SetState(aCon, otCancel);
if pcSta.ActivePageIndex = 0 then
begin
DrawTree;
FindTree(sNo);
end;
except
MessageBox(self.Handle, '记录添加失败!', '提示', mb_IconInformation + mb_Ok);
end;
end;
begin
case aCon of
ssSta:
begin
if edtStano.Text = '' then
begin
MessageBox(self.Handle, '请输入工号!', '提示', mb_IconInformation + mb_Ok);
edtStano.SetFocus;
Abort;
end;
if edtName.Text = '' then
begin
MessageBox(self.Handle, '请输入员工姓名!', '提示', mb_IconInformation + mb_Ok);
edtName.SetFocus;
Abort;
end;
if cboSex.Text = '' then
begin
MessageBox(self.Handle, '请选择员工性别!', '提示', mb_IconInformation + mb_Ok);
cboSex.SetFocus;
Abort;
end;
if deBirth.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入员工生日,用以统计年龄段!', '提示', mb_IconInformation + mb_Ok);
deBirth.SetFocus;
Abort;
end;
if dcbDep.Text = '' then
begin
MessageBox(self.Handle, '请选择员工部门!', '提示', mb_IconInformation + mb_Ok);
dcbDep.SetFocus;
Abort;
end;
if deInDate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入入司时间!', '提示', mb_IconInformation + mb_Ok);
deInDate.SetFocus;
Abort;
end;
UpDateRecord;
end;
ssExper:
begin
if deSDate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入开始时间!', '提示', mb_IconInformation + mb_Ok);
deSDate.SetFocus;
Abort;
end;
if deEdate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入结束时间!', '提示', mb_IconInformation + mb_Ok);
deEdate.SetFocus;
Abort;
end;
if deCom.Text = '' then
begin
MessageBox(self.Handle, '请输入公司名!', '提示', mb_IconInformation + mb_Ok);
deCom.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssFami:
begin
if dbeName.Text = '' then
begin
MessageBox(self.Handle, '请输入家人姓名!', '提示', mb_IconInformation + mb_Ok);
dbeName.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssAP:
begin
if dbSort.Text = '' then
begin
MessageBox(self.Handle, '请选择类别!', '提示', mb_IconInformation + mb_Ok);
dbSort.SetFocus;
Abort;
end;
if deTopic.Text = '' then
begin
MessageBox(self.Handle, '请输入事件!', '提示', mb_IconInformation + mb_Ok);
deTopic.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssTrain:
begin
if deCourse.Text = '' then
begin
MessageBox(self.Handle, '请输入培训课程!', '提示', mb_IconInformation + mb_Ok);
deCourse.SetFocus;
Abort;
end;
if deDLimit.Text = '' then
begin
MessageBox(self.Handle, '请输入培训期限!', '提示', mb_IconInformation + mb_Ok);
deDLimit.SetFocus;
Abort;
end;
UpdateRecord;
end;
end;
end;
procedure TfrmStainfo.UpdateData(aCon: TSetState);
procedure UpdateRecord;
procedure FindTree(aNo: string);
var
i: Integer;
begin
for i := 0 to tvPer.Items.Count - 1 do
begin
if tvPer.Items[i].Data <> nil then
if Psid(tvPer.Items[i].Data)^.sNo = aNo then
begin
tvPer.Items[i].Selected := true;
tvPer.Setfocus;
Break;
end;
end;
end;
var
sNo, sDep: string;
begin
if tvPer.Selected.Data <> nil then
begin
sNo := Psid(tvPer.Selected.Data)^.sNo;
sDep := tvPer.Selected.Parent.Text;
end;
try
aqStaInfo.Post;
aqStaInfo.UpdateBatch();
SetState(aCon, otCancel);
if (sDep <> dcbDep.Text) and (pcSta.ActivePageIndex = 0) then
begin
DrawTree;
FindTree(sNo);
end;
except
MessageBox(self.Handle, '记录更新失败!', '提示', mb_IconInformation + mb_Ok);
end;
end;
begin
case aCon of
ssSta:
begin
if edtName.Text = '' then
begin
MessageBox(self.Handle, '请输入员工姓名!', '提示', mb_IconInformation + mb_Ok);
edtName.SetFocus;
Abort;
end;
if cboSex.Text = '' then
begin
MessageBox(self.Handle, '请选择员工性别!', '提示', mb_IconInformation + mb_Ok);
cboSex.SetFocus;
Abort;
end;
if deBirth.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入员工生日,用以统计年龄段!', '提示', mb_IconInformation + mb_Ok);
deBirth.SetFocus;
Abort;
end;
if dcbDep.Text = '' then
begin
MessageBox(self.Handle, '请选择员工部门!', '提示', mb_IconInformation + mb_Ok);
dcbDep.SetFocus;
Abort;
end;
if deInDate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入入司时间!', '提示', mb_IconInformation + mb_Ok);
deInDate.SetFocus;
Abort;
end;
UpDateRecord;
end;
ssExper:
begin
if deSDate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入开始时间!', '提示', mb_IconInformation + mb_Ok);
deSDate.SetFocus;
Abort;
end;
if deEdate.Text = ' - - ' then
begin
MessageBox(self.Handle, '请输入结束时间!', '提示', mb_IconInformation + mb_Ok);
deEdate.SetFocus;
Abort;
end;
if deCom.Text = '' then
begin
MessageBox(self.Handle, '请输入公司名!', '提示', mb_IconInformation + mb_Ok);
deCom.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssFami:
begin
if dbeName.Text = '' then
begin
MessageBox(self.Handle, '请输入家人姓名!', '提示', mb_IconInformation + mb_Ok);
dbeName.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssAP:
begin
if dbSort.Text = '' then
begin
MessageBox(self.Handle, '请选择类别!', '提示', mb_IconInformation + mb_Ok);
dbSort.SetFocus;
Abort;
end;
if deTopic.Text = '' then
begin
MessageBox(self.Handle, '请输入事件!', '提示', mb_IconInformation + mb_Ok);
deTopic.SetFocus;
Abort;
end;
UpdateRecord;
end;
ssTrain:
begin
if deCourse.Text = '' then
begin
MessageBox(self.Handle, '请输入培训课程!', '提示', mb_IconInformation + mb_Ok);
deCourse.SetFocus;
Abort;
end;
if deDLimit.Text = '' then
begin
MessageBox(self.Handle, '请输入培训期限!', '提示', mb_IconInformation + mb_Ok);
deDLimit.SetFocus;
Abort;
end;
UpdateRecord;
end;
end;
end;
procedure TfrmStainfo.FormShow(Sender: TObject);
begin
self.DoubleBuffered := true;
DrawTree;
pcsta.ActivePageIndex := 0;
SetState(ssSta, true);
end;
procedure TfrmStainfo.tvPerCollapsed(Sender: TObject; Node: TTreeNode);
begin
tvPer.Repaint;
end;
procedure TfrmStainfo.tvPerChanging(Sender: TObject; Node: TTreeNode;
var AllowChange: Boolean);
begin
if Node.IsFirstNode then
gbPer.Caption := Node.Text
else if (not Node.IsFirstNode) and Node.HasChildren then
gbPer.Caption := '部门: ' + Node.Text
else if not Node.HasChildren then
begin
if Node.Data <> nil then
begin
gbPer.Caption := '员工: ' + Node.Parent.Text + ' --> ' + Node.Text;
ID := Integer(Psid(Node.Data)^.ID);
btnEditi.Enabled := true;
btnDeli.Enabled := true;
case pcSta.ActivePageIndex of
0: tsStainfoShow(Sender);
1: tsExperShow(Sender);
2: tsFamiShow(Sender);
3: tsAPShow(Sender);
4: tstrainShow(Sender);
end;
end
else
begin
if pcSta.ActivePageIndex = 0 then
begin
btnEditi.Enabled := false;
btnDeli.Enabled := false;
end;
end;
end;
end;
procedure TfrmStainfo.tvPerClick(Sender: TObject);
begin
if not tvPer.Selected.HasChildren then
begin
if tvPer.Selected.Data <> nil then
begin
ID := Integer(Psid(tvPer.Selected.Data)^.ID);
btnEditi.Enabled := true;
btnDeli.Enabled := true;
case pcSta.ActivePageIndex of
0: tsStainfoShow(Sender);
1: tsExperShow(Sender);
2: tsFamiShow(Sender);
3: tsAPShow(Sender);
4: tstrainShow(Sender);
end;
end
else
if pcSta.ActivePageIndex = 0 then
begin
btnEditi.Enabled := false;
btnDeli.Enabled := false;
end;
end;
if pcSta.ActivePageIndex = 5 then
tsStainfo.Show;
end;
procedure TfrmStainfo.tsStainfoShow(Sender: TObject);
var
i: integer;
begin
if aqStaInfo.State in [dsEdit, dsInsert] then
begin
aqStaInfo.Cancel;
aqStaInfo.CancelBatch;
end;
dmPer.OpenDep;
aqStaInfo := dmPer.aqDep;
if not aqStaInfo.Eof then
begin
dcbDep.Clear;
for i :=0 to aqStaInfo.RecordCount - 1 do
begin
dcbDep.AddItem(aqStaInfo.FieldByName('dep').AsString, nil);
aqStaInfo.Next;
end;
end;
dmPer.OpenStaInfo(IntToStr(ID));
aqStaInfo := dmPer.aqSta;
if (btnAdd.Caption = '提 交') and (aqStaInfo.State <> dsInsert) then
begin
aqStaInfo.Append;
SetState(ssSta, false);
Exit;
end
else if (btnAdd.Caption = '确 定') and (aqStaInfo.State <> dsEdit) then
begin
aqStaInfo.Edit;
SetState(ssSta, false);
Exit;
end;
if FileExists(ExtractFilePath(Application.ExeName) + 'images\' + aqStaInfo.FieldByName('image').AsString) then
imgi.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'images\' + aqStaInfo.FieldByName('image').AsString)
else
imgi.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) + 'images\imgd.jpg');
aqStaInfo.Refresh;
SetState(ssSta, true);
if aqStaInfo.RecordCount = 0 then
btnEdit.Enabled := false
else
btnEdit.Enabled := true;
end;
procedure TfrmStainfo.tsExperShow(Sender: TObject);
begin
if aqStaInfo.State in [dsEdit, dsInsert] then
begin
aqStaInfo.Cancel;
aqStaInfo.CancelBatch;
end;
dmPer.OpenExper(IntToStr(ID));
aqStaInfo := dmPer.aqExper;
if (btnAdd.Caption = '提 交') and (aqStaInfo.State <> dsInsert) then
begin
aqStaInfo.Append;
SetState(ssExper, false);
Exit;
end
else if (btnAdd.Caption = '确 定') and (aqStaInfo.State <> dsEdit) then
begin
aqStaInfo.Edit;
SetState(ssExper, false);
Exit;
end;
SetState(ssExper, true);
if aqStaInfo.RecordCount = 0 then
btnEdit.Enabled := false
else
btnEdit.Enabled := true;
end;
procedure TfrmStainfo.tsFamiShow(Sender: TObject);
begin
if aqStaInfo.State in [dsEdit, dsInsert] then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -