📄 fmain.~pas
字号:
self.ReadStencil[11]:= ReadString('Stencil', 'BY', 'BY');
self.ReadStencil[12]:= ReadString('Stencil', 'WY', 'WY');
self.ReadStencil[13]:= ReadString('Stencil', 'CD', 'CD');
self.ReadStencil[14]:= ReadString('Stencil', 'DH', 'DH');
self.ReadStencil[15]:= ReadString('Stencil', 'JD', 'JD');
self.ReadStencil[16]:= ReadString('Stencil', 'JR', 'JR');
self.ReadStencil[17]:= ReadString('Stencil', 'DY', 'DY');
self.ReadDataControl:= ReadString('ToolBar', 'DataControl', '1');
self.ReadSheet:= ReadString('ToolBar', 'Sheet', '1');
self.ReadStyle:= ReadString('Sheet', 'Style', '1');
self.ReadSaveOut:= ReadString('System', 'SaveOut', '0');
self.ReadAutoMessage:= ReadString('System', 'AutoMessage', '1');
self.Readeidolon:= ReadString('System','eidolon','1');
end;
ReadIni.Free;
End;
Procedure TMain.LoadForm(Form:TForm);
Var
MyFormSettings:TRegistry;
Begin
MyFormSettings:=TRegistry.Create;
Try
MyFormSettings.OpenKey('\Software\'+ ExtractFileName(Application.Exename)+ '\WinPos', TRUE);
If MyFormSettings.ValueExists(Form.Name) Then
Begin
If (MyFormSettings.ReadInteger(Form.Name+'_ScrWidth')=Screen.Width) Or (MyFormSettings.ReadInteger(Form.Name+'_ScrHeight')=Screen.Height) Then
Begin
Case MyFormSettings.ReadInteger(Form.Name+'_WindowState') Of
1:Form.WindowState:=wsNormal;
2:Form.WindowState:=wsMinimized;
3:Form.WindowState:=wsMaximized;
End;
if Form.WindowState<>wsMaximized then
begin
Form.Top:=MyFormSettings.ReadInteger(Form.Name+'_Top');
Form.Left:=MyFormSettings.ReadInteger(Form.Name+'_Left');
Form.Width:=MyFormSettings.ReadInteger(Form.Name+'_Width');
Form.Height:=MyFormSettings.ReadInteger(Form.Name+'_Height')
end
End
End
Finally
MyFormSettings.Free
End
End;
Procedure TMain.SaveForm(Form:TForm);
Var
MyFormSettings:TRegistry;
Begin
MyFormSettings:=TRegistry.Create;
Try
MyFormSettings.OpenKey( '\Software\'+
ExtractFileName(Application.Exename)+
'\WinPos', TRUE);
MyFormSettings.WriteInteger(Form.Name+'_ScrWidth',Screen.Width);
MyFormSettings.WriteInteger(Form.Name+'_ScrHeight',Screen.Height);
Case Form.WindowState Of
wsNormal:MyFormSettings.WriteInteger(Form.Name+'_WindowState',1);
wsMinimized:MyFormSettings.WriteInteger(Form.Name+'_WindowState',2);
wsMaximized:MyFormSettings.WriteInteger(Form.Name+'_WindowState',3)
End;
MyFormSettings.WriteInteger(Form.Name+'_Width',Form.Width);
MyFormSettings.WriteInteger(Form.Name+'_Height',Form.Height);
MyFormSettings.WriteInteger(Form.Name+'_Left',Form.Left);
MyFormSettings.WriteInteger(Form.Name+'_Top',Form.Top);
MyFormSettings.WriteBool(Form.Name,True)
Finally
MyFormSettings.Free
End
End;
//....在表格上建立文字
procedure TMain.SetCellText(ACol, ARow : Integer; AText : String);
begin
with cxSpreadSheetBook1.ActiveSheet.GetCellObject(ACol,ARow) do
begin
try
Text := AText;
finally
Free;
end;
end;
end;
//......建立新数据文件
procedure TMain.NewSheet(const ASheetName: string = '');
begin
self.TabSheet8.TabVisible:=true;
self.PageControl1.ActivePageIndex:=7;
self.cxSpreadSheetBook1.PageCount:=1;
self.cxSpreadSheetBook1.ActivePage:=0;
self.cxSpreadSheetBook1.ActiveSheet.ClearAll;
self.cxSpreadSheetBook1.ActiveSheet.SelectCell(0,0,false);
with cxSpreadSheetBook1 do
OnSetSelection := cxSpreadBookSetSelection;
end;
//........设定字体类型
procedure TMain.SetCellsStyle(AValuesSet: TStyleValueSet; AAlign: TcxHorzTextAlign;
AFontSize: Integer; const AFontName: string; AStyles: TFontStyles);
procedure SetValue(AFlag: TStyleValue; ANeedStyle: TFontStyle;
var ASetStyles: TFontStyles);
begin
if AFlag in AValuesSet then
begin
if ANeedStyle in AStyles then
Include(ASetStyles, ANeedStyle)
else
Exclude(ASetStyles, ANeedStyle);
end;
end;
var
I, J: Integer;
AStyle: TFontStyles;
begin
with cxSpreadSheetBook1 do
try
BeginUpdate;
with ActiveSheet do
begin
for I := SelectionRect.Left to SelectionRect.Right do
for J := SelectionRect.Top to SelectionRect.Bottom do
with GetCellObject(I, J) do
try
with Style do
begin
AStyle := Font.Style;
if svFontName in AValuesSet then
Font.Name := AFontName;
if svSize in AValuesSet then
Font.Size := AFontSize;
if svAlign in AValuesSet then
HorzTextAlign := AAlign;
SetValue(svBold, fsBold, AStyle);
SetValue(svItalic, fsItalic, AStyle);
SetValue(svUnderline, fsUnderline, AStyle);
SetValue(svStrikeOut, fsStrikeOut, AStyle);
Font.Style := AStyle;
end;
finally
Free;
end;
end;
finally
EndUpdate;
UpdateControl;
end;
end;
procedure TMain.SetTokenStyle(AToolButton: TToolButton; AStyleValue: TStyleValue; AFontStyle: TFontStyle);
begin
if AToolButton.Down then
SetCellsStyle([AStyleValue], haGeneral, 0, '', [AFontStyle])
else
SetCellsStyle([AStyleValue], haGeneral, 0, '', []);
end;
function cxTryStrToInt(const AString: string; var Value: Integer): Boolean;
var
ErrCode: Integer;
S: string;
begin
S := Trim(AString);
Val(S, Value, ErrCode);
Result := ErrCode = 0;
if not Result then Value := 0;
end;
procedure TMain.CalculateSummary(AType: Byte);
function SelRect(const ARect: TRect): string;
begin
Result := cxSpreadSheetBook1.CellsNameByRef(cxSpreadSheetBook1.ActivePage, ARect, False);
end;
var
S: string;
ARect: TRect;
ACell: TcxssCellObject;
const
AFunc: array[0..4] of string = (sxlfSum, sxlfAverage, sxlfCount, sxlfMax, sxlfMin);
begin
with cxSpreadSheetBook1 do
try
ARect := SelectionRect;
S := SelRect(ARect);
ACell := ActiveSheet.GetCellObject(ARect.Right, ARect.Bottom + 1);
try
ACell.Text := '=' + AFunc[AType] + '(' + S + ')';
finally
ACell.Free;
end;
finally
UpdateControl;
end;
end;
function GetTempDirectory: String;
var
TempDir: array[0..255] of Char;
begin
GetTempPath(255, @TempDir);
Result := StrPas(TempDir);
end;
//---------------------------------------------------------------------------//
procedure TMain.FormCreate(Sender: TObject);
//..取出系统临时文件夹
var tmpstr:string;
Names: Pchar;
Size: integer;
begin
// EncryptIt.EncryptFile('tmp.mdb','hrdata.dat',0611); // 加密
// exit;
Names := #0;//读出系统文件夹
try
GetMem( Names, MAX_PATH+1 );
Size := GetWindowsDirectory(Names, MAX_PATH+1);
FWinDir := StrPas(Names);
finally
FreeMem( Names );
end;
//判断程式是否正确安装
if FileExists(fwindir+'\system32\redhr.cnf')=false then
begin
MessageBox(handle,'程序运行失败,请确认您是否正确安装!','错误',MB_ICONERROR or MB_OK);
try
self.Free;
except
end;
exit;
end;
//...以下正确执行
self.iflogin:='N';
tmpstr:=gettempdirectory;
self.ReadConfiguration;
//..解密数据库到临时文件
try
systmpdate:='tmp.tmp';
EncryptIt.DecryptFile('hrdata.dat',tmpstr+systmpdate,0611);
except
MessageBox(handle,'程序运行失败,关闭本系统,并拷贝备份的数据库到程式目录!','错误',MB_ICONERROR or MB_OK);
end;
self.LoadForm(main);
try
//deletefile('hrdata.dat');
self.ADOconn.ConnectionString:='';
self.ADOconn.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'
+'Data Source='
+tmpstr+systmpdate
//+'tmp.mdb'
+';Persist Security Info=False';
self.ADOconn.Open;
self.staffinfo.Open; //基本信息
self.branch.Open;
self.showdel:='0';//不显示删除数据
self.r_staffbranchedit.Open; //部门变动
self.r_staffpost.Open; //职位类型
self.stachpostedit.Open; //职位变动
self.r_staffpict.Open;//图片
self.r_staffpay.Open;//薪资福利
self.r_staffteach.Open;//职工培训计划
self.r_staffteachid.Open;//职工参加培训记录
self.r_staffcontract.Open;//职工合同协议
self.w_tools.Open; //物品表
self.p_w_tools.Open; //领用表
self.PageControl1.ActivePageIndex:=0;
self.TabSheet8.tabVisible:=false;
cbxFont.Items.Assign(Screen.Fonts);
cbxFont.Text := '宋体';
cbxSize.Text := '9';
self.sqlstring:=self.staffinfo.SQL.Text;
except
MessageBox(handle,'程序运行失败,关闭本系统,并拷贝备份的数据库到程式目录!','错误',MB_ICONERROR or MB_OK);
end;
self.StatusBar1.Panels[1].Text:='就绪';
with cxSpreadSheetBook1 do
OnSetSelection := cxSpreadBookSetSelection;
end;
procedure TMain.N28Click(Sender: TObject);
begin
main.tmpquery.Close;
main.tmpquery.SQL.Clear;
main.tmpquery.SQL.Add('select * from r_staffclasscode');
main.tmpquery.Open;
if self.tmpquery.RecordCount=0 then
begin
MessageBox(handle,'请先设置职工类型!','错误',MB_ICONERROR or MB_OK);
exit;
end;
if self.branch.RecordCount=0 then
begin
MessageBox(handle,'没有部门数据暂无法建立职工档案!','错误',MB_ICONERROR or MB_OK);
exit;
end;
faddman:=tfaddman.create(application);
faddman.ADOTable1.Open;
faddman.PageControl1.ActivePageIndex:=0;
faddman.etype:=1;
faddman.showmodal;
self.staffinfo.Close;
self.staffinfo.open;
self.r_staffbranchedit.Close;
self.r_staffbranchedit.Open;
end;
procedure TMain.branchAfterInsert(DataSet: TDataSet);
begin
if varIsNull(branch.FindField('pid').Value) then begin
if varIsNull(dxDBTreeView1.DBTreeNodes.MaxKeyFieldValue) then
branch.FindField('pid').AsString:=''
else branch.FindField('pid').Value := dxDBTreeView1.DBTreeNodes.MaxKeyFieldValue + 1;
end;
branch.FindField('color').AsInteger:=clWhite;
end;
procedure TMain.N36Click(Sender: TObject);
begin
if self.dxDBTreeView1.Selected.Level=0 then
begin
MessageBox(handle,'最高级部门只能唯一!','提示',MB_ICONinformation or MB_OK);
exit;
end;
bran:=tbran.create(application);
bran.etype:=1;
bran.GroupBox2.Visible:=false;
bran.GroupBox3.Visible:=false;
bran.Height:=150;
bran.Button1.Top:=80;
bran.Button2.Top:=80;
bran.GroupBox1.Caption:='部门名称';
bran.showmodal;
end;
procedure TMain.N41Click(Sender: TObject);
begin
self.dxDBTreeView1.Selected.EditText;
end;
procedure TMain.N39Click(Sender: TObject);
begin
if self.branch.RecordCount=0 then exit;
if self.dxDBTreeView1.Selected.Level=0 then
begin
MessageBox(handle,'最高级部门设置不可删除!','提示',MB_ICONinformation or MB_OK);
exit;
end;
if Application.MessageBox('确认要删除这个部门设置吗?','提示',MB_ICONQUESTION or MB_YESNO )=IDYES then
begin
self.dxDBTreeView1.Selected.Delete;
main.Branch.Close;
main.branch.Open;
end;
end;
procedure TMain.N37Click(Sender: TObject);
begin
bran:=tbran.Create(application);
bran.etype:=2;//增加分部
bran.GroupBox2.Visible:=false;
bran.GroupBox3.Visible:=false;
bran.Height:=150;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -