From 768e780780370ab92b058cff7e1d300170a53b8b Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 29 Mar 2012 16:01:32 +0000 Subject: [PATCH] New fcuntion in TRxCloseFormValidator, localization. New function CloneRecord in DBUtils git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2370 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/dbutils.pas | 57 ++++++++++++++++++++++++++ components/rx/languages/rxconst.es.po | 12 ++++++ components/rx/languages/rxconst.po | 12 ++++++ components/rx/languages/rxconst.ru.po | 12 ++++++ components/rx/rxcloseformvalidator.pas | 24 ++++++++--- components/rx/rxconst.pas | 44 ++++++++++---------- 6 files changed, 133 insertions(+), 28 deletions(-) diff --git a/components/rx/dbutils.pas b/components/rx/dbutils.pas index 00fef5721..116249283 100644 --- a/components/rx/dbutils.pas +++ b/components/rx/dbutils.pas @@ -120,6 +120,7 @@ procedure CheckRequiredField(Field: TField); procedure CheckRequiredFields(const Fields: array of TField); function ExtractFieldName(const Fields: string; var Pos: Integer): string; procedure FillValueForField(const Field: TField; Value:Variant); +procedure CloneRecord(DataSet: TDataSet; IgnoreFields: array of const); { SQL expressions } @@ -937,4 +938,60 @@ begin end; end; +function FieldInArray(Field: TField; Arr: array of const): boolean; +var + i: integer; + CI: boolean; +begin + Result := False; + for i := Low(Arr) to High(Arr) do + begin + with Arr[i] do + begin + case VType of + vtInteger: Result := Field.Index = VInteger; + vtPChar: + Result := + AnsiUpperCase(Field.FieldName) = AnsiUpperCase(vPChar); + vtString, + vtAnsiString: + Result :=UpperCase(Field.FieldName) = UpperCase(string(VAnsiString)); + end + end; + if Result then + exit; + end; +end; + +procedure CloneRecord(DataSet: TDataSet; IgnoreFields: array of const); +var + Rec:Array of variant; + i:integer; +begin + if not DataSet.Active then exit; + i:=DataSet.FieldCount; + SetLength(Rec, DataSet.FieldCount); + + for i:=0 to DataSet.FieldCount-1 do + begin + if (DataSet.Fields[i].FieldKind in [fkData]) and (not DataSet.Fields[i].IsBlob) + and (not FieldInArray(DataSet.Fields[i], IgnoreFields)) then + begin + Rec[i] := DataSet.Fields[i].Value; + end; + end; + + DataSet.Append; + + for i:=0 to DataSet.FieldCount-1 do + begin + if (DataSet.Fields[i].FieldKind in [fkData]) and (not DataSet.Fields[i].IsBlob) + and (not FieldInArray(DataSet.Fields[i], IgnoreFields)) then + begin + DataSet.Fields[i].Value:=Rec[i]; + Rec[i]:=Null; + end; + end; +end; + end. diff --git a/components/rx/languages/rxconst.es.po b/components/rx/languages/rxconst.es.po index 7dd3cd6e6..69596aa06 100644 --- a/components/rx/languages/rxconst.es.po +++ b/components/rx/languages/rxconst.es.po @@ -41,6 +41,10 @@ msgstr "Derecho" msgid "Carbon widget set" msgstr "" +#: rxconst.sclosevaliderror +msgid "Error. Expected vailes..." +msgstr "" + #: rxconst.sdatedlgtitle msgid "Select a Date" msgstr "Seleccionar Fecha" @@ -65,6 +69,10 @@ msgstr "Destino" msgid "Source" msgstr "Fuente" +#: rxconst.sexptcontrolnotfound +msgid "Control not found in validate %s." +msgstr "" + #: rxconst.sfilenotexec msgid "File specified is not an executable file, dynamic-link library, or icon file" msgstr "Fichero especificado no es un fichero ejecutable, vinculo dinamico, o fichero de icono" @@ -141,6 +149,10 @@ msgstr "Anterior A?o|" msgid "QT widget set" msgstr "" +#: rxconst.sreqvalue +msgid "Error. Expected value for filed %s." +msgstr "" + #: rxconst.sshowcaption msgid "Show caption" msgstr "Mostrar titulo" diff --git a/components/rx/languages/rxconst.po b/components/rx/languages/rxconst.po index 553713459..cc471fde2 100644 --- a/components/rx/languages/rxconst.po +++ b/components/rx/languages/rxconst.po @@ -41,6 +41,10 @@ msgstr "" msgid "Carbon widget set" msgstr "" +#: rxconst.sclosevaliderror +msgid "Error. Expected vailes..." +msgstr "" + #: rxconst.sdatedlgtitle msgid "Select a Date" msgstr "" @@ -65,6 +69,10 @@ msgstr "" msgid "Source" msgstr "" +#: rxconst.sexptcontrolnotfound +msgid "Control not found in validate %s." +msgstr "" + #: rxconst.sfilenotexec msgid "File specified is not an executable file, dynamic-link library, or icon file" msgstr "" @@ -141,6 +149,10 @@ msgstr "" msgid "QT widget set" msgstr "" +#: rxconst.sreqvalue +msgid "Error. Expected value for filed %s." +msgstr "" + #: rxconst.sshowcaption msgid "Show caption" msgstr "" diff --git a/components/rx/languages/rxconst.ru.po b/components/rx/languages/rxconst.ru.po index dc1384191..a6398e39e 100644 --- a/components/rx/languages/rxconst.ru.po +++ b/components/rx/languages/rxconst.ru.po @@ -41,6 +41,10 @@ msgstr "Вправо" msgid "Carbon widget set" msgstr "Графический интерфейс Carbon" +#: rxconst.sclosevaliderror +msgid "Error. Expected vailes..." +msgstr "Ошибка. Ожидается значение..." + #: rxconst.sdatedlgtitle msgid "Select a Date" msgstr "Выберите дату" @@ -65,6 +69,10 @@ msgstr "Выбор" msgid "Source" msgstr "Источник" +#: rxconst.sexptcontrolnotfound +msgid "Control not found in validate %s." +msgstr "Элемент управления не найден в валидаторе %s" + #: rxconst.sfilenotexec msgid "File specified is not an executable file, dynamic-link library, or icon file" msgstr "Указанный файл не исполняемый, не библиотека и не иконка" @@ -141,6 +149,10 @@ msgstr "Превыдущий год|" msgid "QT widget set" msgstr "Графический интерфейс QT" +#: rxconst.sreqvalue +msgid "Error. Expected value for filed %s." +msgstr "Поле %s. Требуется значение" + #: rxconst.sshowcaption msgid "Show caption" msgstr "Отображать заголовок" diff --git a/components/rx/rxcloseformvalidator.pas b/components/rx/rxcloseformvalidator.pas index 240558818..493fb9d7d 100644 --- a/components/rx/rxcloseformvalidator.pas +++ b/components/rx/rxcloseformvalidator.pas @@ -38,11 +38,6 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DB; -const - { TODO : В дальнейшем эти константы оформить в виде ресурсов и вынести в соответсвующий модуль } - sCloseValidError = 'Ошибка. Не все требуемые поля заполнены!'; - sReqValue = 'Поле %s. Требуется значение'; - type { TValidateItem } @@ -100,13 +95,14 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; function CheckCloseForm:boolean; + function ByControl(AControl: TWinControl):TValidateItem; published property ErrorMsgCaption:string read FErrorMsgCaption write FErrorMsgCaption; property Items:TValidateItems read GetItems write SetItems; end; implementation -uses LCLType, StdCtrls, DbCtrls, typinfo, ComCtrls, ExtCtrls; +uses LCLType, StdCtrls, DbCtrls, typinfo, ComCtrls, ExtCtrls, rxconst; { TValidateItems } @@ -319,6 +315,22 @@ begin Result:=true; end; +function TRxCloseFormValidator.ByControl(AControl: TWinControl): TValidateItem; +var + i:integer; +begin + Result:=nil; + for i:=0 to FItems.Count - 1 do + begin + if FItems[i].FControl = AControl then + begin + Result:=FItems[i]; + exit; + end; + end; + raise Exception.CreateFmt(sExptControlNotFound, [Name]); +end; + function TRxCloseFormValidator.GetItems: TValidateItems; begin Result:=FItems; diff --git a/components/rx/rxconst.pas b/components/rx/rxconst.pas index f66e92954..5deddd575 100644 --- a/components/rx/rxconst.pas +++ b/components/rx/rxconst.pas @@ -55,24 +55,24 @@ const crHand = TCursor(14000); crDragHand = TCursor(14001); -const -{ TBitmap.GetTransparentColor from GRAPHICS.PAS uses this value } - PaletteMask = $02000000; +//const +//{ TBitmap.GetTransparentColor from GRAPHICS.PAS uses this value } +// PaletteMask = $02000000; resourcestring - sBrowse = 'Browse'; - sDefaultFilter = 'All files (*.*)|*.*'; - sDateDlgTitle = 'Select a Date'; - sNextYear = 'Next Year|'; - sNextMonth = 'Next Month|'; - sPrevYear = 'Previous Year|'; - sPrevMonth = 'Previous Month|'; - sNotImplemented = 'Function not yet implemented'; - sFileNotExec = 'File specified is not an executable file, dynamic-link library, or icon file'; - sLoadLibError = 'Could not load ''%s'' library'; - sDetails = 'Details'; - sWindowsIcoFiles = 'Windows Ico files (*.ico)|*.ico|All files (*.*)|*.*'; - sToCurDate = 'Set current date'; + sBrowse = 'Browse'; + sDefaultFilter = 'All files (*.*)|*.*'; + sDateDlgTitle = 'Select a Date'; + sNextYear = 'Next Year|'; + sNextMonth = 'Next Month|'; + sPrevYear = 'Previous Year|'; + sPrevMonth = 'Previous Month|'; + sNotImplemented = 'Function not yet implemented'; + sFileNotExec = 'File specified is not an executable file, dynamic-link library, or icon file'; + sLoadLibError = 'Could not load ''%s'' library'; + sDetails = 'Details'; + sWindowsIcoFiles = 'Windows Ico files (*.ico)|*.ico|All files (*.*)|*.*'; + sToCurDate = 'Set current date'; //TDualListDialog SDualListSrcCaption = 'Source'; @@ -116,13 +116,13 @@ resourcestring { TRxHistoryNavigator } - sHistoryDesc = 'History - "%s"'; + sHistoryDesc = 'History - "%s"'; + + { RxCloseFormValidator } + sCloseValidError = 'Error. Expected vailes...'; + sReqValue = 'Error. Expected value for filed %s.'; + sExptControlNotFound = 'Control not found in validate %s.'; implementation -uses Forms; - -{initialization - Screen.Cursors[crHand] := LoadCursor(hInstance, 'RX_HANDCUR'); - Screen.Cursors[crDragHand] := LoadCursor(hInstance, 'RX_DRAGCUR'); } end.