173 lines
4.7 KiB
ObjectPascal
173 lines
4.7 KiB
ObjectPascal
|
|
unit uBizCuentas;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDAInterfaces, uDADataTable, schCuentasClient_Intf, Classes,
|
|||
|
|
DBGrids, uDBSelectionList, DB, uExceptions, Controls;
|
|||
|
|
|
|||
|
|
const
|
|||
|
|
BIZ_CUENTA = 'BizCuenta';
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IBizCuenta = interface(ICuentas)
|
|||
|
|
['{6A535FAA-01A9-42E1-A6F5-6DB630306ACC}']
|
|||
|
|
procedure Show;
|
|||
|
|
function ShowForSelect : TModalResult;
|
|||
|
|
|
|||
|
|
function GetOnCuentaChanged : TNotifyEvent;
|
|||
|
|
procedure SetOnCuentaChanged (const Value : TNotifyEvent);
|
|||
|
|
property OnCuentaChanged : TNotifyEvent read GetOnCuentaChanged
|
|||
|
|
write SetOnCuentaChanged;
|
|||
|
|
|
|||
|
|
function LocalizarCuenta(Codigo: Integer): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TBizCuentaDataTableRules = class(TCuentasDataTableRules, IBizCuenta,
|
|||
|
|
IApplyUpdateFailedException, ISelectedRowList)
|
|||
|
|
private
|
|||
|
|
FOnCuentaChanged: TNotifyEvent;
|
|||
|
|
FSelectedRows : TSelectedRowList;
|
|||
|
|
procedure ShowToSelect;
|
|||
|
|
procedure BeforeApplyUpdates(Sender: TDADataTable; const Delta: IDADelta);
|
|||
|
|
procedure OnPostError(DataTable: TDADataTable; Error: EDatabaseError;
|
|||
|
|
var Action: TDataAction); override;
|
|||
|
|
function GetOnCuentaChanged: TNotifyEvent;
|
|||
|
|
procedure SetOnCuentaChanged(const Value: TNotifyEvent);
|
|||
|
|
protected
|
|||
|
|
procedure OnNewRecord(Sender: TDADataTable); override;
|
|||
|
|
function GetSelectedRows : TSelectedRowList; virtual;
|
|||
|
|
procedure ShowApplyUpdateFailed (const Error: EDAApplyUpdateFailed); virtual;
|
|||
|
|
public
|
|||
|
|
property OnCuentaChanged : TNotifyEvent read GetOnCuentaChanged write SetOnCuentaChanged;
|
|||
|
|
property SelectedRows : TSelectedRowList read GetSelectedRows;
|
|||
|
|
constructor Create(aDataTable: TDADataTable); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
procedure Show; virtual;
|
|||
|
|
function ShowForSelect : TModalResult; virtual;
|
|||
|
|
function LocalizarCuenta(Codigo: Integer): Boolean;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure ValidarCuenta (const ACuenta : IBizCuenta);
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Dialogs, uDACDSDataTable, SysUtils, uDataModuleBase, uDataModuleUsuarios,
|
|||
|
|
uEditorUtils, uDataModuleCuentas, Variants;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure ValidarCuenta (const ACuenta : IBizCuenta);
|
|||
|
|
begin
|
|||
|
|
//
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
{ TBizCuentaDataTableRules }
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
************************** TBizCuentaDataTableRules **************************
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.OnNewRecord(Sender: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
CODIGOEMPRESA := dmBase.CodigoEmpresa;
|
|||
|
|
USUARIO := dmUsuarios.LoginInfo.UserID;
|
|||
|
|
FECHAALTA := Date;
|
|||
|
|
ULTIMOCIERRE := MinDateTime;
|
|||
|
|
PENULTIMOCIERRE := MinDateTime;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.Show;
|
|||
|
|
begin
|
|||
|
|
ShowEditor(IBizCuenta, Self, etItem);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.ShowApplyUpdateFailed(const Error: EDAApplyUpdateFailed);
|
|||
|
|
begin
|
|||
|
|
// if (Pos(AUF_FKVIOLATION, Error.Message) > 0) then
|
|||
|
|
// MessageBox(0, 'No se puede borrar esta cuenta porque tiene pagos asociados', 'Atenci<63>n', MB_ICONWARNING or MB_OK);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TBizCuentaDataTableRules.GetSelectedRows: TSelectedRowList;
|
|||
|
|
begin
|
|||
|
|
Result := FSelectedRows;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.ShowToSelect;
|
|||
|
|
begin
|
|||
|
|
//
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TBizCuentaDataTableRules.Create(aDataTable: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FSelectedRows := TSelectedRowList.Create(aDataTable);
|
|||
|
|
aDataTable.OnBeforeApplyUpdates := BeforeApplyUpdates;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TBizCuentaDataTableRules.Destroy;
|
|||
|
|
begin
|
|||
|
|
FSelectedRows.Free;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TBizCuentaDataTableRules.ShowForSelect: TModalResult;
|
|||
|
|
begin
|
|||
|
|
Result := ShowEditor(IBizCuenta, Self, etItems);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.BeforeApplyUpdates(
|
|||
|
|
Sender: TDADataTable; const Delta: IDADelta);
|
|||
|
|
var
|
|||
|
|
i: Integer;
|
|||
|
|
begin
|
|||
|
|
for i := 0 to Delta.Count - 1 do
|
|||
|
|
case Delta.Changes[i].ChangeType of
|
|||
|
|
ctInsert, ctUpdate : ValidarCuenta(Self);
|
|||
|
|
// ctDelete :
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.OnPostError(DataTable: TDADataTable;
|
|||
|
|
Error: EDatabaseError; var Action: TDataAction);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Action := daAbort;
|
|||
|
|
if (Pos(AUF_HAVEVALUE, Error.Message) > 0) then
|
|||
|
|
begin
|
|||
|
|
if (Pos('Nombre', Error.Message) > 0) then
|
|||
|
|
MessageBox(0, 'Debe indicar al menos el nombre', 'Atenci<63>n', MB_ICONWARNING or MB_OK)
|
|||
|
|
else
|
|||
|
|
raise Error;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
raise Error;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TBizCuentaDataTableRules.LocalizarCuenta(Codigo: Integer): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := Locate(fld_CuentasCODIGO,Codigo);
|
|||
|
|
|
|||
|
|
if Assigned(FOnCuentaChanged) then
|
|||
|
|
FOnCuentaChanged(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TBizCuentaDataTableRules.GetOnCuentaChanged: TNotifyEvent;
|
|||
|
|
begin
|
|||
|
|
Result := FOnCuentaChanged;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCuentaDataTableRules.SetOnCuentaChanged(const Value: TNotifyEvent);
|
|||
|
|
begin
|
|||
|
|
FOnCuentaChanged := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
RegisterDataTableRules(BIZ_CUENTA, TBizCuentaDataTableRules);
|
|||
|
|
|
|||
|
|
finalization
|
|||
|
|
|
|||
|
|
end.
|