940 lines
29 KiB
ObjectPascal
940 lines
29 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2001. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n: 01-10-2001
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.8
|
|||
|
|
Fecha versi<EFBFBD>n actual: 26-04-2004
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
01-10-2001 A<EFBFBD>adir la pesta<EFBFBD>a 'Sucursales'.
|
|||
|
|
|
|||
|
|
05-10-2001 Arreglado un fallo con la poblaci<EFBFBD>n principal. No cog<EFBFBD>a la
|
|||
|
|
poblacici<EFBFBD>n seleccionada en la lista modal.
|
|||
|
|
|
|||
|
|
07-04-2002 Se ha adaptado para la transacci<EFBFBD>n <EFBFBD>nica.
|
|||
|
|
|
|||
|
|
09-04-2002 En las funciones 'CancelarAnadir', 'CancelarModificar',
|
|||
|
|
'CancelarEliminar', 'AnadirDatos', 'ModificarDatos', y
|
|||
|
|
'EliminarDatos' cerrar todas las tablas que se usen.
|
|||
|
|
|
|||
|
|
09-04-2002 En el evento 'bCancelarClick' llamar a la funci<EFBFBD>n
|
|||
|
|
'TratarCambios' en vez de 'DescartarOperacion'.
|
|||
|
|
|
|||
|
|
21-08-2002 P236. No sal<EFBFBD>an las sucursales al consultar o eliminar el
|
|||
|
|
proveedor.
|
|||
|
|
|
|||
|
|
21-08-2002 P237. Revisar los botones de 'Eliminar' y 'Eliminar todo'
|
|||
|
|
para que al pulsar 'Esc' cancele la operaci<EFBFBD>n y no la
|
|||
|
|
ejecute como ahora.
|
|||
|
|
|
|||
|
|
24-09-2002 Se produc<EFBFBD>a una excepci<EFBFBD>n si el cursos estaba en el c<EFBFBD>digo
|
|||
|
|
del proveedor, se pulsaba la tecla 'Esc' y se eleg<EFBFBD>a 'No'.
|
|||
|
|
El frame estaba oculto pero saltaba el evento OnExit del
|
|||
|
|
campo de c<EFBFBD>digo de factura.
|
|||
|
|
|
|||
|
|
21-12-2002 Se ha eliminado un error con el campo 'PROVINCIA'. Al estar
|
|||
|
|
situado en ese campo y dar Esc para salir se puede producir
|
|||
|
|
una excepci<EFBFBD>n.
|
|||
|
|
|
|||
|
|
26-04-2004 p272. Adaptaci<EFBFBD>n a multiempresa.
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit Proveedor;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Db, StdCtrls, RdxMemo, RdxCampos, RdxTitulos, Forms, RdxPaneles,
|
|||
|
|
RdxBotones, Controls, ExtCtrls, RdxBarras, Classes, RdxFrameProveedores,
|
|||
|
|
Grids, DBGrids, RXDBCtrl, ComCtrls, RdxPageControl, dxCntner, dxTL,
|
|||
|
|
dxDBCtrl, dxDBGrid, dxEditor, dxExEdtr, dxEdLib, cxControls, cxContainer,
|
|||
|
|
cxEdit, cxTextEdit, cxMaskEdit, cxButtonEdit, cxDBEdit, cxCheckBox;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrProveedor = class(TRdxFrameProveedores)
|
|||
|
|
brDoble: TRdxBarraInferior;
|
|||
|
|
bAceptar: TRdxBoton;
|
|||
|
|
bCancelarGuardar: TRdxBoton;
|
|||
|
|
brSimple: TRdxBarraInferior;
|
|||
|
|
bSalir: TRdxBoton;
|
|||
|
|
pnlScroll: TRdxScrollPanel;
|
|||
|
|
pnlProveedor: TRdxPanel;
|
|||
|
|
eCodigoAsignado: TLabel;
|
|||
|
|
eObservaciones: TLabel;
|
|||
|
|
cDatos: TRdxCabecera;
|
|||
|
|
eCodigo: TLabel;
|
|||
|
|
eNIFCIF: TLabel;
|
|||
|
|
NIF: TRdxDBEdit;
|
|||
|
|
eNombre: TLabel;
|
|||
|
|
Nombre: TRdxDBEdit;
|
|||
|
|
Observaciones: TRdxDBMemo;
|
|||
|
|
dsProveedor: TDataSource;
|
|||
|
|
Titulo: TRdxPanelTituloOperacion;
|
|||
|
|
PanelDirecciones: TRdxPanel;
|
|||
|
|
Paginas: TRdxPagesControl;
|
|||
|
|
TabSheet1: TTabSheet;
|
|||
|
|
pnlDireccion: TRdxPanel;
|
|||
|
|
eDireccion: TLabel;
|
|||
|
|
eNumero: TLabel;
|
|||
|
|
ePiso: TLabel;
|
|||
|
|
eCodigoPostal: TLabel;
|
|||
|
|
ePoblacion: TLabel;
|
|||
|
|
eProvincia: TLabel;
|
|||
|
|
eTelefono1: TLabel;
|
|||
|
|
eTelefono2: TLabel;
|
|||
|
|
eFax: TLabel;
|
|||
|
|
eCorreo: TLabel;
|
|||
|
|
ePersona: TLabel;
|
|||
|
|
Provincia: TRdxDBEdit;
|
|||
|
|
Poblacion: TRdxDBEdit;
|
|||
|
|
Telefono1: TRdxDBEdit;
|
|||
|
|
Telefono2: TRdxDBEdit;
|
|||
|
|
Fax: TRdxDBEdit;
|
|||
|
|
Calle: TRdxDBEdit;
|
|||
|
|
Numero: TRdxDBEdit;
|
|||
|
|
Piso: TRdxDBEdit;
|
|||
|
|
CodigoPostal: TRdxDBEdit;
|
|||
|
|
CorreoElectronico: TRdxDBEdit;
|
|||
|
|
PersonaContacto: TRdxDBEdit;
|
|||
|
|
TabSheet2: TTabSheet;
|
|||
|
|
pnlGridArticulos: TPanel;
|
|||
|
|
pnlBarraGrid: TRdxPanel;
|
|||
|
|
bAnadir: TRdxBoton;
|
|||
|
|
bEliminar: TRdxBoton;
|
|||
|
|
bEliminarTodo: TRdxBoton;
|
|||
|
|
dsSucursales: TDataSource;
|
|||
|
|
gridSucursales: TdxDBGrid;
|
|||
|
|
Codigo: TcxDBButtonEdit;
|
|||
|
|
CodigoCliente: TcxTextEdit;
|
|||
|
|
cxEtiquetado: TcxDBCheckBox;
|
|||
|
|
procedure bSalirClick(Sender: TObject);
|
|||
|
|
procedure bCancelarGuardarClick(Sender: TObject);
|
|||
|
|
procedure ProvinciaButtonClick(Sender: TObject);
|
|||
|
|
procedure PoblacionButtonClick(Sender: TObject);
|
|||
|
|
procedure bAceptarClick(Sender: TObject);
|
|||
|
|
procedure bAnadirClick(Sender: TObject);
|
|||
|
|
procedure bEliminarClick(Sender: TObject);
|
|||
|
|
procedure bEliminarTodoClick(Sender: TObject);
|
|||
|
|
procedure CodigoPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure CodigoPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
private
|
|||
|
|
FCodigoProvincia : Variant;
|
|||
|
|
FCodigoPoblacion : Variant;
|
|||
|
|
FCodigoProvinciaDireccion : Variant;
|
|||
|
|
FCodigoPoblacionDireccion : Variant;
|
|||
|
|
FCodigoProvinciaSucursal : Variant;
|
|||
|
|
FCodigoPoblacionSucursal : Variant;
|
|||
|
|
protected
|
|||
|
|
procedure ActivarModoAnadir; override;
|
|||
|
|
procedure ActivarModoModificar; override;
|
|||
|
|
procedure ActivarModoConsultar; override;
|
|||
|
|
procedure ActivarModoEliminar; override;
|
|||
|
|
function AnadirDatos : Boolean; override;
|
|||
|
|
function ModificarDatos : Boolean; override;
|
|||
|
|
function EliminarDatos : Boolean; override;
|
|||
|
|
function CancelarAnadir : Boolean; override;
|
|||
|
|
function CancelarModificar : Boolean; override;
|
|||
|
|
function CancelarEliminar : Boolean; override;
|
|||
|
|
function ComprobarDatos : Boolean; override;
|
|||
|
|
procedure VerModal; override;
|
|||
|
|
procedure SetCodigoProvincia (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoPoblacion (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoProvinciaDireccion (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoPoblacionDireccion (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoProvinciaSucursal (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoPoblacionSucursal (Value : Variant); virtual;
|
|||
|
|
procedure FreeContenido; override;
|
|||
|
|
procedure BuscarProveedor; override;
|
|||
|
|
public
|
|||
|
|
property CodigoProvincia : Variant read FCodigoProvincia write SetCodigoProvincia;
|
|||
|
|
property CodigoPoblacion : Variant read FCodigoPoblacion write SetCodigoPoblacion;
|
|||
|
|
property CodigoProvinciaDireccion : Variant read FCodigoProvinciaDireccion write SetCodigoProvinciaDireccion;
|
|||
|
|
property CodigoPoblacionDireccion : Variant read FCodigoPoblacionDireccion write SetCodigoPoblacionDireccion;
|
|||
|
|
property CodigoProvinciaSucursal : Variant read FCodigoProvinciaSucursal write SetCodigoProvinciaSucursal;
|
|||
|
|
property CodigoPoblacionSucursal : Variant read FCodigoPoblacionSucursal write SetCodigoPoblacionSucursal;
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
published
|
|||
|
|
property TablaProveedores;
|
|||
|
|
property TablaSucursales;
|
|||
|
|
property CodigoProveedor;
|
|||
|
|
procedure GridBotonProvinciaClick(Sender: TObject);
|
|||
|
|
procedure GridBotonPoblacionClick(Sender: TObject);
|
|||
|
|
procedure ProvinciaSucursalSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure ProvinciaSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure SucursalAfterInsert(DataSet: TDataSet);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frProveedor: TfrProveedor;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
TablaProveedores, Mensajes, IB, Colores, IBDatabase, Proveedores,
|
|||
|
|
Provincias, RdxFrameProvincias, Poblaciones, RdxFramePoblaciones,
|
|||
|
|
TablaProvincias, BaseDatos, Tipos, IBCustomDataSet, Sysutils,
|
|||
|
|
StrFunc, TablaPoblaciones, Excepciones, IBErrorCodes, NumFunc,
|
|||
|
|
TablaSucursalesProveedor, dxDBTLCL, Configuracion, Literales, RdxEmpresaActiva;
|
|||
|
|
|
|||
|
|
constructor TfrProveedor.Create (AOwner : TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited Create(AOwner);
|
|||
|
|
FCodigoProvincia := NULL;
|
|||
|
|
FCodigoPoblacion := NULL;
|
|||
|
|
FCodigoProvinciaDireccion := NULL;
|
|||
|
|
FCodigoPoblacionDireccion := NULL;
|
|||
|
|
FCodigoProvinciaSucursal := NULL;
|
|||
|
|
FCodigoPoblacionSucursal := NULL;
|
|||
|
|
|
|||
|
|
Entidad := entProveedor;
|
|||
|
|
ConfigurarFrame(Self, Self.Entidad);
|
|||
|
|
|
|||
|
|
BaseDatos := dmBaseDatos.BD;
|
|||
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|||
|
|
TablaProveedores := TIBDataSet.Create(Self);
|
|||
|
|
TablaSucursales := TIBDataSet.Create(Self);
|
|||
|
|
TablaSucursales.AfterInsert := SucursalAfterInsert;
|
|||
|
|
dsProveedor.DataSet := TablaProveedores;
|
|||
|
|
dsSucursales.DataSet := TablaSucursales;
|
|||
|
|
with TablaProveedores do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaProveedores.sqlConsultar);
|
|||
|
|
InsertSQL.Assign(dmTablaProveedores.sqlInsertar);
|
|||
|
|
ModifySQL.Assign(dmTablaProveedores.sqlModificar);
|
|||
|
|
DeleteSQL.Assign(dmTablaProveedores.sqlEliminar);
|
|||
|
|
RefreshSQL.Assign(dmTablaProveedores.sqlConsultar);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaSucursales do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaSucursalesProveedor.sqlGrid);
|
|||
|
|
InsertSQL.Assign(dmTablaSucursalesProveedor.sqlInsertar);
|
|||
|
|
ModifySQL.Assign(dmTablaSucursalesProveedor.sqlModificar);
|
|||
|
|
DeleteSQL.Assign(dmTablaSucursalesProveedor.sqlEliminar);
|
|||
|
|
RefreshSQL.Assign(dmTablaSucursalesProveedor.sqlConsultar);
|
|||
|
|
end;
|
|||
|
|
dmTablaSucursalesProveedor.InicializarGridSucursales(gridSucursales);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoProvincia(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if FCodigoProvincia <> Value then
|
|||
|
|
FCodigoProvincia := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoPoblacion(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if FCodigoPoblacion <> Value then
|
|||
|
|
FCodigoPoblacion := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bSalirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
Rollback;
|
|||
|
|
CloseFrame;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bCancelarGuardarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (TratarCambios = IDOK) then
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.AnadirDatos : Boolean;
|
|||
|
|
var
|
|||
|
|
CodSucursal : Integer;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
CodSucursal := 0;
|
|||
|
|
TablaProveedores.Post;
|
|||
|
|
TablaSucursales.DisableControls;
|
|||
|
|
TablaSucursales.First;
|
|||
|
|
while not TablaSucursales.Eof do begin
|
|||
|
|
TablaSucursales.Edit;
|
|||
|
|
TablaSucursales.FieldByName('CODIGO').AsInteger := CodSucursal;
|
|||
|
|
TablaSucursales.FieldByName('CODIGOPROVEEDOR').AsString := Codigo.DataBinding.Field.AsString;
|
|||
|
|
CodSucursal := CodSucursal + 1;
|
|||
|
|
TablaSucursales.Next;
|
|||
|
|
end;
|
|||
|
|
TablaSucursales.EnableControls;
|
|||
|
|
TablaSucursales.ApplyUpdates;
|
|||
|
|
|
|||
|
|
TablaProveedores.ApplyUpdates;
|
|||
|
|
dmTablaProveedores.insertarProveedorCliEmp(Codigo.DataBinding.Field.AsString, CodigoCliente.Text);
|
|||
|
|
dmTablaProveedores.incrementarCodigo;
|
|||
|
|
CodigoProveedor := TablaProveedores.FieldByName('CODIGO').AsString;
|
|||
|
|
Commit;
|
|||
|
|
TablaProveedores.CachedUpdates := False;
|
|||
|
|
TablaSucursales.CachedUpdates := False;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do begin
|
|||
|
|
if E.IBErrorCode = isc_unique_key_violation then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgProCodProvRepetido, [Codigo.DataBinding.Field.AsString]);
|
|||
|
|
TablaProveedores.Edit;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.ModificarDatos : Boolean;
|
|||
|
|
var
|
|||
|
|
CodSucursal : Integer;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
CodSucursal := 0;
|
|||
|
|
TablaProveedores.Post;
|
|||
|
|
if not dmTablaProveedores.modificarProveedorCliEmp(Codigo.DataBinding.Field.AsString, CodigoCliente.Text) then
|
|||
|
|
dmTablaProveedores.insertarProveedorCliEmp(Codigo.DataBinding.Field.AsString, CodigoCliente.Text);
|
|||
|
|
TablaSucursales.DisableControls;
|
|||
|
|
|
|||
|
|
TablaSucursales.First;
|
|||
|
|
while not TablaSucursales.Eof do
|
|||
|
|
begin
|
|||
|
|
TablaSucursales.Edit;
|
|||
|
|
TablaSucursales.FieldByName('CODIGO').AsInteger := CodSucursal;
|
|||
|
|
CodSucursal := CodSucursal + 1;
|
|||
|
|
TablaSucursales.Post;
|
|||
|
|
TablaSucursales.Next;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TablaSucursales.ApplyUpdates;
|
|||
|
|
Commit;
|
|||
|
|
TablaSucursales.CachedUpdates := False;
|
|||
|
|
TablaSucursales.EnableControls;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.EliminarDatos : Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
TablaProveedores.Delete;
|
|||
|
|
Commit;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
begin
|
|||
|
|
case E.IBErrorCode of
|
|||
|
|
isc_lock_conflict : VerMensajeFmt(msgProvBloqueado, [Codigo.DataBinding.Field.AsString]);
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ActivarModoAnadir;
|
|||
|
|
var
|
|||
|
|
CodNuevo : Variant;
|
|||
|
|
begin
|
|||
|
|
dsProveedor.AutoEdit := True;
|
|||
|
|
|
|||
|
|
pnlBarraGrid.Visible := True;
|
|||
|
|
|
|||
|
|
ActivarEdicionGridDetalles(gridSucursales);
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('PROVINCIA')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := GridBotonProvinciaClick;
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('POBLACION')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := GridBotonPoblacionClick;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := False;
|
|||
|
|
Codigo.Properties.ReadOnly := False;
|
|||
|
|
Codigo.Properties.OnValidate := CodigoPropertiesValidate;
|
|||
|
|
|
|||
|
|
Provincia.VerBoton := True;
|
|||
|
|
Poblacion.VerBoton := True;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaProveedores.CachedUpdates := True;
|
|||
|
|
TablaProveedores.Open;
|
|||
|
|
TablaProveedores.Insert;
|
|||
|
|
TablaProveedores.FieldByName('PROVINCIA').OnSetText := ProvinciaSetText;
|
|||
|
|
|
|||
|
|
CodigoCliente.Properties.ReadOnly := False;
|
|||
|
|
CodigoCliente.Properties.MaxLength := TablaProveedores.FieldByName('CODIGO').Size;
|
|||
|
|
|
|||
|
|
CodNuevo := dmTablaProveedores.darNuevoCodigo;
|
|||
|
|
Codigo.DataBinding.Field.asString := CodNuevo;
|
|||
|
|
cxEtiquetado.DataBinding.Field.AsInteger := 0;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
TablaSucursales.CachedUpdates := True;
|
|||
|
|
TablaSucursales.Prepare;
|
|||
|
|
TablaSucursales.Params.ByName('CODIGOPROVEEDOR').AsString := CodNuevo;
|
|||
|
|
TablaSucursales.Open;
|
|||
|
|
TablaSucursales.FieldByName('PROVINCIA').OnSetText := ProvinciaSucursalSetText;
|
|||
|
|
|
|||
|
|
Visible := True;
|
|||
|
|
NIF.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ActivarModoModificar;
|
|||
|
|
begin
|
|||
|
|
dsProveedor.AutoEdit := True;
|
|||
|
|
dsSucursales.AutoEdit := True;
|
|||
|
|
pnlBarraGrid.Visible := True;
|
|||
|
|
|
|||
|
|
ActivarEdicionGridDetalles(gridSucursales);
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('PROVINCIA')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := GridBotonProvinciaClick;
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('POBLACION')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := GridBotonPoblacionClick;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
Codigo.Properties.ReadOnly := True;
|
|||
|
|
Codigo.Properties.OnValidate := nil;
|
|||
|
|
Provincia.VerBoton := True;
|
|||
|
|
Poblacion.VerBoton := True;
|
|||
|
|
|
|||
|
|
// Para que no haga dos accesos a la tabla cuando es consulta
|
|||
|
|
FCodigoProvinciaDireccion := dmTablaProvincias.darCodigoProvincia(Provincia.Text);
|
|||
|
|
try
|
|||
|
|
TablaProveedores.Open;
|
|||
|
|
TablaProveedores.FieldByName('PROVINCIA').OnSetText := ProvinciaSetText;
|
|||
|
|
if TablaProveedores.RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgProvNoExisteProv, [CodigoProveedor]);
|
|||
|
|
CancelarModificar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
CodigoCliente.Properties.ReadOnly := False;
|
|||
|
|
CodigoCliente.Properties.MaxLength := TablaProveedores.FieldByName('CODIGO').Size;
|
|||
|
|
CodigoCliente.Text := dmTablaProveedores.darCodigoClienteProveedor(CodigoProveedor);
|
|||
|
|
|
|||
|
|
{ Antes de aplicar la cach<EFBFBD> hay que asegurarse de que la
|
|||
|
|
tabla est<EFBFBD> cerrada. }
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
TablaSucursales.CachedUpdates := True;
|
|||
|
|
TablaSucursales.Params.ByName('CODIGOPROVEEDOR').AsString := Codigo.DataBinding.Field.asString;
|
|||
|
|
TablaSucursales.Prepare;
|
|||
|
|
TablaSucursales.Open;
|
|||
|
|
TablaSucursales.FieldByName('PROVINCIA').OnSetText := ProvinciaSucursalSetText;
|
|||
|
|
|
|||
|
|
TablaProveedores.Edit;
|
|||
|
|
TablaProveedores.Post;
|
|||
|
|
TablaProveedores.Edit;
|
|||
|
|
Visible := True;
|
|||
|
|
NIF.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
begin
|
|||
|
|
case E.IBErrorCode of
|
|||
|
|
isc_lock_conflict : begin
|
|||
|
|
VerMensajeFmt(msgProvBloqueado, [CodigoProveedor]);
|
|||
|
|
CancelarModificar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ActivarModoConsultar;
|
|||
|
|
begin
|
|||
|
|
dsProveedor.AutoEdit := False;
|
|||
|
|
dsSucursales.AutoEdit := False;
|
|||
|
|
|
|||
|
|
pnlBarraGrid.Visible := True;
|
|||
|
|
|
|||
|
|
DesactivarEdicionGridDetalles(gridSucursales);
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('PROVINCIA')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := NIL;
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('POBLACION')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := NIL;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
Codigo.Properties.OnValidate := nil;
|
|||
|
|
Provincia.VerBoton := False;
|
|||
|
|
Poblacion.VerBoton := False;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
TablaProveedores.Open;
|
|||
|
|
if TablaProveedores.RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgProvNoExisteProv, [CodigoProveedor]);
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
CodigoCliente.Properties.ReadOnly := True;
|
|||
|
|
CodigoCliente.Text := dmTablaProveedores.darCodigoClienteProveedor(CodigoProveedor);
|
|||
|
|
TablaProveedores.Cancel;
|
|||
|
|
|
|||
|
|
TablaSucursales.Params.ByName('CODIGOPROVEEDOR').AsString := Codigo.DataBinding.Field.asString;
|
|||
|
|
TablaSucursales.Prepare;
|
|||
|
|
TablaSucursales.Open;
|
|||
|
|
Visible := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ActivarModoEliminar;
|
|||
|
|
begin
|
|||
|
|
dsProveedor.AutoEdit := False;
|
|||
|
|
dsSucursales.AutoEdit := False;
|
|||
|
|
|
|||
|
|
DesactivarEdicionGridDetalles(gridSucursales);
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('PROVINCIA')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := NIL;
|
|||
|
|
|
|||
|
|
(gridSucursales.ColumnByFieldName('POBLACION')
|
|||
|
|
as TdxDBTreeListButtonColumn).OnEditButtonClick := NIL;
|
|||
|
|
|
|||
|
|
pnlBarraGrid.Visible := False;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
Codigo.Properties.OnValidate := nil;
|
|||
|
|
Provincia.VerBoton := False;
|
|||
|
|
Poblacion.VerBoton := False;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
TablaProveedores.Open;
|
|||
|
|
if TablaProveedores.RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgProvNoExisteProv, [CodigoProveedor]);
|
|||
|
|
CancelarEliminar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
CodigoCliente.Properties.ReadOnly := True;
|
|||
|
|
CodigoCliente.Text := dmTablaProveedores.darCodigoClienteProveedor(CodigoProveedor);
|
|||
|
|
TablaProveedores.Cancel;
|
|||
|
|
|
|||
|
|
TablaSucursales.Params.ByName('CODIGOPROVEEDOR').AsString := Codigo.DataBinding.Field.asString;
|
|||
|
|
TablaSucursales.Prepare;
|
|||
|
|
TablaSucursales.Open;
|
|||
|
|
Visible := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ProvinciaButtonClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CaptionModal := 'Lista de provincias';
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrProvincias.Create(Self);
|
|||
|
|
CodigoProvinciaDireccion := CodigoProvincia;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.PoblacionButtonClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (VarIsNull(CodigoProvinciaDireccion)) then begin
|
|||
|
|
VerMensaje(msgSinProvincia);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
Provincia.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
CodigoProvincia := CodigoProvinciaDireccion;
|
|||
|
|
CaptionModal := Format(msgListaPoblaciones, [dmTablaProvincias.darNombreProvincia(CodigoProvincia)]);
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrPoblaciones.Create(Self);
|
|||
|
|
CodigoPoblacionDireccion := CodigoPoblacion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrProveedor.Destroy;
|
|||
|
|
begin
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaProveedores.UnPrepare;
|
|||
|
|
TablaProveedores.Free;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bAceptarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (RealizarOperacion) then
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.FreeContenido;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFrameProveedores) then
|
|||
|
|
begin
|
|||
|
|
CodigoProveedor := (ContenidoModal as TRdxFrameProveedores).CodigoProveedor;
|
|||
|
|
ActivarModo;
|
|||
|
|
end;
|
|||
|
|
if (ContenidoModal is TRdxFrameProvincias) then
|
|||
|
|
CodigoProvincia := (ContenidoModal as TRdxFrameProvincias).CodigoProvincia;
|
|||
|
|
if (ContenidoModal is TRdxFramePoblaciones) then begin
|
|||
|
|
CodigoProvincia := (ContenidoModal as TRdxFramePoblaciones).CodigoProvincia;
|
|||
|
|
CodigoPoblacion := (ContenidoModal as TRdxFramePoblaciones).CodigoPoblacion;
|
|||
|
|
end;
|
|||
|
|
inherited FreeContenido;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.VerModal;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFramePoblaciones) then
|
|||
|
|
(ContenidoModal as TRdxFramePoblaciones).CodigoProvincia := FCodigoProvincia;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.BuscarProveedor;
|
|||
|
|
begin
|
|||
|
|
if Transaccion = NIL then
|
|||
|
|
Exit;
|
|||
|
|
try
|
|||
|
|
TablaProveedores.DisableControls;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
|
|||
|
|
// Buscar la fila a tratar si es necesario
|
|||
|
|
if not EsCadenaVacia(CodigoProveedor) then
|
|||
|
|
TablaProveedores.Params.ByName('CODIGO').AsString := CodigoProveedor;
|
|||
|
|
|
|||
|
|
TablaProveedores.Prepare;
|
|||
|
|
TablaProveedores.Open;
|
|||
|
|
TablaProveedores.EnableControls;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.CancelarAnadir: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
TablaProveedores.CancelUpdates;
|
|||
|
|
TablaSucursales.CancelUpdates;
|
|||
|
|
RollBack;
|
|||
|
|
TablaProveedores.CachedUpdates := False;
|
|||
|
|
TablaSucursales.CachedUpdates := False;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.CancelarEliminar: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
RollBack;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.CancelarModificar: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
TablaSucursales.CancelUpdates;
|
|||
|
|
RollBack;
|
|||
|
|
TablaSucursales.CachedUpdates := False;
|
|||
|
|
TablaProveedores.Close;
|
|||
|
|
TablaSucursales.Close;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrProveedor.ComprobarDatos: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
if EsCadenaVacia(Nombre.Text) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgProFaltaNombreProv);
|
|||
|
|
Nombre.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ProvinciaSucursalSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
var
|
|||
|
|
CampoProvincia : String;
|
|||
|
|
begin
|
|||
|
|
CampoProvincia := AnsiUpperCase(Text);
|
|||
|
|
FCodigoProvinciaSucursal := dmTablaProvincias.darCodigoProvincia(CampoProvincia);
|
|||
|
|
Sender.AsString := CampoProvincia;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bAnadirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
TablaSucursales.Append;
|
|||
|
|
Paginas.ActivePageIndex := 1;
|
|||
|
|
gridSucursales.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bEliminarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (VerMensajePregunta(msgDeseaBorrar) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
if TablaSucursales.RecordCount = 0 then begin
|
|||
|
|
{ Hacemos un cancel de la tabla por si el registro actual estuviera
|
|||
|
|
recien creado }
|
|||
|
|
TablaSucursales.Cancel;
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
TablaSucursales.Delete;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.bEliminarTodoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (VerMensajePregunta(msgDeseaBorrarTodo) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
TablaSucursales.DisableControls;
|
|||
|
|
TablaSucursales.Last;
|
|||
|
|
while TablaSucursales.RecordCount > 0 do begin
|
|||
|
|
TablaSucursales.Delete;
|
|||
|
|
TablaSucursales.Prior;
|
|||
|
|
end;
|
|||
|
|
TablaSucursales.EnableControls;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.GridBotonProvinciaClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TablaSucursales.Edit;
|
|||
|
|
CaptionModal := 'Lista de provincias';
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrProvincias.Create(Self);
|
|||
|
|
CodigoProvinciaSucursal := CodigoProvincia;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoPoblacionDireccion(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not VarIsNull(FCodigoPoblacionDireccion)) and (FCodigoPoblacionDireccion = Value) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
if (not VarIsNull(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoPoblacionDireccion := Value;
|
|||
|
|
Poblacion.Field.AsString := dmTablaPoblaciones.darNombrePoblacion(FCodigoProvinciaDireccion, FCodigoPoblacionDireccion);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoPoblacionSucursal(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not VarIsNull(FCodigoPoblacionSucursal)) and (FCodigoPoblacionSucursal = Value) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
if (not VarIsNull(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoPoblacionSucursal := Value;
|
|||
|
|
TablaSucursales.FieldByName('POBLACION').AsString := dmTablaPoblaciones.darNombrePoblacion(FCodigoProvinciaSucursal, FCodigoPoblacionSucursal);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoProvinciaDireccion(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not VarIsNull(FCodigoProvinciaDireccion)) and (FCodigoProvinciaDireccion = Value) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
if (not VarIsNull(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoProvinciaDireccion := Value;
|
|||
|
|
Provincia.Field.AsString := dmTablaProvincias.darNombreProvincia(FCodigoProvinciaDireccion);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SetCodigoProvinciaSucursal(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not VarIsNull(FCodigoProvinciaSucursal)) and (FCodigoProvinciaSucursal = Value) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
if (not VarIsNull(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoProvinciaSucursal := Value;
|
|||
|
|
TablaSucursales.FieldByName('PROVINCIA').AsString := dmTablaProvincias.darNombreProvincia(FCodigoProvinciaSucursal);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.SucursalAfterInsert(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
DataSet.FieldByName('CODIGOPROVEEDOR').AsString := Codigo.DataBinding.Field.AsString;
|
|||
|
|
DataSet.FieldByName('CODIGO').AsInteger := -1;
|
|||
|
|
DataSet.FieldByName('DB_KEY').AsString := '-';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.GridBotonPoblacionClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
FCodigoProvinciaSucursal := dmTablaProvincias.darCodigoProvincia(TablaSucursales.FieldByName('PROVINCIA').AsString);
|
|||
|
|
if (VarIsNull(CodigoProvinciaSucursal)) then begin
|
|||
|
|
VerMensaje(msgSinProvincia);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
TablaSucursales.Edit;
|
|||
|
|
CodigoProvincia := CodigoProvinciaSucursal;
|
|||
|
|
CaptionModal := Format(msgListaPoblaciones, [dmTablaProvincias.darNombreProvincia(CodigoProvincia)]);
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrPoblaciones.Create(Self);
|
|||
|
|
CodigoPoblacionSucursal := CodigoPoblacion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.ProvinciaSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
FCodigoProvinciaDireccion := dmTablaProvincias.darCodigoProvincia(Text);
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.CodigoPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
if (TratarCambios = IDCANCEL) then
|
|||
|
|
exit;
|
|||
|
|
{ Esto es porque en modo 'Modificar' hacemos un cambio y pulsamos
|
|||
|
|
este bot<EFBFBD>n se cierra la tabla y si en el frame hijo (el del grid) damos
|
|||
|
|
a cancelar, FCodigoProveedor es NULL y da error al activar modo porque
|
|||
|
|
no se inicializa los par<EFBFBD>metros de la sql. Lo hace BuscarProveedor. }
|
|||
|
|
if not TablaProveedores.Active then
|
|||
|
|
BuscarProveedor;
|
|||
|
|
ContenidoModal := TfrProveedores.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrProveedor.CodigoPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
if (Modo <> Anadir) or (Visible = false) then
|
|||
|
|
exit;
|
|||
|
|
if EsCadenaVacia(DisplayValue) then
|
|||
|
|
DisplayValue := dmTablaProveedores.darNuevoCodigo;
|
|||
|
|
|
|||
|
|
if (dmTablaProveedores.validarCodigo(DisplayValue)) then begin
|
|||
|
|
//Comprueba que le numero es lo sufucientemente peque<75>o para ser un entero
|
|||
|
|
if not EsInteger(DisplayValue) then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgProCodProvIncorrecto,[DisplayValue]);
|
|||
|
|
Codigo.SetFocus;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
DisplayValue := dmTablaProveedores.formatearCodigo(DisplayValue);
|
|||
|
|
if (dmTablaProveedores.existeCodigo(DisplayValue)) then begin
|
|||
|
|
VerMensajeFmt(msgProCodProvRepetido, [DisplayValue]);
|
|||
|
|
Codigo.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
VerMensajeFmt(msgProCodProvIncorrecto, [DisplayValue]);
|
|||
|
|
Codigo.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|