git-svn-id: https://192.168.0.254/svn/Proyectos.Noviseda_FactuGES2/trunk@4 f33bb606-9f5c-448d-9c99-757f00063c96
197 lines
5.3 KiB
ObjectPascal
197 lines
5.3 KiB
ObjectPascal
unit uEditorDireccionEntregaAlbaranProveedor;
|
|
|
|
interface
|
|
|
|
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
|
|
Buttons, ExtCtrls, Mask, DBCtrls, DB, uDADataTable,
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit,
|
|
uIEditorDireccionEntregaAlbaranProveedor, uBizAlbaranesProveedor,
|
|
uDAInterfaces, cxGraphics, cxMaskEdit, cxDropDownEdit;
|
|
|
|
type
|
|
TfEditorDireccionEntregaAlbaranProveedor = class(TForm, IEditorDireccionEntregaAlbaranProveedor)
|
|
OKBtn: TButton;
|
|
CancelBtn: TButton;
|
|
Bevel1: TBevel;
|
|
eDireccion: TDBEdit;
|
|
eCodigoPostal: TDBEdit;
|
|
Label1: TLabel;
|
|
Label4: TLabel;
|
|
dsDireccion: TDADataSource;
|
|
Label6: TLabel;
|
|
ePersonaContacto: TDBEdit;
|
|
Label7: TLabel;
|
|
eTelefono: TDBEdit;
|
|
Label3: TLabel;
|
|
cbProvincia: TcxDBComboBox;
|
|
Label2: TLabel;
|
|
cbPoblacion: TcxDBComboBox;
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormDestroy(Sender: TObject);
|
|
|
|
private
|
|
pDireccion: String;
|
|
pPoblacion: String;
|
|
pProvincia: String;
|
|
pCodigoPostal: String;
|
|
pPersonaContacto: String;
|
|
pTelefono: String;
|
|
FProvincias : TStringList;
|
|
FPoblaciones : TStringList;
|
|
FAlbaran : IBizAlbaranProveedor;
|
|
function GetAlbaran: IBizAlbaranProveedor;
|
|
procedure SetAlbaran(const Value: IBizAlbaranProveedor);
|
|
procedure CargarProvincias;
|
|
procedure CargarPoblaciones;
|
|
public
|
|
property Albaran: IBizAlbaranProveedor read GetAlbaran write SetAlbaran;
|
|
end;
|
|
|
|
implementation
|
|
{$R *.dfm}
|
|
|
|
uses
|
|
uProvinciasPoblacionesController, uStringsUtils;
|
|
|
|
{ TfEditorDireccionEntrega }
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.CargarPoblaciones;
|
|
var
|
|
i : integer;
|
|
AID : Integer;
|
|
begin
|
|
AID := StrToInt(FProvincias.Values[cbProvincia.Text]);
|
|
with TProvinciasPoblacionesController.Create do
|
|
try
|
|
FPoblaciones := DarListaPoblaciones(AID);
|
|
|
|
with cbPoblacion.Properties.Items do
|
|
begin
|
|
BeginUpdate;
|
|
try
|
|
Clear;
|
|
for i := 0 to FPoblaciones.Count - 1 do
|
|
Add(FPoblaciones.Names[i]);
|
|
finally
|
|
EndUpdate;
|
|
end;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.CargarProvincias;
|
|
var
|
|
i : integer;
|
|
begin
|
|
with TProvinciasPoblacionesController.Create do
|
|
try
|
|
FProvincias := DarListaProvincias;
|
|
|
|
with cbProvincia.Properties.Items do
|
|
begin
|
|
BeginUpdate;
|
|
try
|
|
Clear;
|
|
for i := 0 to FProvincias.Count - 1 do
|
|
Add(FProvincias.Names[i]);
|
|
finally
|
|
EndUpdate;
|
|
end;
|
|
end;
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.cbPoblacionPropertiesInitPopup(
|
|
Sender: TObject);
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
FreeANDNIL(FPoblaciones);
|
|
if not Assigned(FProvincias) then
|
|
CargarProvincias;
|
|
if not EsCadenaVacia(cbProvincia.Text) and
|
|
(FProvincias.IndexOfName(cbProvincia.Text) <> -1) then
|
|
CargarPoblaciones
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.cbProvinciaPropertiesInitPopup(
|
|
Sender: TObject);
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
if not Assigned(FProvincias) then
|
|
CargarProvincias;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
//En el caso de cancelar se recuperan los valores iniciales
|
|
if (Self.ModalResult <> mrOk) and (dsDireccion.DataTable.State in dsEditModes) then
|
|
begin
|
|
eDireccion.Field.Value := pDireccion;
|
|
cbPoblacion.DataBinding.Field.Value := pPoblacion;
|
|
cbProvincia.DataBinding.Field.Value := pProvincia;
|
|
eCodigoPostal.Field.Value := pCodigoPostal;
|
|
ePersonaContacto.Field.Value := pPersonaContacto;
|
|
eTelefono.Field.Value := pTelefono;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.FormCreate(Sender: TObject);
|
|
begin
|
|
FProvincias := NIL;
|
|
FPoblaciones := NIL;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.FormDestroy(Sender: TObject);
|
|
begin
|
|
if Assigned(FProvincias) then
|
|
FreeANDNIL(FProvincias);
|
|
|
|
if Assigned(FPoblaciones) then
|
|
FreeANDNIL(FPoblaciones);
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.FormShow(Sender: TObject);
|
|
begin
|
|
//Guardamos los valores iniciales por si al final el usuario cancela
|
|
pDireccion := eDireccion.Text;
|
|
pPoblacion := cbPoblacion.Text;
|
|
pProvincia := cbProvincia.Text;
|
|
pCodigoPostal := eCodigoPostal.Text;
|
|
pPersonaContacto := ePersonaContacto.Text;
|
|
pTelefono := eTelefono.Text;
|
|
end;
|
|
|
|
function TfEditorDireccionEntregaAlbaranProveedor.GetAlbaran: IBizAlbaranProveedor;
|
|
begin
|
|
Result := FAlbaran;
|
|
end;
|
|
|
|
procedure TfEditorDireccionEntregaAlbaranProveedor.SetAlbaran(
|
|
const Value: IBizAlbaranProveedor);
|
|
begin
|
|
FAlbaran := Value;
|
|
if Assigned(FAlbaran) then
|
|
dsDireccion.DataTable := FAlbaran.DataTable
|
|
else
|
|
dsDireccion.DataTable := NIL;
|
|
end;
|
|
|
|
end.
|