130 lines
3.9 KiB
ObjectPascal
130 lines
3.9 KiB
ObjectPascal
|
|
unit uDatosBancariosContactoController;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Forms, Classes, Controls, Contnrs, SysUtils, uDADataTable,
|
|||
|
|
uBizContactos, uBizContactosDatosBancarios, uIDataModuleContactos,
|
|||
|
|
uControllerBase;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IDatosBancariosContactoController = interface(IControllerBase)
|
|||
|
|
['{2E1C410A-B11D-4E1C-A7DF-9321BAEA5952}']
|
|||
|
|
procedure Ver(ADatoBancario : IBizContactosDatosBancarios);
|
|||
|
|
function Localizar(ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TDatosBancariosContactoController = class(TControllerBase, IDatosBancariosContactoController)
|
|||
|
|
private
|
|||
|
|
FDataModule : IDataModuleContactos;
|
|||
|
|
function GenerarCodigoIBAN(
|
|||
|
|
ADatosBancarios: IBizContactosDatosBancarios): string;
|
|||
|
|
protected
|
|||
|
|
public
|
|||
|
|
function ValidarCodigoIBAN(AIBAN: string): boolean;
|
|||
|
|
procedure Ver(ADatoBancario : IBizContactosDatosBancarios);
|
|||
|
|
function Localizar(ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
|
|||
|
|
constructor Create; override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
function ValidarDatosBancarios(ADatosBancarios : IBizContactosDatosBancarios): Boolean; virtual;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{ TDatosBancariosContactoController }
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDataModuleContactos, schContactosClient_Intf, uIBANUtils, uStringsUtils,
|
|||
|
|
uEditorRegistryUtils, cxControls, uIEditorDatoBancarioContacto;
|
|||
|
|
|
|||
|
|
|
|||
|
|
constructor TDatosBancariosContactoController.Create;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FDataModule := TDataModuleContactos.Create(Nil);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TDatosBancariosContactoController.Destroy;
|
|||
|
|
begin
|
|||
|
|
FDataModule := Nil;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TDatosBancariosContactoController.Localizar(
|
|||
|
|
ADatosBancarios: IBizContactosDatosBancarios; const ID : Integer): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := True;
|
|||
|
|
ShowHourglassCursor;
|
|||
|
|
try
|
|||
|
|
with ADatosBancarios.DataTable do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
First;
|
|||
|
|
if not Locate(fld_DatosBancariosID, ID, []) then
|
|||
|
|
Result := False;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
HideHourglassCursor;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TDatosBancariosContactoController.ValidarCodigoIBAN(
|
|||
|
|
AIBAN: string): boolean;
|
|||
|
|
begin
|
|||
|
|
//Se desactiva la validaci<63>n ya que dicen que hay clientes que no les coincide
|
|||
|
|
result := True; //EsCodigoIBANValido(AIBAN)
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TDatosBancariosContactoController.GenerarCodigoIBAN(
|
|||
|
|
ADatosBancarios: IBizContactosDatosBancarios): string;
|
|||
|
|
begin
|
|||
|
|
Result := uIBANUtils.GenerarCodigoIBAN(ADatosBancarios.ENTIDAD,
|
|||
|
|
ADatosBancarios.SUCURSAL, ADatosBancarios.DC, ADatosBancarios.CUENTA);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TDatosBancariosContactoController.ValidarDatosBancarios(
|
|||
|
|
ADatosBancarios: IBizContactosDatosBancarios): Boolean;
|
|||
|
|
begin
|
|||
|
|
ADatosBancarios.DataTable.Edit;
|
|||
|
|
try
|
|||
|
|
if not EsCadenaVacia(ADatosBancarios.IBAN) then
|
|||
|
|
begin
|
|||
|
|
ADatosBancarios.IBAN := StringReplace(ADatosBancarios.IBAN, ' ', '', [rfReplaceAll]); // Quitar espacios
|
|||
|
|
if not ValidarCodigoIBAN(ADatosBancarios.IBAN) then
|
|||
|
|
raise Exception.Create('Compruebe que el c<>digo IBAN es correcto.');
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
if not EsCadenaVacia(ADatosBancarios.ENTIDAD) and
|
|||
|
|
not EsCadenaVacia(ADatosBancarios.SUCURSAL) and
|
|||
|
|
not EsCadenaVacia(ADatosBancarios.DC) and
|
|||
|
|
not EsCadenaVacia(ADatosBancarios.CUENTA) then
|
|||
|
|
ADatosBancarios.IBAN := GenerarCodigoIBAN(ADatosBancarios);
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
ADatosBancarios.Post;
|
|||
|
|
end;
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TDatosBancariosContactoController.Ver(
|
|||
|
|
ADatoBancario : IBizContactosDatosBancarios);
|
|||
|
|
var
|
|||
|
|
AEditor : IEditorDatoBancarioContacto;
|
|||
|
|
begin
|
|||
|
|
AEditor := NIL;
|
|||
|
|
|
|||
|
|
CreateEditor('EditorDatoBancarioContacto', IEditorDatoBancarioContacto, AEditor);
|
|||
|
|
if Assigned(AEditor) then
|
|||
|
|
try
|
|||
|
|
AEditor.DatoBancario := ADatoBancario;
|
|||
|
|
AEditor.Controller := Self;
|
|||
|
|
AEditor.ShowModal;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
AEditor := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|