📄 functionunit.pas
字号:
unit FunctionUnit;
interface
uses Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs,
ComCtrls, ToolWin, Buttons, ExtCtrls, StdCtrls, ShellAPI;
function Msgbox(Handle: integer; Text, Caption: string; flag: integer): integer;
function Checkrights(S_sourcerights: string; S_checkrights: string): boolean; //权限检测
function Nowindex: string;
function DaysInMonth(MYdate: TDate): Integer; //统计任意月份的天数
const
Infmsg0001 = '数据保存成功!';
Infmsg0002 = '数据删除成功!';
Infmsg0003 = '数据修改成功!';
Infmsg0004 = '数据保存失败!请检查后重新保存。';
Infmsg0005 = '检测到有数据窗口正外于打开状态!';
Askmsg0001 = '数据已修改,是否保存?';
Askmsg0002 = '确定要保存以上数据内容?';
Askmsg0003 = '是否要继续?';
Errormsg0001 = '数据库打开错误,请与系统管理员联系。' + #13 + #13 + '错误代码:';
Errormsg0002 = '关键内容(字段)不能为空。' + #13 + #13 + '错误代码:';
Errormsg0003 = '关键内容(字段)已存在。' + #13 + #13 + '错误代码:';
Errormsg0004 = '数据库更新失败,请与系统管理员联系。' + #13 + #13 + '错误代码:';
Errormsg0005 = '数据库删除错误,请与系统管理员联系。' + #13 + #13 + '错误代码:';
Errormsg0006 = '你没有足够的权限使用本功能,请与系统管理员联系。' + #13 + #13 + '错误代码:';
Errormsg0007 = '管理员信息不可删除。' + #13 + #13 + '错误代码:';
Errormsg0008 = '没有输入有效的数据记录,请重新输入!';
Errormsg0009 = '没有检测到商品的库存记录,请重新输入!';
Errormsg0010 = '检测到商品的库存数量小于出货数量,请重新输入!';
Errormsg0011 = '打印机打开错误,打印不能完成。请检查系统是否安装默认打印机!';
Errormsg0012 = '日期输入错误,请重新输入!' + #13 + #13 + '错误代码:';
implementation
//自定义信息对话框
function Msgbox(Handle: integer; Text, Caption: string; flag: integer): integer;
var
Msg: TMsgBoxParams;
begin
Msg.cbSize := Sizeof(Msg);
Msg.hwndOwner := Handle;
Msg.hInstance := hinstance;
Msg.lpszText := PChar(Text);
Msg.lpszCaption := PChar(Caption);
Msg.dwStyle := flag + MB_USERICON;
Msg.lpszIcon := 'MAINICON';
Msg.dwContextHelpId := 1;
Msg.lpfnMsgBoxCallback := nil;
Msg.dwLanguageId := LANG_NEUTRAL;
Result := integer(MessageBoxIndirect(Msg));
end;
function Nowindex: string;
begin
result := formatdatetime('yyyymmdd', date) + '-' + formatdatetime('hhmmss', time)
end;
function Checkrights(S_sourcerights: string; S_checkrights: string): boolean; //权限检测函数定义
begin
S_checkrights := trim(S_checkrights);
if length(S_sourcerights) <> 10 then
S_sourcerights := '0000000000';
if S_checkrights = '查看' then
begin
if S_sourcerights[1] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '增加' then
begin
if S_sourcerights[2] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '编辑' then
begin
if S_sourcerights[3] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '删除' then
begin
if S_sourcerights[4] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '高级' then
begin
if S_sourcerights[5] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '报表打印' then
begin
if S_sourcerights[6] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '打印预览' then
begin
if S_sourcerights[7] = '1' then
result := true
else
result := false;
end
else if S_checkrights = '系统设置' then
begin
if S_sourcerights[8] = '1' then
result := true
else
result := false;
end
else
result := false;
end;
function DaysInMonth(MYdate: TDate): Integer;
var
MyMonth, MyYear, MyDay: Word;
MyDayTable: TDayTable;
tmpBool: Boolean;
begin
DecodeDate(MYdate, MyYear, MyMonth, MyDay);
tmpBool := IsLeapYear(MyYear);
MyDayTable := MonthDays[tmpBool];
Result := MyDayTable[MyMonth];
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -