git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES/trunk@334 c93665c3-c93d-084d-9b98-7d5f4a9c3376
140 lines
3.9 KiB
ObjectPascal
140 lines
3.9 KiB
ObjectPascal
unit uEditorEmpresas;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uEditorBase, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|
JvNavigationPane, uViewEmpresas, uBizEmpresas, ActnList, DBActns, uViewGrid,
|
|
Menus, uDataModuleBase, ImgList, PngImageList, TB2Dock, TB2Toolbar, TBX,
|
|
TB2Item, StdActns, TB2ExtItems, TBXExtItems, TB2MRU, DB, uDADataTable,
|
|
JvFormAutoSize, uDAScriptingProvider, uDACDSDataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvFormPlacement, ExtCtrls, uCustomView, uViewBase,
|
|
uViewBarraSeleccion, pngimage, uIEditorEmpresas, uEditorGridBase,
|
|
JvComponentBase, uViewGridBase, uEmpresasController, JvExComCtrls,
|
|
JvStatusBar;
|
|
|
|
type
|
|
TfEditorEmpresas = class(TfEditorGridBase, IEditorEmpresas)
|
|
frViewEmpresas1: TfrViewEmpresas;
|
|
procedure FormShow(Sender: TObject);
|
|
private
|
|
FEmpresas: IBizEmpresa;
|
|
FController : IEmpresasController;
|
|
protected
|
|
function GetEmpresas: IBizEmpresa;
|
|
procedure SetEmpresas(const Value: IBizEmpresa);
|
|
function GetController : IEmpresasController; virtual;
|
|
procedure SetController (const Value : IEmpresasController); virtual;
|
|
|
|
procedure NuevoInterno; override;
|
|
procedure EliminarInterno; override;
|
|
procedure ModificarInterno; override;
|
|
|
|
public
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
property Empresas: IBizEmpresa read GetEmpresas write SetEmpresas;
|
|
property Controller : IEmpresasController read GetController write SetController;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
uCustomEditor, uDataModuleEmpresas, //uDataModuleUsuarios,
|
|
// uEditorAlmacen,
|
|
uEditorDBBase,
|
|
cxGrid, cxGridCustomTableView; //, uListaEmpresas;
|
|
|
|
{$R *.dfm}
|
|
|
|
{
|
|
****************************** TfEditorEmpresas *******************************
|
|
}
|
|
procedure TfEditorEmpresas.FormShow(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
|
|
if not Assigned(ViewGrid) then
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
if not Assigned(Empresas) then
|
|
raise Exception.Create('No hay ningún Almacen asignado');
|
|
|
|
Empresas.DataTable.Active := True;
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
function TfEditorEmpresas.GetEmpresas: IBizEmpresa;
|
|
begin
|
|
Result := FEmpresas;
|
|
end;
|
|
|
|
function TfEditorEmpresas.GetController: IEmpresasController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.ModificarInterno;
|
|
begin
|
|
inherited;
|
|
FController.Ver(Empresas);
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.NuevoInterno;
|
|
begin
|
|
inherited;
|
|
FController.Anadir(Empresas);
|
|
FController.Ver(Empresas);
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
// FTitulo := 'Lista de empresas - ' + dmUsuarios.EmpresaActual.NOMBRE;
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.SetEmpresas(const Value: IBizEmpresa);
|
|
begin
|
|
FEmpresas := Value;
|
|
dsDataTable.DataTable := FEmpresas.DataTable;
|
|
if Assigned(ViewGrid) then
|
|
(ViewGrid as IViewEmpresas).Empresas := Empresas;
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.SetController(const Value: IEmpresasController);
|
|
begin
|
|
FController := Value;
|
|
end;
|
|
|
|
destructor TfEditorEmpresas.Destroy;
|
|
begin
|
|
FEmpresas := NIL;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfEditorEmpresas.EliminarInterno;
|
|
begin
|
|
|
|
if (Application.MessageBox('¿Desea borrar esta empresa?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
inherited;
|
|
//Para que en el caso de no poderse realizar la operación se refresquen
|
|
//los datos y no nos permita eliminar un registro a la segunda
|
|
if not FController.Eliminar(Empresas) then
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
constructor TfEditorEmpresas.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
ViewGrid := frViewEmpresas1; //CreateView(TfrViewEmpresas) as IViewEmpresas;
|
|
end;
|
|
|
|
end.
|
|
|