From 0d4cc87c6ce31665a59bdc8ba2c20270ee587c45 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 31 Jul 2008 15:48:01 +0000 Subject: [PATCH] =?UTF-8?q?Limpieza=20de=20c=C3=B3digo=20y=20de=20mensajes?= =?UTF-8?q?=20de=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@489 0c75b7a4-871f-7646-8a2f-f78d34cc349f --- Source/Base/Utiles/Ctltortf.pas | 887 ++++++++++++----------- Source/Base/Utiles/uDataTableUtils.pas | 86 --- Source/Base/Utiles/uReferenciasUtils.pas | 2 +- 3 files changed, 445 insertions(+), 530 deletions(-) diff --git a/Source/Base/Utiles/Ctltortf.pas b/Source/Base/Utiles/Ctltortf.pas index a04bf0e0..8add5b63 100644 --- a/Source/Base/Utiles/Ctltortf.pas +++ b/Source/Base/Utiles/Ctltortf.pas @@ -32,7 +32,7 @@ { software. } { 3. This notice may not be removed or altered from any } { source distribution. } -{ 4. You must register this software by visiting } +{ 4. You must register this software by visiting } { http://nishita.com. } {*************************************************************} @@ -41,49 +41,48 @@ unit CtlToRTF; interface uses - SysUtils, {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs,{$ENDIF} Messages, Classes, Graphics, Controls, - StdCtrls, ExtCtrls, Grids, Forms, cxGridTableView; - + SysUtils, {$IFDEF WIN32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF} Messages, Classes, Graphics, Controls, + StdCtrls, ExtCtrls, Grids, Forms, cxGridTableView; + type - TCtrlToRTF = class(TComponent) - private - { Private declarations } - FFileName:string; - RTF:TMemoryStream; - FontTable:TStringList; - procedure StreamWriteStr(var ms: TMemoryStream; s: string); - function GetRTFFontTableName(FontName:string):string; - function GetRTFFontAttrib(Style:TFontStyles):string; - function GetRTFFontSize(Size:Integer):string; - function GetRTFAlignment(Alignment:TAlignment):string; - function GetRTFFontColorTableName(Color:TColor):string; - function GetRTF: String; - - protected - { Protected declarations } - public - { Public declarations } - constructor Create(AOwner: TComponent); override; - destructor Destroy; override; - procedure CreateRTFHeader; - procedure AddFontToTable(Font:TFont); - procedure ImageToRTF(Image:TImage;Alignment:TAlignment); - procedure MemoToRTF(Memo:TMemo); - procedure ListBoxToRTF(pList:TListBox); - procedure StringListToRTF(pStringList:TStringList;Font:TFont;Alignment:TAlignment); - procedure StringToRTF(pString:String;Font:TFont;Alignment:TAlignment); - procedure TextBufToRTF(TextBuf:pointer;size:word;Font:TFont;Alignment:TAlignment); - procedure LabelToRTF(pLabel:TLabel); - procedure EditToRTF(pEdit:TEdit); - procedure GridToRTF(Grid:TStringGrid); - procedure cxGridViewToRTF(cxGridView:TcxGridTableView); - procedure SaveToFile(pFileName:String); - published - property RTFText : String read GetRTF; - end; - -procedure Register; - + TCtrlToRTF = class(TComponent) + private + { Private declarations } + RTF: TMemoryStream; + FontTable: TStringList; + procedure StreamWriteStr(var ms: TMemoryStream; s: string); + function GetRTFFontTableName(FontName: string): string; + function GetRTFFontAttrib(Style: TFontStyles): string; + function GetRTFFontSize(Size: Integer): string; + function GetRTFAlignment(Alignment: TAlignment): string; + function GetRTFFontColorTableName(Color: TColor): string; + function GetRTF: String; + + protected + { Protected declarations } + public + { Public declarations } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure CreateRTFHeader; + procedure AddFontToTable(Font: TFont); + procedure ImageToRTF(Image: TImage; Alignment: TAlignment); + procedure MemoToRTF(Memo: TMemo); + procedure ListBoxToRTF(pList: TListBox); + procedure StringListToRTF(pStringList: TStringList; Font: TFont; Alignment: TAlignment); + procedure StringToRTF(pString: String; Font: TFont; Alignment: TAlignment); + procedure TextBufToRTF(TextBuf: pointer; size: word; Font: TFont; Alignment: TAlignment); + procedure LabelToRTF(pLabel: TLabel); + procedure EditToRTF(pEdit: TEdit); + procedure GridToRTF(Grid: TStringGrid); + procedure cxGridViewToRTF(cxGridView: TcxGridTableView); + procedure SaveToFile(pFileName: String); + published + property RTFText: String read GetRTF; + end; + + procedure Register; + implementation //{$IFDEF WIN32} @@ -94,488 +93,490 @@ implementation constructor TCtrlToRTF.Create(AOwner: TComponent); begin -inherited Create(AOwner); -RTF:=TMemoryStream.Create; -FontTable:=TStringList.Create; + inherited Create(AOwner); + RTF := TMemoryStream.Create; + FontTable := TStringList.Create; end; destructor TCtrlToRTF.Destroy; begin -RTF.Free; -FontTable.Free; -inherited Destroy; + RTF.Free; + FontTable.Free; + inherited Destroy; end; procedure TCtrlToRTF.CreateRTFHeader; -var i:Integer; +var i: Integer; begin -StreamWriteStr(RTF,'{\rtf1\ansi\ansicpg1252\deff0\deftab720'); -StreamWriteStr(RTF,'{\fonttbl'); -for i:=0 to FontTable.count-1 do -StreamWriteStr(RTF,FontTable.Strings[i]); -StreamWriteStr(RTF,'}'); -StreamWriteStr(RTF,'{\colortbl'); -StreamWriteStr(RTF,'\red0\green0\blue0;'); {Black} -StreamWriteStr(RTF,'\red128\green0\blue0;'); {Maroon} -StreamWriteStr(RTF,'\red0\green128\blue0;'); {Green} -StreamWriteStr(RTF,'\red128\green128\blue0;'); {Olive} -StreamWriteStr(RTF,'\red0\green0\blue128;'); {Navy} -StreamWriteStr(RTF,'\red128\green0\blue128;'); {Purple} -StreamWriteStr(RTF,'\red0\green128\blue128;'); {Teal} -StreamWriteStr(RTF,'\red128\green128\blue128;'); {Gray} -StreamWriteStr(RTF,'\red192\green192\blue192;'); {Silver} -StreamWriteStr(RTF,'\red255\green0\blue0;'); {Red} -StreamWriteStr(RTF,'\red0\green255\blue0;'); {Lime} -StreamWriteStr(RTF,'\red255\green255\blue0;'); {Yellow} -StreamWriteStr(RTF,'\red0\green0\blue255;'); {Blue} -StreamWriteStr(RTF,'\red255\green0\blue255;'); {Fuchsia} -StreamWriteStr(RTF,'\red0\green255\blue255;'); {Aqua} -StreamWriteStr(RTF,'\red255\green255\blue255;'); {White} -StreamWriteStr(RTF,'}'); + StreamWriteStr(RTF, '{\rtf1\ansi\ansicpg1252\deff0\deftab720'); + StreamWriteStr(RTF, '{\fonttbl'); + for i := 0 to FontTable.count - 1 do + StreamWriteStr(RTF, FontTable.Strings[i]); + StreamWriteStr(RTF, '}'); + StreamWriteStr(RTF, '{\colortbl'); + StreamWriteStr(RTF, '\red0\green0\blue0;'); {Black} + StreamWriteStr(RTF, '\red128\green0\blue0;'); {Maroon} + StreamWriteStr(RTF, '\red0\green128\blue0;'); {Green} + StreamWriteStr(RTF, '\red128\green128\blue0;'); {Olive} + StreamWriteStr(RTF, '\red0\green0\blue128;'); {Navy} + StreamWriteStr(RTF, '\red128\green0\blue128;'); {Purple} + StreamWriteStr(RTF, '\red0\green128\blue128;'); {Teal} + StreamWriteStr(RTF, '\red128\green128\blue128;'); {Gray} + StreamWriteStr(RTF, '\red192\green192\blue192;'); {Silver} + StreamWriteStr(RTF, '\red255\green0\blue0;'); {Red} + StreamWriteStr(RTF, '\red0\green255\blue0;'); {Lime} + StreamWriteStr(RTF, '\red255\green255\blue0;'); {Yellow} + StreamWriteStr(RTF, '\red0\green0\blue255;'); {Blue} + StreamWriteStr(RTF, '\red255\green0\blue255;'); {Fuchsia} + StreamWriteStr(RTF, '\red0\green255\blue255;'); {Aqua} + StreamWriteStr(RTF, '\red255\green255\blue255;'); {White} + StreamWriteStr(RTF, '}'); end; procedure TCtrlToRTF.cxGridViewToRTF(cxGridView: TcxGridTableView); -var i,j:Integer; - Temp:double; - FontColor,FontAttrib,FontSize,FontName:String; +var i, j: Integer; + Temp: double; + FontColor, FontAttrib, FontSize, FontName: String; begin -{FontColor:=GetRTFFontColorTableName(cxGridView.Font.Color); -FontSize:=GetRTFFontSize(cxGridView.Font.Size); -FontAttrib:=GetRTFFontAttrib(cxGridView.Font.Style); -FontName:=GetRTFFontTableName(cxGridView.Font.Name);} + {FontColor:=GetRTFFontColorTableName(cxGridView.Font.Color); + FontSize:=GetRTFFontSize(cxGridView.Font.Size); + FontAttrib:=GetRTFFontAttrib(cxGridView.Font.Style); + FontName:=GetRTFFontTableName(cxGridView.Font.Name);} -CreateRTFHeader; + CreateRTFHeader; -FontColor:=GetRTFFontColorTableName(Windows.GetSysColor(COLOR_BTNTEXT)); -FontSize:=GetRTFFontSize(8); -FontAttrib:=GetRTFFontAttrib([]); -FontName:=GetRTFFontTableName('Tahoma'); + FontColor := GetRTFFontColorTableName(Windows.GetSysColor(COLOR_BTNTEXT)); + FontSize := GetRTFFontSize(8); + FontAttrib := GetRTFFontAttrib([]); + FontName := GetRTFFontTableName('Tahoma'); -StreamWriteStr(RTF,'\par \pard\plain\cgrid'); -StreamWriteStr(RTF,'{\stylesheet{\nowidctlpar\widctlpar\adjustright \fs20\cgrid \snext0 Normal;}'); -StreamWriteStr(RTF,'{\*\cs10 \additive Default Paragraph Font;}}'); -StreamWriteStr(RTF,'{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta'); -StreamWriteStr(RTF,'.}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang'); -StreamWriteStr(RTF,'{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1'+'\pnindent720\pnhang{\pntxta'); -StreamWriteStr(RTF,'.}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta'); -StreamWriteStr(RTF,')}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta'); -StreamWriteStr(RTF,')}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang'); -StreamWriteStr(RTF,'{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720'+ -'\pnhang{\pntxtb (}{\pntxta'); -StreamWriteStr(RTF,')}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta'); -StreamWriteStr(RTF,')}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}'); + StreamWriteStr(RTF, '\par \pard\plain\cgrid'); + StreamWriteStr(RTF, '{\stylesheet{\nowidctlpar\widctlpar\adjustright \fs20\cgrid \snext0 Normal;}'); + StreamWriteStr(RTF, '{\*\cs10 \additive Default Paragraph Font;}}'); + StreamWriteStr(RTF, '{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta'); + StreamWriteStr(RTF, '.}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang'); + StreamWriteStr(RTF, '{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1' + '\pnindent720\pnhang{\pntxta'); + StreamWriteStr(RTF, '.}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta'); + StreamWriteStr(RTF, ')}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta'); + StreamWriteStr(RTF, ')}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang'); + StreamWriteStr(RTF, '{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720' + + '\pnhang{\pntxtb (}{\pntxta'); + StreamWriteStr(RTF, ')}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta'); + StreamWriteStr(RTF, ')}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}'); -for i:=0 to cxGridView.Controller.SelectedRowCount-1 do + for i := 0 to cxGridView.Controller.SelectedRowCount - 1 do + begin + StreamWriteStr(RTF, '\trowd'); + StreamWriteStr(RTF, '\trgaph108'); + StreamWriteStr(RTF, '\trrh260'); + StreamWriteStr(RTF, '\trleft90'); + StreamWriteStr(RTF, '\trbrdrt\brdrs\brdrw10'); + StreamWriteStr(RTF, '\trbrdrl\brdrs\brdrw10'); + StreamWriteStr(RTF, '\trbrdrb\brdrs\brdrw10'); + StreamWriteStr(RTF, '\trbrdrr\brdrs\brdrw10'); + StreamWriteStr(RTF, '\trbrdrh\brdrs\brdrw10'); + StreamWriteStr(RTF, '\trbrdrv\brdrs\brdrw10'); + + for j := 0 to cxGridView.VisibleColumnCount - 1 do + begin + StreamWriteStr(RTF, '\clvertalt'); + StreamWriteStr(RTF, '\clbrdrt\brdrs\brdrw10'); + StreamWriteStr(RTF, '\clbrdrl\brdrs\brdrw10'); + StreamWriteStr(RTF, '\clbrdrb\brdrs\brdrw10'); + StreamWriteStr(RTF, '\clbrdrr\brdrs\brdrw10'); + // żżżżż if (j 0 then -begin -Result := '\f'+IntToStr(i); -Exit; -end; -end; + Result := '\f0'; + for i := 0 to FontTable.Count - 1 do + begin + if Pos(FontName, FontTable.Strings[i]) > 0 then + begin + Result := '\f' + IntToStr(i); + Exit; + end; + end; end; -function TCtrlToRTF.GetRTFFontAttrib(Style:TFontStyles):string; -var retval:string; +function TCtrlToRTF.GetRTFFontAttrib(Style: TFontStyles): string; +var retval: string; begin -retval:=''; -if fsBold in Style then -retval := retval+'\b'; -if fsItalic in Style then -retval := retval+'\c'; -if fsUnderline in Style then -retval := retval+'\ul'; -if fsStrikeOut in Style then -retval := retval+'\strike'; -Result:=retval; + retval := ''; + if fsBold in Style then + retval := retval + '\b'; + if fsItalic in Style then + retval := retval + '\c'; + if fsUnderline in Style then + retval := retval + '\ul'; + if fsStrikeOut in Style then + retval := retval + '\strike'; + Result := retval; end; -function TCtrlToRTF.GetRTFFontSize(Size:Integer):string; +function TCtrlToRTF.GetRTFFontSize(Size: Integer): string; begin -Result:='\fs'+IntToStr(size*2); + Result := '\fs' + IntToStr(size * 2); end; function TCtrlToRTF.GetRTF: String; var - A : TStringList; + A: TStringList; begin - StreamWriteStr(RTF,#13#10+'}}'); - RTF.Position := 0; - A := TStringList.Create; - try - A.LoadFromStream(RTF); - Result := A.Text; - finally - FreeANDNIL(A); - end; + StreamWriteStr(RTF, #13#10 + '}}'); + RTF.Position := 0; + A := TStringList.Create; + try + A.LoadFromStream(RTF); + Result := A.Text; + finally + FreeANDNIL(A); + end; end; -function TCtrlToRTF.GetRTFAlignment(Alignment:TAlignment):string; -var Align:String; +function TCtrlToRTF.GetRTFAlignment(Alignment: TAlignment): string; +var Align: String; begin -if Alignment = taCenter then Align := '\qc' -else if Alignment = taRightJustify then Align := '\qr' -else Align:=''; -Result := Align; + if Alignment = taCenter then Align := '\qc' + else if Alignment = taRightJustify then Align := '\qr' + else Align := ''; + Result := Align; end; -function TCtrlToRTF.GetRTFFontColorTableName(Color:TColor):string; +function TCtrlToRTF.GetRTFFontColorTableName(Color: TColor): string; begin -if Color = clBlack then Result:='\cf0' -else if Color =clMaroon then Result:='\cf1' -else if Color =clGreen then Result:='\cf2' -else if Color =clOlive then Result:='\cf3' -else if Color =clNavy then Result:='\cf4' -else if Color =clPurple then Result:='\cf5' -else if Color =clTeal then Result:='\cf6' -else if Color =clGray then Result:='\cf7' -else if Color =clSilver then Result:='\cf8' -else if Color =clRed then Result:='\cf9' -else if Color =clLime then Result:='\cf10' -else if Color =clYellow then Result:='\cf11' -else if Color =clBlue then Result:='\cf12' -else if Color =clFuchsia then Result:='\cf13' -else if Color =clAqua then Result:='\cf14' -else if Color =clWhite then Result:='\cf15'; + if Color = clBlack then Result := '\cf0' + else if Color = clMaroon then Result := '\cf1' + else if Color = clGreen then Result := '\cf2' + else if Color = clOlive then Result := '\cf3' + else if Color = clNavy then Result := '\cf4' + else if Color = clPurple then Result := '\cf5' + else if Color = clTeal then Result := '\cf6' + else if Color = clGray then Result := '\cf7' + else if Color = clSilver then Result := '\cf8' + else if Color = clRed then Result := '\cf9' + else if Color = clLime then Result := '\cf10' + else if Color = clYellow then Result := '\cf11' + else if Color = clBlue then Result := '\cf12' + else if Color = clFuchsia then Result := '\cf13' + else if Color = clAqua then Result := '\cf14' + else if Color = clWhite then Result := '\cf15'; end; -procedure TCtrlToRTF.AddFontToTable(Font:TFont); +procedure TCtrlToRTF.AddFontToTable(Font: TFont); var DC: HDC; - SaveFont: HFont; - SysMetrics, Metrics: TTextMetric; - Temp:byte; -I: Integer; -charset,family:string; + SaveFont: HFont; + Metrics: TTextMetric; + Temp: byte; + I: Integer; + charset, family: string; begin -DC := GetDC(0); -SaveFont := SelectObject(DC, Font.Handle); -GetTextMetrics(DC, Metrics); -SelectObject(DC, SaveFont); -ReleaseDC(0, DC); -for I:=0 to FontTable.Count-1 do -begin -if Pos(Font.Name,FontTable.Strings[i]) > 0 then -Exit; -end; -case Metrics.tmCharSet of -ANSI_CHARSET: charset:='fcharset0'; -DEFAULT_CHARSET: charset:='fcharset1'; -SYMBOL_CHARSET: charset:='fcharset2'; -SHIFTJIS_CHARSET: charset:='fcharset128'; -OEM_CHARSET: charset:='fcharset255'; -else charset:=''; -end; -Temp:=Metrics.tmPitchAndFamily; -Temp:= (Temp shr 4) shl 4; -case Temp of -FF_DECORATIVE: family:='fdecorative'; -FF_DONTCARE: family:='fdontcare'; -FF_MODERN: family:='fmodern'; -FF_ROMAN: family:='froman'; -FF_SCRIPT: family:='fscript'; -FF_SWISS: family:='fswiss'; -else family:='froman'; -end; -FontTable.Add('{\f'+IntToStr(FontTable.Count)+'\'+family+'\'+charset+' '+font.name+';}'); + DC := GetDC(0); + SaveFont := SelectObject(DC, Font.Handle); + GetTextMetrics(DC, Metrics); + SelectObject(DC, SaveFont); + ReleaseDC(0, DC); + for I := 0 to FontTable.Count - 1 do + begin + if Pos(Font.Name, FontTable.Strings[i]) > 0 then + Exit; + end; + case Metrics.tmCharSet of + ANSI_CHARSET: charset := 'fcharset0'; + DEFAULT_CHARSET: charset := 'fcharset1'; + SYMBOL_CHARSET: charset := 'fcharset2'; + SHIFTJIS_CHARSET: charset := 'fcharset128'; + OEM_CHARSET: charset := 'fcharset255'; + else charset := ''; + end; + Temp := Metrics.tmPitchAndFamily; + Temp := (Temp shr 4) shl 4; + case Temp of + FF_DECORATIVE: family := 'fdecorative'; + FF_DONTCARE: family := 'fdontcare'; + FF_MODERN: family := 'fmodern'; + FF_ROMAN: family := 'froman'; + FF_SCRIPT: family := 'fscript'; + FF_SWISS: family := 'fswiss'; + else family := 'froman'; + end; + FontTable.Add('{\f' + IntToStr(FontTable.Count) + '\' + family + '\' + charset + ' ' + font.name + ';}'); end; -procedure TCtrlToRTF.SaveToFile(pFileName:String); +procedure TCtrlToRTF.SaveToFile(pFileName: String); begin -StreamWriteStr(RTF,#13#10+'}}'); -RTF.SaveToFile(pFileName); + StreamWriteStr(RTF, #13#10 + '}}'); + RTF.SaveToFile(pFileName); end; procedure TCtrlToRTF.StreamWriteStr(var ms: TMemoryStream; s: string); begin -ms.Write(s[1], Length(s)); + ms.Write(s[1], Length(s)); end; procedure Register; begin - RegisterComponents('CynapSYS', [TCtrlToRTF]); + RegisterComponents('CynapSYS', [TCtrlToRTF]); end; end. - \ No newline at end of file + diff --git a/Source/Base/Utiles/uDataTableUtils.pas b/Source/Base/Utiles/uDataTableUtils.pas index f6863eaf..983e944d 100644 --- a/Source/Base/Utiles/uDataTableUtils.pas +++ b/Source/Base/Utiles/uDataTableUtils.pas @@ -22,9 +22,6 @@ procedure DesconectarTabla (ATarget: TDADataTable); procedure CopyDataTableDA5(ASource : TDADataTable; ATarget: TDADataTable; const OnlySelectedRows : Boolean = False); -procedure CopyDataTableDA3(ASource : TDADataTable; ATarget : TDADataTable; - const OnlySelectedRows : Boolean = False); - procedure CloneDataTable(const ASource : TDACDSDataTable; var ATarget : TDACDSDataTable; RemoteUpdate: Boolean = True); overload; @@ -344,89 +341,6 @@ begin end; -procedure CopyDataTableDA3(ASource : TDADataTable; ATarget : TDADataTable; - const OnlySelectedRows : Boolean = False); -var - DABin: Binary; - DAAdapter : TDABINAdapter; - AFilter : String; - AFiltered : Boolean; - AObj : ISeleccionable; - i : Integer; -begin - AFilter := ''; - AFiltered := False; - - if OnlySelectedRows then - begin - if not Supports(ASource, ISeleccionable, aObj) then - raise Exception.Create('El origen de datos no soporta la interfaz ISeleccionable (CopyDataTable)'); - - if ASource.Filtered then - begin - AFiltered := True; - AFilter := ASource.Filter; - ASource.Filtered := False; - end; - - ASource.Filter := ''; - if ASource.Active then - ASource.Close; - - //Si no hay elemento seleccionados filtramos para que ATarget se quede vacia - if (AObj.SelectedRecords.Count = 0) then - ASource.Filter := ASource.Filter + '(ID = ' + IntToStr(ID_NULO) + ')' - //En caso contrario filtramos por los elementos seleccionados - else - for i := 0 to AObj.SelectedRecords.Count - 1 do - begin - if (i > 0) then - ASource.Filter := ASource.Filter + ' or '; - ASource.Filter := ASource.Filter + '(ID = ' + IntToStr(AObj.SelectedRecords.Items[i]) + ')'; - end; - - ASource.Filtered := True; - end; - - DABin := Binary.Create; - DAAdapter := TDABINAdapter.Create(nil); - - ShowHourglassCursor; - ASource.DisableControls; - ATarget.DisableControls; - try - ATarget.LogicalName := ASource.LogicalName; // We need to specify new dataset LogicalName - ATarget.RemoteFetchEnabled := False; // "Desconectamos" la tabla destino del servidor - - if not ASource.Active then - ASource.Open; - ASource.First; - - DAAdapter.WriteDataset(DABin, ASource, [woRows]); - DAAdapter.ReadDataset(DABin, ATarget); - DAAdapter.Finalize; - - - ATarget.RemoteFetchEnabled := True; // "Conectamos" la tabla del servidor otra vez - - // Dejar el filtro de la tabla origen como estaba - if OnlySelectedRows then - begin - ASource.Filtered := False; - ASource.Filter := AFilter; - if AFiltered then - ASource.Filtered := True; - end; - - finally - FreeAndNil(DABin); - FreeAndNil(DAAdapter); - ASource.EnableControls; - ATarget.EnableControls; - HideHourglassCursor; - end; -end; - procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable; Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False); var i, j: Integer; diff --git a/Source/Base/Utiles/uReferenciasUtils.pas b/Source/Base/Utiles/uReferenciasUtils.pas index 5080d529..19a04ff5 100644 --- a/Source/Base/Utiles/uReferenciasUtils.pas +++ b/Source/Base/Utiles/uReferenciasUtils.pas @@ -26,7 +26,7 @@ begin if StrIsDigit(Aux1) and StrIsDigit(Aux2) then Result := VarCompare(StrToIntSafe(Aux1), StrToIntSafe(Aux2)) else - VarCompare(Aux1, Aux2) + Result := VarCompare(Aux1, Aux2) end; end.