Se arregla la carga de poblaciones de las provincias para que si no se cambia de provincia no se vuelva a solicitar al servidor las poblaciones

git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@531 f4e31baf-9722-1c47-927c-6f952f962d4b
This commit is contained in:
roberto 2010-07-20 09:30:40 +00:00
parent b11ba9df75
commit 8786d03ee1
4 changed files with 71 additions and 55 deletions

View File

@ -48,6 +48,7 @@ type
procedure cbProvinciaPropertiesInitPopup(Sender: TObject); procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
private private
FProvincias : TStringList; FProvincias : TStringList;
FIDProvincia : Integer; //Almacenará la provincia que hay seleccionada para no cargar las poblaciones si no es necesario
FPoblaciones : TStringList; FPoblaciones : TStringList;
procedure CargarProvincias; procedure CargarProvincias;
procedure CargarPoblaciones; procedure CargarPoblaciones;
@ -83,28 +84,31 @@ type
procedure TfEditorTiendaEmpresa.CargarPoblaciones; procedure TfEditorTiendaEmpresa.CargarPoblaciones;
var var
i : integer; i : integer;
AID : Integer;
begin begin
AID := StrToInt(FProvincias.Values[cbProvincia.Text]); if (FIDProvincia <> StrToInt(FProvincias.Values[cbProvincia.Text])) then
with TProvinciasPoblacionesController.Create do Begin
begin FIDProvincia := StrToInt(FProvincias.Values[cbProvincia.Text]);
try with TProvinciasPoblacionesController.Create do
FPoblaciones := DarListaPoblaciones(AID); begin
with cbPoblacion.Properties.Items do try
begin FPoblaciones := DarListaPoblaciones(FIDProvincia);
BeginUpdate; with cbPoblacion.Properties.Items do
try begin
Clear; BeginUpdate;
for i := 0 to FPoblaciones.Count - 1 do try
Add(FPoblaciones.Names[i]); Clear;
finally for i := 0 to FPoblaciones.Count - 1 do
EndUpdate; Add(FPoblaciones.Names[i]);
finally
EndUpdate;
end;
end; end;
finally
Free;
end; end;
finally
Free;
end; end;
end; End;
end; end;
procedure TfEditorTiendaEmpresa.CargarProvincias; procedure TfEditorTiendaEmpresa.CargarProvincias;
@ -162,6 +166,7 @@ constructor TfEditorTiendaEmpresa.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FController := NIL; FController := NIL;
FIDProvincia := 0;
FProvincias := NIL; FProvincias := NIL;
FPoblaciones := NIL; FPoblaciones := NIL;

View File

@ -100,6 +100,7 @@ type
FEmpresa: IBizEmpresa; FEmpresa: IBizEmpresa;
FController : IEmpresasController; FController : IEmpresasController;
FProvincias : TStringList; FProvincias : TStringList;
FIDProvincia : Integer; //Almacenará la provincia que hay seleccionada para no cargar las poblaciones si no es necesario
FPoblaciones : TStringList; FPoblaciones : TStringList;
FFormasPago: TStringList; FFormasPago: TStringList;
FTiposIVA: TStringList; FTiposIVA: TStringList;
@ -178,28 +179,32 @@ end;
procedure TfrViewEmpresa.CargarPoblaciones; procedure TfrViewEmpresa.CargarPoblaciones;
var var
i : integer; i : integer;
AID : Integer;
begin begin
AID := StrToInt(FProvincias.Values[cbProvincia.Text]); if (FIDProvincia <> StrToInt(FProvincias.Values[cbProvincia.Text])) then
with TProvinciasPoblacionesController.Create do Begin
begin FIDProvincia := StrToInt(FProvincias.Values[cbProvincia.Text]);
try
FPoblaciones := DarListaPoblaciones(AID); with TProvinciasPoblacionesController.Create do
with cbPoblacion.Properties.Items do begin
begin try
BeginUpdate; FPoblaciones := DarListaPoblaciones(FIDProvincia);
try with cbPoblacion.Properties.Items do
Clear; begin
for i := 0 to FPoblaciones.Count - 1 do BeginUpdate;
Add(FPoblaciones.Names[i]); try
finally Clear;
EndUpdate; for i := 0 to FPoblaciones.Count - 1 do
Add(FPoblaciones.Names[i]);
finally
EndUpdate;
end;
end; end;
finally
Free;
end; end;
finally
Free;
end; end;
end; End;
end; end;
procedure TfrViewEmpresa.CargarProvincias; procedure TfrViewEmpresa.CargarProvincias;
@ -231,6 +236,7 @@ end;
constructor TfrViewEmpresa.Create(AOwner : TComponent); constructor TfrViewEmpresa.Create(AOwner : TComponent);
begin begin
inherited; inherited;
FIDProvincia := 0;
FProvincias := NIL; FProvincias := NIL;
FPoblaciones := NIL; FPoblaciones := NIL;
end; end;

