unit Common;
interface
uses Classes, Windows, Forms, SysUtils, StdCtrls, Grids, Types, Registry,
Messages, ShellAPI, Graphics;
type
TCommon = class(TComponent)
public
function GetAppPath: string; // 取应用程序当前路径
function GetTempDirectory: string; //取得操作系统临时目录的位置
function DelFolder(const AsFolder: string): Boolean; //删除一个文件夹
function DoubleToSingle(ADoubleStr: string): string;//将全角变成半角
function JudgeAnsiChar(AStr: string): Boolean; //判断一个字符串是否为全英文字符
function FillDigit(AText: string; ADigitCount: Integer): string;//设置字符的长度,如果不足补0
function IfListExist(AString: TStrings; AFindString: string): Boolean; //查找在列表中是否存在
procedure QueryPress(Sender: TObject; var Key: Char);// 限制在查询输入框中不能输入单引号及双引号}
procedure PressNumber(Sender: TObject; var Key: Char);// 限制只能输入数字、退格、TAB及回车键
procedure PressFloat(Sender: TObject; var Key: Char);// 限制只能输入数字、退格、TAB及回车键和小数点
procedure ShowInfo(AHelpString: string); // 弹出 MessageBox 对话框(普通的对话框)
procedure ShowError(AHelpString: string); // 弹出 MessageBox 对话框(显示错误的对话框)
function IfShowOk(AHelpString: string): Boolean; // 弹出 MessageBox 对话框(有两个选项的选择对话框)
function IfShowYesNoCancel(AHelpString: string): Integer; // 弹出 MessageBox 对话框(有三个选项的选择对话框)
procedure ShowIconInfo(AInfoStr: string; AIconFlag: LongInt); //弹一个可选择图标的提示框
function ShowIconOKCancel(AInfoStr: string; AIconFlag: LongInt): Boolean; //弹出可选择图标MessageBox 对话框(有两个选项的选择对话框)
function ShowIconYesNoCancel(AInfoStr: string; AIconFlag: LongInt): Integer; //弹出可选择图标的 MessageBox 对话框(有三个选项的选择对话框)
procedure IdentityCard(AIdentity: string; var ASex: string;
var ABirthDay: TDateTime; var AErrorCount: Integer); //身份证的验证和属性分解
procedure SetSgPos(ASg: TStringGrid; ACol, ARow: Integer; ARect: TRect; APos: string); //改变StringGrid内容的位置
function EncryptStr(AStr: string): string; //加密字符串
function DecodeStr(AStr: string): string; //解密字符串
function ExistName(AName: string; AStringList: TStrings): Boolean;
procedure ComboBoxLength(AComboBox: TComboBox);
procedure ShowSql(ASqlText: string);
function GetTimeString(AiTime: Integer): string;
procedure DoTip(AifShow: Boolean; AStr: string = ''); //弹出数据处理提示框(过渡窗口)
end;
const
cCheck = '√';
var
Common: TCommon;
SDGsSkin, SDGsUseSkin: string;
SDGiYear, SDGiMonth, SDGiDay: Word;
SDGdtStart, SDGdtEnd: TDateTime;
implementation
uses afrmSqlMemo, afrmTip;
{ TCommon }
function TCommon.GetAppPath: string;
begin
Result := ExtractFilePath(Application.ExeName);
end;
//弹一个可改变提示图标的对话框
procedure TCommon.ShowIconInfo(AInfoStr: string; AIconFlag: Integer);
begin
Application.MessageBox(Pchar(AInfoStr), PChar('系统提示:'), AIconFlag + MB_OK);
end;
// 弹出可选择图标MessageBox对话框(有两个选项的选择对话框)
function TCommon.ShowIconOKCancel(AInfoStr: string;
AIconFlag: Integer): Boolean;
begin
if App