Tecsitel_FactuGES2/Source/ApplicationBase/Empresas/Views/uViewEmpresa.pas

313 lines
9.1 KiB
ObjectPascal
Raw Blame History

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,
cxCurrencyEdit, 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;
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;
dxLayoutControl1Item18: TdxLayoutItem;
eParamMargen: TcxDBSpinEdit;
dxLayoutControl1Item21: TdxLayoutItem;
eParamTiempo: TcxDBCurrencyEdit;
dxLayoutControl1Item22: TdxLayoutItem;
cbProvincia: TcxDBComboBox;
dxLayoutControl1Item3: TdxLayoutItem;
cbPoblacion: TcxDBComboBox;
dxLayoutControl1Group8: TdxLayoutGroup;
dxLayoutControl1Group15: TdxLayoutGroup;
procedure actAnadirExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure actEliminarUpdate(Sender: TObject);
procedure actAnadirUpdate(Sender: TObject);
procedure eParamTiempoPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
procedure eParamMargenPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
procedure cbProvinciaPropertiesInitPopup(Sender: TObject);
procedure cbPoblacionPropertiesInitPopup(Sender: TObject);
private
FEmpresa: IBizEmpresa;
FProvincias : TStringList;
FPoblaciones : TStringList;
procedure CargarProvincias;
procedure CargarPoblaciones;
protected
function GetEmpresa: IBizEmpresa;
procedure SetEmpresa(const Value: IBizEmpresa);
public
bModificarCatalogo: Boolean;
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
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 TfrViewEmpresa.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 TfrViewEmpresa.cbPoblacionPropertiesInitPopup(Sender: TObject);
begin
inherited;
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.cbProvinciaPropertiesInitPopup(Sender: TObject);
begin
inherited;
ShowHourglassCursor;
try
if not Assigned(FProvincias) then
CargarProvincias;
finally
HideHourglassCursor;
end;
end;
constructor TfrViewEmpresa.Create(AOwner : TComponent);
begin
inherited;
FProvincias := NIL;
FPoblaciones := NIL;
bModificarCatalogo := False;
end;
destructor TfrViewEmpresa.Destroy;
begin
if Assigned(FProvincias) then
FreeANDNIL(FProvincias);
if Assigned(FPoblaciones) then
FreeANDNIL(FPoblaciones);
inherited;
end;
procedure TfrViewEmpresa.eParamMargenPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
begin
inherited;
if (Application.MessageBox('Si modifica el margen de venta, se recalcular<61>n los precios del cat<61>logo de art<72>culos, <20>Esta seguro que desea continuar?', 'Atenci<63>n', MB_YESNO) = IDYES) then
bModificarCatalogo := True
else
DisplayValue := eParamTiempo.Value;
end;
procedure TfrViewEmpresa.eParamTiempoPropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
begin
inherited;
if (Application.MessageBox('Si modifica el precio minuto, se recalcular<61>n los precios del cat<61>logo de art<72>culos, <20>Esta seguro que desea continuar?', 'Atenci<63>n', MB_YESNO) = IDYES) then
bModificarCatalogo := True
else
DisplayValue := eParamTiempo.Value;
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.