194 lines
5.3 KiB
ObjectPascal
194 lines
5.3 KiB
ObjectPascal
|
|
unit uBizCitas;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDAInterfaces, uDADataTable, Classes, DBGrids, uDBSelectionList, DB,
|
|||
|
|
uExceptions, Controls,
|
|||
|
|
|
|||
|
|
schCitasClient_Intf;
|
|||
|
|
|
|||
|
|
const
|
|||
|
|
BIZ_CITAS = 'BizCitas';
|
|||
|
|
BIZ_VENDEDORES = 'BizVendedores';
|
|||
|
|
BIZ_INSTALADORES = 'BizInstaladores';
|
|||
|
|
BIZ_DOCUMENTOS = 'BizDocumentos';
|
|||
|
|
BIZ_TIPOSPEDIDODOCUMENTO = 'BizTiposPedidoDocumento';
|
|||
|
|
CTE_TIPO_DOCUMENTO = 'TIPO_DOCUMENTO';
|
|||
|
|
BIZ_OBRAS = 'BizObras';
|
|||
|
|
|
|||
|
|
TextoTipoCita: array[0..9] of String = ('PERSONAL', 'MEDICION', 'ENTREGA',
|
|||
|
|
'MONTAJE', 'REMATE', 'PEDIDO', 'CONFIRMACION',
|
|||
|
|
'RECEPCION', 'AVISO', 'ENTREGACLIENTE');
|
|||
|
|
|
|||
|
|
LiteralTipoCita: array[0..9] of String = ('Personal', 'Medici<63>n',
|
|||
|
|
'Entrega a instalador', 'Montaje', 'Remate', 'Pedido',
|
|||
|
|
'Confirmaci<63>n de pedido', 'Recepci<63>n de pedido', 'Aviso transportista',
|
|||
|
|
'Entrega al cliente');
|
|||
|
|
|
|||
|
|
TextoPartidasObra: array[0..3] of String = ('COCINA', 'ENCIMERAS',
|
|||
|
|
'ELECTRO', 'VARIOS');
|
|||
|
|
|
|||
|
|
LiteralPartidasObra: array[0..3] of String = ('Cocina', 'Encimeras',
|
|||
|
|
'Electrodom<6F>sticos', 'Varios');
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TPartidasObra = (poCocina, poEncimeras, poElectro, poVarios);
|
|||
|
|
TTipoCitas = (tcPersonal, tcMedicion, tcEntrega, tcMontaje, tcRemate,
|
|||
|
|
tcPedido, tcConfirmacion, tcRecepcion, tcAviso, tcEntregaCliente);
|
|||
|
|
|
|||
|
|
|
|||
|
|
IBizCitas = interface(ICitas)
|
|||
|
|
['{B7CFAD14-99F6-4541-89B4-94B4C4B829D2}']
|
|||
|
|
procedure Show;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
IBizVendedores = interface(IVendedores)
|
|||
|
|
['{19E86356-0BA1-4A58-A552-D68D665232DB}']
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
IBizInstaladores = interface //(IInstaladores)
|
|||
|
|
['{27917CC0-E202-4C0B-82FE-19DC2B494DB2}']
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
IBizDocumentos = interface //(IDocumentos)
|
|||
|
|
['{3000D86E-FD7B-40BD-99FB-E05C00B8FA8A}']
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
IBizTiposPedidoDocumento = interface //(ITiposPedidoDocumento)
|
|||
|
|
['{B6B48E61-C510-4ACA-BFD8-65A876010B13}']
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
IBizObras = interface //(IObras)
|
|||
|
|
['{B9A9EDDE-4F4C-46D1-B48C-2B0BB4E4580E}']
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TBizCitasDataTableRules = class(TCitasDataTableRules, IBizCitas,
|
|||
|
|
IApplyUpdateFailedException)
|
|||
|
|
private
|
|||
|
|
procedure BeforeApplyUpdates(Sender: TDADataTable; const Delta: IDADelta);
|
|||
|
|
procedure BeforePost(Sender: TDADataTable);
|
|||
|
|
procedure OnPostError(DataTable: TDADataTable; Error: EDatabaseError;
|
|||
|
|
var Action: TDataAction); override;
|
|||
|
|
protected
|
|||
|
|
procedure OnNewRecord(Sender: TDADataTable); override;
|
|||
|
|
procedure ShowApplyUpdateFailed (const Error: EDAApplyUpdateFailed); virtual;
|
|||
|
|
public
|
|||
|
|
constructor Create(aDataTable: TDADataTable); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
procedure Show; virtual;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TBizVendedoresDataTableRules = class(TVendedoresDataTableRules, IBizVendedores)
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function DarTipoCita (Texto : String) : TTipoCitas;
|
|||
|
|
function esCitaFase (Texto : String) : Boolean;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Dialogs, uDACDSDataTable, SysUtils, uDataModuleBase,
|
|||
|
|
uEditorUtils, Variants,
|
|||
|
|
|
|||
|
|
uDataModuleCalendarios;
|
|||
|
|
|
|||
|
|
|
|||
|
|
function DarTipoCita (Texto : String) : TTipoCitas;
|
|||
|
|
var
|
|||
|
|
i : Integer;
|
|||
|
|
begin
|
|||
|
|
Result := tcPersonal;
|
|||
|
|
for I := Low(TextoTipoCita) to High(TextoTipoCita) do
|
|||
|
|
begin
|
|||
|
|
if UpperCase(TextoTipoCita[i]) = UpperCase(Texto) then
|
|||
|
|
Result := TTipoCitas(I);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Result = tcPersonal then
|
|||
|
|
for I := Low(LiteralTipoCita) to High(LiteralTipoCita) do
|
|||
|
|
begin
|
|||
|
|
if UpperCase(LiteralTipoCita[i]) = UpperCase(Texto) then
|
|||
|
|
Result := TTipoCitas(I);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function esCitaFase (Texto : String) : Boolean;
|
|||
|
|
var
|
|||
|
|
I: TTipoCitas;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
for I:=tcPedido to tcEntregaCliente do
|
|||
|
|
if (TextoTipoCita[Ord(I)] = Texto) then
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
{ TBizCitasDataTableRules }
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
************************** TBizCitasDataTableRules **************************
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.OnNewRecord(Sender: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ID := dmCalendarios.GetCodigo;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.Show;
|
|||
|
|
begin
|
|||
|
|
ShowEditor(IBizCitas, Self, etItem);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.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;
|
|||
|
|
|
|||
|
|
constructor TBizCitasDataTableRules.Create(aDataTable: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
aDataTable.OnBeforeApplyUpdates := BeforeApplyUpdates;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TBizCitasDataTableRules.Destroy;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.BeforeApplyUpdates(Sender: TDADataTable; const Delta: IDADelta);
|
|||
|
|
begin
|
|||
|
|
//
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.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;
|
|||
|
|
|
|||
|
|
procedure TBizCitasDataTableRules.BeforePost(Sender: TDADataTable);
|
|||
|
|
begin
|
|||
|
|
Sender.FieldByName(fld_CITASCODIGOCONTRATO).AsVariant := null;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
RegisterDataTableRules(BIZ_CITAS, TBizCitasDataTableRules);
|
|||
|
|
RegisterDataTableRules(BIZ_VENDEDORES, TBizVendedoresDataTableRules);
|
|||
|
|
|
|||
|
|
finalization
|
|||
|
|
|
|||
|
|
end.
|