You've already forked lazarus-ccr
RxFPC:new application service function - ErrorBox, WarningBox, InfoBox
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6347 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
17
components/rx/trunk/docs/rxapputils.xml
Normal file
17
components/rx/trunk/docs/rxapputils.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<fpdoc-descriptions><package name="rxnew"><module name="rxapputils"><element name="InfoBox"><short>Процедура отображает на экран окно информационного сообщения</short><descr>Процедура отображает на экран окно информационного сообщения
|
||||||
|
Также сообщение будет записано в протокол работы системы
|
||||||
|
</descr>
|
||||||
|
</element><element name="WarningBox"><short>Процедура отображает на экран окно сообщения - предупреждения</short><descr>Процедура отображает на экран окно сообщения - предупреждения
|
||||||
|
Также сообщение будет записано в протокол работы системы
|
||||||
|
</descr>
|
||||||
|
</element><element name="ErrorBox"><short>Процедура отображает на экран окно сообщения - ошибки</short><descr>Процедура отображает на экран окно сообщения - предупреждения
|
||||||
|
Также сообщение будет записано в протокол работы системы
|
||||||
|
</descr>
|
||||||
|
</element><element name="InfoBox.S"><short>Текст информационного сообщения</short>
|
||||||
|
</element><element name="WarningBox.S"><short>Текст предупрежедения</short>
|
||||||
|
</element><element name="ErrorBox.S"><short>Текст сообщения об ошибке</short>
|
||||||
|
</element>
|
||||||
|
</module>
|
||||||
|
</package>
|
||||||
|
</fpdoc-descriptions>
|
@ -16,7 +16,16 @@
|
|||||||
</element><element name="ConfirmDelete"><short>Функция выдаёт диалоговое окно подтверждения удаления данных</short>
|
</element><element name="ConfirmDelete"><short>Функция выдаёт диалоговое окно подтверждения удаления данных</short>
|
||||||
</element><element name="ConfirmDataSetCancel"><short>Функция завершает редактирование набора данных вопросом о сохранении</short><descr>Функция завершает редактирование набора данных вопросом о сохранении
|
</element><element name="ConfirmDataSetCancel"><short>Функция завершает редактирование набора данных вопросом о сохранении</short><descr>Функция завершает редактирование набора данных вопросом о сохранении
|
||||||
При подтверждении сохранения вызывается метод Post
|
При подтверждении сохранения вызывается метод Post
|
||||||
При отмене - метод Cancel</descr>
|
При отмене - метод Cancel
|
||||||
|
</descr>
|
||||||
|
</element>
|
||||||
|
<element name="CheckRequiredField"><short>Процедура производит проверку заполнения данными поля</short><descr>Процедура производит проверку заполнения данными поля
|
||||||
|
В случае если данные не введены - то данное визуальный эелемент ввода получит фокус для ввода данных
|
||||||
|
|
||||||
|
</descr>
|
||||||
|
</element><element name="CheckRequiredFields"><short>Процедура производит проверку заполнения данными полей</short>
|
||||||
|
</element><element name="AddSQLExpressionAnd"><short>Процедура добавляет в строку условия новый эелемент через предикат AND</short>
|
||||||
|
</element><element name="AddSQLExpressionOr"><short>Процедура добавляет в строку условия новый эелемент через предикат OR</short>
|
||||||
</element>
|
</element>
|
||||||
</module>
|
</module>
|
||||||
</package>
|
</package>
|
||||||
|
@ -39,11 +39,11 @@ msgstr "Вправо"
|
|||||||
|
|
||||||
#: rxconst.sclose
|
#: rxconst.sclose
|
||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr ""
|
msgstr "Закрыть"
|
||||||
|
|
||||||
#: rxconst.scloseaftersec
|
#: rxconst.scloseaftersec
|
||||||
msgid "Close after %d sec"
|
msgid "Close after %d sec"
|
||||||
msgstr ""
|
msgstr "Будет закрыто через %d секунд"
|
||||||
|
|
||||||
#: rxconst.scloseallexceptthis
|
#: rxconst.scloseallexceptthis
|
||||||
msgid "Close all except this"
|
msgid "Close all except this"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
}
|
}
|
||||||
|
|
||||||
unit rxapputils;
|
unit rxAppUtils;
|
||||||
|
|
||||||
{$I rx.inc}
|
{$I rx.inc}
|
||||||
|
|
||||||
@ -57,9 +57,11 @@ function GetDefaultIniName: string;
|
|||||||
|
|
||||||
type
|
type
|
||||||
TOnGetDefaultIniName = function: string;
|
TOnGetDefaultIniName = function: string;
|
||||||
|
TRxLoggerEvent = procedure( ALogType:TEventType; const ALogMessage:string);
|
||||||
|
|
||||||
const
|
const
|
||||||
OnGetDefaultIniName: TOnGetDefaultIniName = nil;
|
OnGetDefaultIniName: TOnGetDefaultIniName = nil;
|
||||||
|
OnRxLoggerEvent:TRxLoggerEvent = nil;
|
||||||
|
|
||||||
//Save to IniFile or TRegIniFile string value
|
//Save to IniFile or TRegIniFile string value
|
||||||
procedure IniWriteString(IniFile: TObject; const Section, Ident,
|
procedure IniWriteString(IniFile: TObject; const Section, Ident,
|
||||||
@ -74,16 +76,31 @@ function IniReadInteger(IniFile: TObject; const Section, Ident:string;
|
|||||||
const Value: integer):integer;
|
const Value: integer):integer;
|
||||||
|
|
||||||
function GetDefaultIniRegKey: string;
|
function GetDefaultIniRegKey: string;
|
||||||
Function RxGetAppConfigDir(Global : Boolean) : String;
|
function RxGetAppConfigDir(Global : Boolean) : String;
|
||||||
|
|
||||||
|
|
||||||
|
procedure InfoBox(const S:string); overload;
|
||||||
|
procedure InfoBox(const S:string; Params:array of const); overload;
|
||||||
|
|
||||||
|
procedure WarningBox(const S:string); overload;
|
||||||
|
procedure WarningBox(const S:string; Params:array of const); overload;
|
||||||
|
|
||||||
|
procedure ErrorBox(const S:string);
|
||||||
|
procedure ErrorBox(const S:string; Params:array of const);
|
||||||
|
|
||||||
|
procedure RxDefaultWriteLog( ALogType:TEventType; const ALogMessage:string);
|
||||||
|
function RxDefaultLogFileName:string;
|
||||||
|
procedure InitRxLogs;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses
|
uses
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
windirs,
|
windirs,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Registry, Forms, FileUtil, LazUTF8, LazFileUtils;
|
Registry, Forms, FileUtil, LazUTF8, LazFileUtils, Dialogs;
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
|
||||||
function RxGetAppConfigDir(Global: Boolean): String;
|
function RxGetAppConfigDir(Global: Boolean): String;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
begin
|
begin
|
||||||
If Global then
|
If Global then
|
||||||
Result:=GetWindowsSpecialDir(CSIDL_COMMON_APPDATA)
|
Result:=GetWindowsSpecialDir(CSIDL_COMMON_APPDATA)
|
||||||
@ -99,12 +116,86 @@ begin
|
|||||||
Result:=ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))); //IncludeTrailingPathDelimiter(DGetAppConfigDir(Global));
|
Result:=ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))); //IncludeTrailingPathDelimiter(DGetAppConfigDir(Global));
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
function RxGetAppConfigDir(Global: Boolean): String;
|
|
||||||
begin
|
begin
|
||||||
Result:=GetAppConfigDir(Global);
|
Result:=GetAppConfigDir(Global);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
procedure DoWriteLog(ALogType:TEventType; const ALogMessage:string);
|
||||||
|
begin
|
||||||
|
if Assigned(OnRxLoggerEvent) then
|
||||||
|
OnRxLoggerEvent(ALogType, ALogMessage)
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InfoBox(const S: string);
|
||||||
|
begin
|
||||||
|
MessageDlg(S, mtInformation, [mbOK], 0);
|
||||||
|
DoWriteLog(etInfo, S);
|
||||||
|
Application.Log(etInfo, S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InfoBox(const S: string; Params: array of const);
|
||||||
|
begin
|
||||||
|
InfoBox(Format(S, Params));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WarningBox(const S: string);
|
||||||
|
begin
|
||||||
|
MessageDlg(S, mtWarning, [mbOK], 0);
|
||||||
|
DoWriteLog(etWarning, S);
|
||||||
|
Application.Log(etWarning, S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure WarningBox(const S: string; Params: array of const);
|
||||||
|
begin
|
||||||
|
WarningBox(Format(S, Params));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ErrorBox(const S: string);
|
||||||
|
begin
|
||||||
|
MessageDlg(S, mtError, [mbOK], 0);
|
||||||
|
DoWriteLog(etError, S);
|
||||||
|
Application.Log(etError, S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ErrorBox(const S: string; Params: array of const);
|
||||||
|
begin
|
||||||
|
ErrorBox(Format(S, Params));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure RxDefaultWriteLog(ALogType: TEventType; const ALogMessage: string);
|
||||||
|
var
|
||||||
|
F: Text;
|
||||||
|
S: String;
|
||||||
|
const
|
||||||
|
sEventNames : array [TEventType] of string =
|
||||||
|
('CUSTOM','INFO','WARNING','ERROR','DEBUG');
|
||||||
|
begin
|
||||||
|
S:=RxDefaultLogFileName;
|
||||||
|
if S<>'' then
|
||||||
|
begin
|
||||||
|
Assign(F, S);
|
||||||
|
if FileExists(S) then
|
||||||
|
Append(F)
|
||||||
|
else
|
||||||
|
Rewrite(F);
|
||||||
|
|
||||||
|
Writeln(F,Format( '|%s| %20s |%s', [sEventNames[ALogType], DateTimeToStr(Now), ALogMessage]));
|
||||||
|
CloseFile(F);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function RxDefaultLogFileName: string;
|
||||||
|
begin
|
||||||
|
Result:=AppendPathDelim(GetTempDir) + ExtractFileNameOnly(ParamStr(0)) + '.log';
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InitRxLogs;
|
||||||
|
begin
|
||||||
|
OnRxLoggerEvent:=@RxDefaultWriteLog;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetDefaultSection(Component: TComponent): string;
|
function GetDefaultSection(Component: TComponent): string;
|
||||||
var
|
var
|
||||||
F: TCustomForm;
|
F: TCustomForm;
|
||||||
|
@ -127,6 +127,10 @@ procedure FillValueForField(const Field: TField; Value:Variant);
|
|||||||
procedure CloneRecord(DataSet: TDataSet; IgnoreFields: array of const);
|
procedure CloneRecord(DataSet: TDataSet; IgnoreFields: array of const);
|
||||||
function FieldValueToStrings(const DataSet: TDataSet; const FieldName: string; List:TStrings = nil):TStrings;
|
function FieldValueToStrings(const DataSet: TDataSet; const FieldName: string; List:TStrings = nil):TStrings;
|
||||||
|
|
||||||
|
procedure AddSQLExpressionAnd(var MacroStr:string; const MacroWhere:string); overload;
|
||||||
|
procedure AddSQLExpressionAnd(var MacroStr:string; const MacroWhere:string; Params:array of const); overload; inline;
|
||||||
|
procedure AddSQLExpressionOr(var MacroStr:string; const MacroWhere:string);
|
||||||
|
|
||||||
{ SQL expressions }
|
{ SQL expressions }
|
||||||
|
|
||||||
function DateToSQL(Value: TDateTime): string;
|
function DateToSQL(Value: TDateTime): string;
|
||||||
@ -1081,4 +1085,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddSQLExpressionAnd(var MacroStr: string; const MacroWhere: string);
|
||||||
|
begin
|
||||||
|
if MacroWhere <> '' then
|
||||||
|
begin
|
||||||
|
if MacroStr<>'' then MacroStr:=MacroStr + ' and ';
|
||||||
|
MacroStr:=MacroStr + '('+MacroWhere+')';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddSQLExpressionAnd(var MacroStr: string; const MacroWhere: string;
|
||||||
|
Params: array of const);
|
||||||
|
begin
|
||||||
|
AddSQLExpressionAnd(MacroStr, Format(MacroWhere, Params));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddSQLExpressionOr(var MacroStr: string; const MacroWhere: string);
|
||||||
|
begin
|
||||||
|
if MacroWhere<>'' then
|
||||||
|
begin
|
||||||
|
if MacroStr<>'' then MacroStr:=MacroStr + ' or ';
|
||||||
|
MacroStr:=MacroStr + '('+MacroWhere+')';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user