📄 untappmdiconsts.pas
字号:
unit UntAppMDIConsts;
interface
uses
Windows,Forms,Classes,SysUtils,UntExcSQL,cxDropDownEdit;
//退出系统提示
Function ExitSys():boolean;
//加密解密算法
Function PassFormat(pws:String; isRead:Boolean):String;
//检查Str是否为空
Function TestStr(Str:String):Boolean;
//返回表中编号的最大值
Function MaxID(TableName:String;ID:String):String;
//执行SQL语句
procedure RunSQL(SQL:String;ExcType:String);
//将职称、部门等表中的name值显示在Combobox中
procedure ShowName(ComBox:TCxCombobox;TableName:String);
//根据Combobox中的文字返回对应表中的编号值
Function ShowTableID(Name,TableName:String):String;
//显示Combobox文本的编号
Function ShowComboxID(Combox:TCxCombobox;Str:String):Integer;
implementation
//*************** 退出系统提示***********************************
Function ExitSys():boolean;
begin
ExitSys:=True;
if Messagebox(0,'您确定要退出当前系统吗?','询问',MB_YESNO+MB_ICONQUESTION)=IDYES then begin
Application.Terminate;
end
else ExitSys:=false;
end;
//**************************************************
//加密解密算法
function PassFormat(pws:String; isRead:Boolean):String;
var
temp_pws:String[30];
pws_length,
i:ShortInt;
begin
randomize; //初始化随机数产生器
pws_length := 0;
if isRead then
begin
case pws[5] of
'1'..'9' : pws_length := Integer(pws[5])-48;
'a' : pws_length := 10;
'b' : pws_length := 11;
'c' : pws_length := 12;
'd' : pws_length := 13;
'e' : pws_length := 14;
'f' : pws_length := 15;
'g' : pws_length := 16;
end;
temp_pws := Copy(pws, 6, pws_length); //===========
for i:=1 to pws_length do
begin
temp_pws[i] := Char(Integer(temp_pws[i]) - 5);
end;
end
else
begin
pws_length := length(pws);
case pws_length of
1..9 : temp_pws[5] := chr(48 + pws_length);
10 : temp_pws[5] := 'a';
11 : temp_pws[5] := 'b';
12 : temp_pws[5] := 'c';
13 : temp_pws[5] := 'd';
14 : temp_pws[5] := 'e';
15 : temp_pws[5] := 'f';
16 : temp_pws[5] := 'g';
end;
for i := 1 to 4 do
begin
temp_pws[i] := chr(48 + Random(10));
end;
for i := 6 to 6 + pws_length - 1 do //=========
begin
temp_pws[i] := Char(Integer(pws[i - 5]) + 5); //=======
end;
for i := pws_length + 6 to 30 do //===========
begin
temp_pws[i] := chr(97 + Random(26));
end;
end;
temp_pws := copy(temp_pws,1,30); //返回长度为30位的串
Result := temp_pws;
end;
//*******************************************************************
//检查Str是否为空
Function TestStr(Str:String):Boolean;
begin
if Trim(Str)='' then
Result:=True
else
Result:=False;
end;
//*******************************************************************
//返回表中编号的最大值
Function MaxID(TableName:String;ID:String):String;
var
ExcID:TExcSQL;
MID:String;
begin
ExcID:=TExcSQL.create;
Try
ExcID.SQL:='Select '+ID+' from '+ Tablename+ ' Order by '+ID;
ExcID.ExcSQL(ExcID.SQL,'Search');
ExcID.ADOQuery.Last;
MID:=ExcID.ADOQuery.FieldByName(Id).AsString;
If ExcID.ADOQuery.RecordCount <1 then
ReSult:='1001'
else
ReSult:=IntToStr(StrToInt(MID)+1);
Finally
ExcID.Free;
end;
end;
//*******************************************************************
//执行SQL语句
procedure RunSQL(SQL:String;ExcType:String);
var
ExcRun:TExcSQL;
begin
ExcRun:=TExcSql.create;
Try
ExcRun.SQL:=Sql;
ExcRun.ExcSQL(ExcRun.SQL,ExcType);
Finally
ExcRun.Free;
end;
end;
//*******************************************************************
//将职称、部门等表中的name值显示在Combobox中
procedure ShowName(ComBox:TCxCombobox;TableName:String);
var
ExcBox:TExcSQL;
begin
ExcBox:=TExcSQL.create;
Try
ExcBox.SQL:='Select * from '+TableName+ ' order by ID ';
ExcBox.ExcSQL(ExcBox.SQL,'Search');
ComBox.Properties.Items.Clear;
ExcBox.ADOQuery.First;
While Not ExcBox.ADOQuery.Eof do
begin
Combox.Properties.Items.Add(ExcBox.ADOQuery.FieldByName('Name').AsString );
ExcBox.ADOQuery.Next;
end;
finally
ExcBox.Free;
end;
end;
//*******************************************************************
//根据Combobox中的文字返回对应表中的编号值
Function ShowTableID(Name,TableName:String):String;
var
ExcID:TExcSQL;
begin
ExcID:=TExcSQL.create;
Try
ExcID.SQL:='Select * from '+TableName +' where Name="'+Name+'"';
ExcID.ExcSQL(ExcID.SQL,'Search');
ReSult:=ExcID.ADOQuery.FieldByName('ID').asstring;
finally
ExcID.Free;
end;
end;
//*******************************************************************
//显示Combobox文本的编号
Function ShowComboxID(Combox:TCxCombobox;Str:String):Integer;
begin
Result:=Combox.Properties.Items.IndexOf(Combox.Text);
end;
//*******************************************************************
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -