2007-10-29 18:18:11 +00:00
|
|
|
|
unit uViewAlmacen;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uViewBase, ExtCtrls, StdCtrls, Buttons, DB, uDADataTable,
|
|
|
|
|
|
DBCtrls, Grids, DBGrids, uBizAlmacenes, Mask, ComCtrls, uCustomView,
|
|
|
|
|
|
JvComponent, JvFormAutoSize, cxControls, cxContainer, cxEdit, cxTextEdit,
|
2008-08-27 16:48:20 +00:00
|
|
|
|
cxDBEdit, dxLayoutControl, uDAInterfaces, cxGraphics, cxMaskEdit, cxDropDownEdit;
|
2007-10-29 18:18:11 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewAlmacen = interface(IViewBase)
|
|
|
|
|
|
['{F44F8AEF-CB9C-44D5-93DA-53D6AB6A2D29}']
|
|
|
|
|
|
function GetAlmacen: IBizAlmacen;
|
|
|
|
|
|
procedure SetAlmacen(const Value: IBizAlmacen);
|
|
|
|
|
|
property Almacen: IBizAlmacen read GetAlmacen write SetAlmacen;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewAlmacen = class(TfrViewBase, IViewAlmacen)
|
|
|
|
|
|
DADataSource: TDADataSource;
|
|
|
|
|
|
ePersonaContacto: TcxDBTextEdit;
|
|
|
|
|
|
eTlfTelefono: TcxDBTextEdit;
|
|
|
|
|
|
eTlfMovil: TcxDBTextEdit;
|
|
|
|
|
|
eFax: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControlAlmacenGroup_Root: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControlAlmacen: TdxLayoutControl;
|
|
|
|
|
|
dxLayoutControlAlmacenGroup1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControlAlmacenItem3: TdxLayoutItem;
|
|
|
|
|
|
eNombre: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControlAlmacenItem4: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControlAlmacenGroup2: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControlAlmacenItem1: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControlAlmacenItem5: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControlAlmacenItem6: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControlAlmacenGroup3: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControlAlmacenGroup4: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControlAlmacenItem10: TdxLayoutItem;
|
|
|
|
|
|
eCalle: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControlAlmacenItem2: TdxLayoutItem;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
cbPoblacion: TcxDBComboBox;
|
2007-10-29 18:18:11 +00:00
|
|
|
|
dxLayoutControlAlmacenItem7: TdxLayoutItem;
|
|
|
|
|
|
eCodigoPostal: TcxDBTextEdit;
|
|
|
|
|
|
dxLayoutControlAlmacenItem9: TdxLayoutItem;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
cbProvincia: TcxDBComboBox;
|
2007-10-29 18:18:11 +00:00
|
|
|
|
dxLayoutControlAlmacenGroup6: TdxLayoutGroup;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
|
|
|
|
procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
|
2007-10-29 18:18:11 +00:00
|
|
|
|
protected
|
|
|
|
|
|
FAlmacen: IBizAlmacen;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
FProvincias : TStringList;
|
2010-07-20 09:27:50 +00:00
|
|
|
|
FIDProvincia : Integer; //Almacenar<61> la provincia que hay seleccionada para no cargar las poblaciones si no es necesario
|
2008-06-09 18:10:00 +00:00
|
|
|
|
FPoblaciones : TStringList;
|
|
|
|
|
|
procedure CargarProvincias;
|
|
|
|
|
|
procedure CargarPoblaciones;
|
2007-10-29 18:18:11 +00:00
|
|
|
|
function GetAlmacen: IBizAlmacen;
|
|
|
|
|
|
procedure SetAlmacen(const Value: IBizAlmacen);
|
|
|
|
|
|
public
|
2008-06-09 18:10:00 +00:00
|
|
|
|
constructor Create(AOwner : TComponent); override;
|
|
|
|
|
|
destructor Destroy;
|
2007-10-29 18:18:11 +00:00
|
|
|
|
property Almacen: IBizAlmacen read GetAlmacen write SetAlmacen;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
2008-06-09 18:10:00 +00:00
|
|
|
|
uses
|
|
|
|
|
|
uDataModuleAlmacenes, uProvinciasPoblacionesController, uStringsUtils;
|
|
|
|
|
|
|
2007-10-29 18:18:11 +00:00
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TfrViewAlmacenes }
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
******************************* TfrViewAlmacenes ********************************
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-06-09 18:10:00 +00:00
|
|
|
|
procedure TfrViewAlmacen.CargarPoblaciones;
|
|
|
|
|
|
var
|
|
|
|
|
|
i : integer;
|
|
|
|
|
|
|
2010-07-20 09:27:50 +00:00
|
|
|
|
begin
|
|
|
|
|
|
if (FIDProvincia <> StrToInt(FProvincias.Values[cbProvincia.Text])) then
|
|
|
|
|
|
Begin
|
|
|
|
|
|
FIDProvincia := StrToInt(FProvincias.Values[cbProvincia.Text]);
|
|
|
|
|
|
|
|
|
|
|
|
with TProvinciasPoblacionesController.Create do
|
|
|
|
|
|
try
|
|
|
|
|
|
FPoblaciones := DarListaPoblaciones(FIDProvincia);
|
|
|
|
|
|
|
|
|
|
|
|
with cbPoblacion.Properties.Items do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
for i := 0 to FPoblaciones.Count - 1 do
|
|
|
|
|
|
Add(FPoblaciones.Names[i]);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
end;
|
2010-07-20 09:27:50 +00:00
|
|
|
|
finally
|
|
|
|
|
|
Free;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
end;
|
2010-07-20 09:27:50 +00:00
|
|
|
|
End;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlmacen.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 TfrViewAlmacen.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 TfrViewAlmacen.cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
|
try
|
|
|
|
|
|
if not Assigned(FProvincias) then
|
|
|
|
|
|
CargarProvincias;
|
|
|
|
|
|
finally
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TfrViewAlmacen.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2010-07-20 09:27:50 +00:00
|
|
|
|
FIDProvincia := 0;
|
2008-06-09 18:10:00 +00:00
|
|
|
|
FProvincias := NIL;
|
|
|
|
|
|
FPoblaciones := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfrViewAlmacen.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Assigned(FProvincias) then
|
|
|
|
|
|
FreeANDNIL(FProvincias);
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FPoblaciones) then
|
|
|
|
|
|
FreeANDNIL(FPoblaciones);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-10-29 18:18:11 +00:00
|
|
|
|
function TfrViewAlmacen.GetAlmacen: IBizAlmacen;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAlmacen;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlmacen.SetAlmacen(const Value: IBizAlmacen);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlmacen := Value;
|
|
|
|
|
|
if Assigned(FAlmacen) then
|
|
|
|
|
|
DADataSource.DataTable := FAlmacen.DataTable
|
|
|
|
|
|
else
|
|
|
|
|
|
DADataSource.DataTable := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|