FactuGES2/Source/ApplicationBase/Empresas/Views/uViewEmpresa.pas
2008-06-23 17:39:17 +00:00

279 lines
7.6 KiB
ObjectPascal

unit uViewEmpresa;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, ExtCtrls, StdCtrls, Buttons, DB, uDADataTable,
DBCtrls, Grids, DBGrids, uBizEmpresas, Mask, ComCtrls, uCustomView,
JvComponent, JvFormAutoSize, cxControls, cxContainer, cxEdit, cxTextEdit,
cxDBEdit, dxLayoutControl, dxLayoutLookAndFeels, cxMemo, cxMaskEdit,
cxSpinEdit, cxImage, JvExControls, JvBitmapButton, ActnList, ImgList,
PngImageList, TB2Item, TBX, TB2Dock, TB2Toolbar, PngSpeedButton, uDAInterfaces,
cxGraphics, cxDropDownEdit;
type
IViewEmpresa = interface(IViewBase)
['{876DCEBD-9E92-491A-84CE-498B1A84B525}']
function GetEmpresa: IBizEmpresa;
procedure SetEmpresa(const Value: IBizEmpresa);
property Empresa: IBizEmpresa read GetEmpresa write SetEmpresa;
end;
TfrViewEmpresa = class(TfrViewBase, IViewEmpresa)
DADataSource: TDADataSource;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxLayoutControl1Group1: TdxLayoutGroup;
dxLayoutControl1Group2: TdxLayoutGroup;
dxLayoutControl1Group3: TdxLayoutGroup;
dxLayoutControl1Group4: TdxLayoutGroup;
dxLayoutControl1Group5: TdxLayoutGroup;
dxLayoutControl1Group6: TdxLayoutGroup;
dxLayoutControl1Group7: TdxLayoutGroup;
dxLayoutControl1Item1: TdxLayoutItem;
eCalle: TcxDBTextEdit;
dxLayoutControl1Item2: TdxLayoutItem;
cbProvincia: TcxDBComboBox;
dxLayoutControl1Item3: TdxLayoutItem;
cbPoblacion: TcxDBComboBox;
dxLayoutControl1Item4: TdxLayoutItem;
eCodigoPostal: TcxDBTextEdit;
dxLayoutControl1Item5: TdxLayoutItem;
ePaginaWeb: TcxDBTextEdit;
dxLayoutControl1Item6: TdxLayoutItem;
eMailParticular: TcxDBTextEdit;
dxLayoutControl1Item7: TdxLayoutItem;
eMailTrabajo: TcxDBTextEdit;
cxDBMemo1: TcxDBMemo;
dxLayoutControl1Item8: TdxLayoutItem;
dxLayoutControl1Item9: TdxLayoutItem;
eTlfParticular: TcxDBTextEdit;
dxLayoutControl1Item10: TdxLayoutItem;
eTlfTrabajo: TcxDBTextEdit;
dxLayoutControl1Item11: TdxLayoutItem;
eTlfMovil: TcxDBTextEdit;
dxLayoutControl1Item12: TdxLayoutItem;
eFax: TcxDBTextEdit;
dxLayoutControl1Item13: TdxLayoutItem;
eNombre: TcxDBTextEdit;
dxLayoutControl1Item14: TdxLayoutItem;
eNIFCIF: TcxDBTextEdit;
dxLayoutControl1Item15: TdxLayoutItem;
memRegistroMercantil: TcxDBMemo;
dxLayoutControl1Group10: TdxLayoutGroup;
dxLayoutControl1Group9: TdxLayoutGroup;
dxLayoutControl1Group11: TdxLayoutGroup;
cxDBSpinEdit1: TcxDBSpinEdit;
dxLayoutControl1Item16: TdxLayoutItem;
ActionList1: TActionList;
actAnadir: TAction;
actEliminar: TAction;
SmallImages: TPngImageList;
OpenDialog1: TOpenDialog;
cxDBImage1: TcxDBImage;
dxLayoutControl1Item17: TdxLayoutItem;
PngSpeedButton1: TPngSpeedButton;
dxLayoutControl1Item19: TdxLayoutItem;
PngSpeedButton2: TPngSpeedButton;
dxLayoutControl1Item20: TdxLayoutItem;
dxLayoutControl1Group12: TdxLayoutGroup;
dxLayoutControl1Group13: TdxLayoutGroup;
procedure actAnadirExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure actEliminarUpdate(Sender: TObject);
procedure actAnadirUpdate(Sender: TObject);
procedure eProvinciaPropertiesInitPopup(Sender: TObject);
procedure ePoblacionPropertiesInitPopup(Sender: TObject);
private
FEmpresa: IBizEmpresa;
FProvincias : TStringList;
FPoblaciones : TStringList;
procedure CargarProvincias;
procedure CargarPoblaciones;
protected
function GetEmpresa: IBizEmpresa;
procedure SetEmpresa(const Value: IBizEmpresa);
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
end;
implementation
{$R *.dfm}
uses uROClasses, uROTypes, uProvinciasPoblacionesController, uStringsUtils;
{ TfrViewEmpresas }
{
******************************* TfrViewEmpresa ********************************
}
procedure TfrViewEmpresa.actAnadirExecute(Sender: TObject);
{var
StdStream: TMemoryStream;
StreamRO: IROStream;
}
begin
inherited;
cxDBImage1.LoadFromFile;
{if not OpenDialog1.Execute then
Exit;
try
StdStream := TMemoryStream.Create;
StdStream.LoadFromFile(OpenDialog1.FileName);
StreamRO := NewROStream(StdStream,False);
DADataSource.DataTable.Edit;
// DADataSource.DataTable.FieldByName('LOGOTIPO').Clear;
DADataSource.DataTable.FieldByName('LOGOTIPO').LoadFromStream(StreamRO);
DADataSource.DataTable.Post;
finally
StdStream.Free;
end;
}
end;
procedure TfrViewEmpresa.actAnadirUpdate(Sender: TObject);
begin
inherited;
// (Sender as TAction).Enabled := cxDBImage1.Picture.Graphic.Empty;
end;
procedure TfrViewEmpresa.actEliminarExecute(Sender: TObject);
begin
inherited;
cxDBImage1.Clear;
{ DADataSource.DataTable.Edit;
DADataSource.DataTable.FieldByName('LOGOTIPO').AsVariant := Null;
DADataSource.DataTable.Post;
}
end;
procedure TfrViewEmpresa.actEliminarUpdate(Sender: TObject);
begin
inherited;
// (Sender as TAction).Enabled := not cxDBImage1.Picture.Graphic.Empty;
end;
procedure TfrViewEmpresa.CargarPoblaciones;
var
i : integer;
AID : Integer;
begin
AID := StrToInt(FProvincias.Values[cbProvincia.Text]);
with TProvinciasPoblacionesController.Create do
begin
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;
end;
procedure TfrViewEmpresa.CargarProvincias;
var
i : integer;
begin
with TProvinciasPoblacionesController.Create do
begin
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;
end;
constructor TfrViewEmpresa.Create(AOwner : TComponent);
begin
inherited;
FProvincias := NIL;
FPoblaciones := NIL;
end;
destructor TfrViewEmpresa.Destroy;
begin
if Assigned(FProvincias) then
FreeANDNIL(FProvincias);
if Assigned(FPoblaciones) then
FreeANDNIL(FPoblaciones);
inherited;
end;
procedure TfrViewEmpresa.ePoblacionPropertiesInitPopup(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 TfrViewEmpresa.eProvinciaPropertiesInitPopup(Sender: TObject);
begin
ShowHourglassCursor;
try
if not Assigned(FProvincias) then
CargarProvincias;
finally
HideHourglassCursor;
end;
end;
function TfrViewEmpresa.GetEmpresa: IBizEmpresa;
begin
Result := FEmpresa;
end;
procedure TfrViewEmpresa.SetEmpresa(const Value: IBizEmpresa);
begin
FEmpresa := Value;
if Assigned(FEmpresa) then
DADataSource.DataTable := FEmpresa.DataTable
else
DADataSource.DataTable := NIL;
end;
initialization
RegisterClass(TfrViewEmpresa);
finalization
UnRegisterClass(TfrViewEmpresa);
end.