git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@448 0c75b7a4-871f-7646-8a2f-f78d34cc349f
238 lines
6.8 KiB
ObjectPascal
238 lines
6.8 KiB
ObjectPascal
unit uViewObra;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, ExtCtrls, StdCtrls, Buttons, DB, uDADataTable,
|
|
DBCtrls, Grids, DBGrids, uBizObras, Mask, ComCtrls, uCustomView,
|
|
JvComponent, JvFormAutoSize, cxControls, cxContainer, cxEdit, cxTextEdit,
|
|
cxDBEdit, dxLayoutControl, uDAInterfaces, uViewDatosYSeleccionCliente, cxMemo,
|
|
uViewDatosYSeleccionProveedor, uViewSubcontrataObra, uViewClienteAsociadoObra,
|
|
dxSkinsCore, dxSkinBlue, dxSkinCaramel, dxSkinCoffee, dxSkinGlassOceans,
|
|
dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
|
|
dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
|
|
dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
|
|
dxSkinSilver, dxSkinStardust, dxSkinsDefaultPainters, dxSkinValentine,
|
|
dxSkinXmas2008Blue, dxSkinsdxLCPainter, cxGraphics, cxMaskEdit, cxDropDownEdit;
|
|
|
|
type
|
|
IViewObra = interface(IViewBase)
|
|
['{D8669267-CAC9-468E-9923-2D3B2DD30CED}']
|
|
function GetObra: IBizObra;
|
|
procedure SetObra(const Value: IBizObra);
|
|
property Obra: IBizObra read GetObra write SetObra;
|
|
end;
|
|
|
|
TfrViewObra = class(TfrViewBase, IViewObra)
|
|
DADataSource: TDADataSource;
|
|
ePersonaContacto: TcxDBTextEdit;
|
|
eTlfTelefono: TcxDBTextEdit;
|
|
eTlfMovil: TcxDBTextEdit;
|
|
eFax: TcxDBTextEdit;
|
|
dxLayoutControlObraGroup_Root: TdxLayoutGroup;
|
|
dxLayoutControlObra: TdxLayoutControl;
|
|
dxLayoutControlObraGroup1: TdxLayoutGroup;
|
|
dxLayoutControlObraItem3: TdxLayoutItem;
|
|
eNombre: TcxDBTextEdit;
|
|
dxLayoutControlObraItem4: TdxLayoutItem;
|
|
dxLayoutControlObraItem1: TdxLayoutItem;
|
|
dxLayoutControlObraItem5: TdxLayoutItem;
|
|
dxLayoutControlObraItem6: TdxLayoutItem;
|
|
dxLayoutControlObraGroup3: TdxLayoutGroup;
|
|
dxLayoutControlObraItem10: TdxLayoutItem;
|
|
eCalle: TcxDBTextEdit;
|
|
dxLayoutControlObraItem2: TdxLayoutItem;
|
|
cbPoblacion: TcxDBComboBox;
|
|
dxLayoutControlObraItem7: TdxLayoutItem;
|
|
dxLayoutControlObraGroup5: TdxLayoutGroup;
|
|
eCodigoPostal: TcxDBTextEdit;
|
|
dxLayoutControlObraItem9: TdxLayoutItem;
|
|
cbProvincia: TcxDBComboBox;
|
|
dxLayoutControlObraGroup7: TdxLayoutGroup;
|
|
dxLayoutControlObraGroup4: TdxLayoutGroup;
|
|
dxLayoutControlObraItem11: TdxLayoutItem;
|
|
eObservaciones: TcxDBMemo;
|
|
dxLayoutControlObraGroup2: TdxLayoutGroup;
|
|
dxLayoutControlObraGroup8: TdxLayoutGroup;
|
|
dxLayoutControlObraGroup9: TdxLayoutGroup;
|
|
dxLayoutControlObraGroup10: TdxLayoutGroup;
|
|
dxLayoutControlObraItem8: TdxLayoutItem;
|
|
frViewSubcontrataObra1: TfrViewSubcontrataObra;
|
|
frViewClienteAsociadoObra1: TfrViewClienteAsociadoObra;
|
|
dxLayoutControlObraItem12: TdxLayoutItem;
|
|
dxLayoutControlObraItem13: TdxLayoutItem;
|
|
dxLayoutControlObraGroup11: TdxLayoutGroup;
|
|
procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
|
|
procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
protected
|
|
FObra: IBizObra;
|
|
FProvincias : TStringList;
|
|
FPoblaciones : TStringList;
|
|
procedure CargarProvincias;
|
|
procedure CargarPoblaciones;
|
|
function GetObra: IBizObra;
|
|
procedure SetObra(const Value: IBizObra);
|
|
procedure OnClienteChanged(Sender : TObject);
|
|
procedure OnSubcontrataChanged(Sender : TObject);
|
|
public
|
|
constructor Create(AOwner : TComponent); override;
|
|
destructor Destroy; override;
|
|
property Obra: IBizObra read GetObra write SetObra;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
uDataModuleObras, uProvinciasPoblacionesController, uStringsUtils;
|
|
|
|
{$R *.dfm}
|
|
|
|
{ TfrViewObras }
|
|
|
|
{
|
|
******************************* TfrViewObras ********************************
|
|
}
|
|
|
|
procedure TfrViewObra.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 TfrViewObra.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 TfrViewObra.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 TfrViewObra.cbProvinciaPropertiesInitPopup(Sender: TObject);
|
|
begin
|
|
ShowHourglassCursor;
|
|
try
|
|
if not Assigned(FProvincias) then
|
|
CargarProvincias;
|
|
finally
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
constructor TfrViewObra.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FProvincias := NIL;
|
|
FPoblaciones := NIL;
|
|
end;
|
|
|
|
destructor TfrViewObra.Destroy;
|
|
begin
|
|
if Assigned(FProvincias) then
|
|
FreeANDNIL(FProvincias);
|
|
|
|
if Assigned(FPoblaciones) then
|
|
FreeANDNIL(FPoblaciones);
|
|
|
|
inherited;
|
|
end;
|
|
|
|
function TfrViewObra.GetObra: IBizObra;
|
|
begin
|
|
Result := FObra;
|
|
end;
|
|
|
|
procedure TfrViewObra.OnClienteChanged(Sender: TObject);
|
|
begin
|
|
if Assigned(FObra) then
|
|
begin
|
|
FObra.Edit;
|
|
FObra.ID_CLIENTE := frViewClienteAsociadoObra1.ID_Cliente;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewObra.OnSubcontrataChanged(Sender: TObject);
|
|
begin
|
|
if Assigned(FObra) then
|
|
begin
|
|
FObra.Edit;
|
|
FObra.ID_SUBCONTRATA := frViewSubcontrataObra1.ID_Proveedor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewObra.SetObra(const Value: IBizObra);
|
|
begin
|
|
FObra := Value;
|
|
frViewClienteAsociadoObra1.OnClienteChanged := NIL;
|
|
frViewSubcontrataObra1.OnProveedorChanged := NIL;
|
|
|
|
if Assigned(FObra) then
|
|
begin
|
|
DADataSource.DataTable := FObra.DataTable;
|
|
if not FObra.ID_CLIENTEIsNull then
|
|
frViewClienteAsociadoObra1.ID_Cliente := FObra.ID_CLIENTE;
|
|
|
|
if not FObra.ID_SUBCONTRATAIsNull then
|
|
frViewSubcontrataObra1.ID_Proveedor := FObra.ID_SUBCONTRATA;
|
|
|
|
|
|
frViewClienteAsociadoObra1.OnClienteChanged := OnClienteChanged;
|
|
frViewSubcontrataObra1.OnProveedorChanged := OnSubcontrataChanged;
|
|
end
|
|
else
|
|
DADataSource.DataTable := NIL;
|
|
end;
|
|
|
|
end.
|
|
|