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
This commit is contained in:
alexs75
2012-03-29 16:01:32 +00:00
parent 2e40e2dbee
commit 768e780780
6 changed files with 133 additions and 28 deletions

View File

@ -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.

View File

@ -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"

View File

@ -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 ""

View File

@ -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 "Отображать заголовок"

View File

@ -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;

View File

@ -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.