View File

@ -13,7 +13,6 @@ inherited frViewContacto: TfrViewContacto
TabOrder = 0 TabOrder = 0
TabStop = False TabStop = False
AutoContentSizes = [acsWidth, acsHeight] AutoContentSizes = [acsWidth, acsHeight]
ExplicitHeight = 536
object PngSpeedButton1: TPngSpeedButton object PngSpeedButton1: TPngSpeedButton
Left = 579 Left = 579
Top = 222 Top = 222
@ -503,6 +502,7 @@ inherited frViewContacto: TfrViewContacto
inherited memObservaciones: TcxDBMemo inherited memObservaciones: TcxDBMemo
DataBinding.DataField = 'NOTAS' DataBinding.DataField = 'NOTAS'
DataBinding.DataSource = dsContacto DataBinding.DataSource = dsContacto
ExplicitHeight = 228
Height = 228 Height = 228
end end
end end

View File

@ -103,6 +103,7 @@ type
procedure cbPoblacionPropertiesInitPopup(Sender: TObject); procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
private private
FProvincias : TStringList; FProvincias : TStringList;
FIDProvincia : Integer; //Almacenará la provincia que hay seleccionada para no cargar las poblaciones si no es necesario
FPoblaciones : TStringList; FPoblaciones : TStringList;
procedure CargarProvincias; procedure CargarProvincias;
procedure CargarPoblaciones; procedure CargarPoblaciones;
@ -173,28 +174,31 @@ end;
procedure TfrViewContacto.CargarPoblaciones; procedure TfrViewContacto.CargarPoblaciones;
var var
i : integer; i : integer;
AID : Integer;
begin begin
AID := StrToInt(FProvincias.Values[cbProvincia.Text]); if (FIDProvincia <> StrToInt(FProvincias.Values[cbProvincia.Text])) then
with TProvinciasPoblacionesController.Create do Begin
begin FIDProvincia := StrToInt(FProvincias.Values[cbProvincia.Text]);
try with TProvinciasPoblacionesController.Create do
FPoblaciones := DarListaPoblaciones(AID); begin
with cbPoblacion.Properties.Items do try
begin FPoblaciones := DarListaPoblaciones(FIDProvincia);
BeginUpdate; with cbPoblacion.Properties.Items do
try begin
Clear; BeginUpdate;
for i := 0 to FPoblaciones.Count - 1 do try
Add(FPoblaciones.Names[i]); Clear;
finally for i := 0 to FPoblaciones.Count - 1 do
EndUpdate; Add(FPoblaciones.Names[i]);
finally
EndUpdate;
end;
end; end;
finally
Free;
end; end;
finally
Free;
end; end;
end; End;
end; end;
procedure TfrViewContacto.CargarProvincias; procedure TfrViewContacto.CargarProvincias;
@ -251,6 +255,7 @@ end;
constructor TfrViewContacto.Create(AOwner: TComponent); constructor TfrViewContacto.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FIDProvincia := 0;
FProvincias := NIL; FProvincias := NIL;
FPoblaciones := NIL; FPoblaciones := NIL;
end; end;