diff --git a/Source/Modulos/Formas de pago/Controller/uFormasPagoController.pas b/Source/Modulos/Formas de pago/Controller/uFormasPagoController.pas index ff4ff03d..4a01cf34 100644 --- a/Source/Modulos/Formas de pago/Controller/uFormasPagoController.pas +++ b/Source/Modulos/Formas de pago/Controller/uFormasPagoController.pas @@ -11,6 +11,8 @@ type ['{94E5F2B6-64C8-4331-B9CB-3ED730478529}'] function BuscarTodos: IBizFormaPago; function Buscar(ID: Integer): IBizFormaPago; + function BuscarID(ADescripcion: String): Integer; + procedure VerTodos(AFormasPago: IBizFormaPago); procedure Ver(AFormaPago: IBizFormaPago); procedure Anadir(AFormaPago : IBizFormaPago); @@ -42,6 +44,7 @@ type procedure Anadir(AFormaPago : IBizFormaPago); function BuscarTodos: IBizFormaPago; function Buscar(ID: Integer): IBizFormaPago; + function BuscarID(ADescripcion: String): Integer; procedure VerTodos(AFormasPago: IBizFormaPago); procedure Ver(AFormaPago: IBizFormaPago); function Localizar(AFormasPago: IBizFormaPago; ADescripcion:String): Boolean; @@ -68,6 +71,23 @@ begin FDataModule := TDataModuleFormasPago.Create(Nil); end; +function TFormasPagoController.BuscarID(ADescripcion: String): Integer; +var + AFormaPago : IBizFormaPago; +begin + Result := -1; + ShowHourglassCursor; + AFormaPago := BuscarTodos; + try + AFormaPago.Open; + if Localizar(AFormaPago, ADescripcion) then + Result := AFormaPago.ID; + finally + AFormaPago := NIL; + HideHourglassCursor; + end; +end; + function TFormasPagoController.Buscar(ID: Integer): IBizFormaPago; var Condicion: TDAWhereExpression; @@ -156,8 +176,6 @@ end; function TFormasPagoController.ValidarFormaPago(AFormaPago: IBizFormaPago): Boolean; begin - Result := False; - if not Assigned(AFormaPago) then raise Exception.Create ('Forma de pago no asignada'); @@ -217,8 +235,6 @@ end; function TFormasPagoController.Eliminar(AFormaPago: IBizFormaPago): Boolean; begin - Result := False; - if not Assigned(AFormaPago) then raise Exception.Create ('Forma de pago no asignada'); @@ -265,11 +281,17 @@ begin try with AFormasPago.DataTable do begin + if not Active then + Open; + DisableControls; - First; - if not Locate(fld_FormasPagoDESCRIPCION, ADescripcion, []) then - Result := False; - EnableControls; + try + First; + if not Locate(fld_FormasPagoDESCRIPCION, ADescripcion, []) then + Result := False; + finally + EnableControls; + end; end; finally HideHourglassCursor;