git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_FactuGES/trunk@4 6cb6b671-b4a0-dd4c-8bdc-3006503d97e9
251 lines
6.7 KiB
ObjectPascal
251 lines
6.7 KiB
ObjectPascal
unit uEditorMontaje;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, DB, uDADataTable, JvAppStorage,
|
||
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, TBX, TB2Item, TB2Dock,
|
||
TB2Toolbar, ExtCtrls, JvExControls, JvNavigationPane,
|
||
uViewMontaje, uCustomView, uViewBase, uViewTotales,
|
||
StdCtrls, pngimage, AppEvnts, JvComponentBase,
|
||
uBizMontajes,
|
||
|
||
|
||
uIEditorMontaje, uMontajesController,
|
||
dxLayoutLookAndFeels, JvExComCtrls, JvStatusBar;
|
||
|
||
|
||
type
|
||
TfEditorMontaje = class(TfEditorDBItem, IEditorMontaje)
|
||
TBXSubmenuItem2: TTBXSubmenuItem;
|
||
TBXItem33: TTBXItem;
|
||
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
||
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
||
procedure FormShow(Sender: TObject);
|
||
procedure actGuardarExecute(Sender: TObject);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure frViewMontaje1edtlNombrePropertiesEditValueChanged(
|
||
Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure actPrevisualizarExecute(Sender: TObject);
|
||
procedure actImprimirExecute(Sender: TObject);
|
||
procedure frViewMontajeedtlNombrePropertiesChange(Sender: TObject);
|
||
|
||
protected
|
||
FController : IMontajesController;
|
||
FMontaje: IBizMontaje;
|
||
FViewMontaje: IViewMontaje;
|
||
|
||
function GetController : IMontajesController;
|
||
procedure SetController (const Value : IMontajesController); virtual;
|
||
function GetMontaje: IBizMontaje;
|
||
procedure SetMontaje(const Value: IBizMontaje); virtual;
|
||
|
||
function GetViewMontaje: IViewMontaje;
|
||
procedure SetViewMontaje(const Value: IViewMontaje);
|
||
property ViewMontaje: IViewMontaje read GetViewMontaje write SetViewMontaje;
|
||
|
||
procedure OnClienteChanged(Sender : TObject);
|
||
|
||
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
||
//sobreescribir este metodo
|
||
procedure AsignarVista; virtual;
|
||
|
||
public
|
||
procedure PonerTitulos(const ATitulo: string = ''); override;
|
||
property Controller : IMontajesController read GetController write SetController;
|
||
property Montaje: IBizMontaje read GetMontaje write SetMontaje;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
cxDBEdit, uBizContactos, uDataModuleUsuarios;
|
||
|
||
|
||
{ TfEditorMontaje }
|
||
|
||
{
|
||
**************************** TfEditorMontaje ****************************
|
||
}
|
||
constructor TfEditorMontaje.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
pgPaginas.ActivePageIndex := 0;
|
||
AsignarVista;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.CustomEditorClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
dsDataTable.DataTable := NIL;
|
||
FViewMontaje := NIL;
|
||
FMontaje := NIL;
|
||
end;
|
||
|
||
destructor TfEditorMontaje.Destroy;
|
||
begin
|
||
// Utilizar mejor OnClose;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.dsDataTableDataChange(Sender: TObject;
|
||
Field: TField);
|
||
begin
|
||
inherited;
|
||
if Assigned(FMontaje) and (not (FMontaje.DataTable.Fetching) or
|
||
not (FMontaje.DataTable.Opening) or not (FMontaje.DataTable.Closing)) then
|
||
PonerTitulos;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if (Application.MessageBox('<27>Desea borrar este montaje de cliente?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
FController.Eliminar(Montaje);
|
||
inherited;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.actGuardarExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FController.Guardar(FMontaje);
|
||
Modified := False;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.actImprimirExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// FController.Print(FMontaje);
|
||
end;
|
||
|
||
procedure TfEditorMontaje.actPrevisualizarExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
// FController.Preview(FMontaje);
|
||
end;
|
||
|
||
procedure TfEditorMontaje.AsignarVista;
|
||
var
|
||
AViewMontaje: TfrViewMontaje;
|
||
begin
|
||
AViewMontaje := TfrViewMontaje.create(Self);
|
||
with AViewMontaje do
|
||
begin
|
||
Parent := pagGeneral;
|
||
Align := alClient;
|
||
dxLayoutControlMontaje.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
||
end;
|
||
ViewMontaje := AViewMontaje;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(FViewMontaje) then
|
||
raise Exception.Create('No hay ninguna vista asignada');
|
||
|
||
if not Assigned(Montaje) then
|
||
raise Exception.Create('No hay ning<6E>n albar<61>n asignado');
|
||
|
||
Montaje.DataTable.Active := True;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.frViewMontaje1edtlNombrePropertiesEditValueChanged(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
with (Sender as TcxDBTextEdit) do
|
||
Enabled := (FMontaje.ID <> 0)
|
||
end;
|
||
|
||
procedure TfEditorMontaje.frViewMontajeedtlNombrePropertiesChange(
|
||
Sender: TObject);
|
||
begin
|
||
inherited;
|
||
PonerTitulos;
|
||
end;
|
||
|
||
function TfEditorMontaje.GetController: IMontajesController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorMontaje.GetMontaje: IBizMontaje;
|
||
begin
|
||
Result := FMontaje;
|
||
end;
|
||
|
||
function TfEditorMontaje.GetViewMontaje: IViewMontaje;
|
||
begin
|
||
Result := FViewMontaje;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.OnClienteChanged(Sender: TObject);
|
||
begin
|
||
FMontaje.Cliente := ViewMontaje.ViewClienteMontaje.Cliente;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.PonerTitulos(const ATitulo: string);
|
||
var
|
||
FTitulo : String;
|
||
begin
|
||
FTitulo := ATitulo;
|
||
if (FTitulo = '') and Assigned(Montaje) then
|
||
begin
|
||
if Montaje.EsNuevo then
|
||
FTitulo := 'Nueva Montaje'
|
||
else
|
||
FTitulo := 'Montaje' + ' - ' + FMontaje.Cliente.Nombre
|
||
end;
|
||
|
||
inherited PonerTitulos(FTitulo);
|
||
|
||
Self.Caption := FTitulo + ' (' + dmUsuarios.EmpresaActual.NOMBRE + ')';
|
||
end;
|
||
|
||
procedure TfEditorMontaje.SetController(const Value: IMontajesController);
|
||
begin
|
||
FController := Value;
|
||
|
||
if Assigned(FController) then
|
||
ViewMontaje.ViewClienteMontaje.Controller := Controller.ClienteController;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.SetMontaje(const Value: IBizMontaje);
|
||
begin
|
||
FMontaje := Value;
|
||
|
||
if Assigned(FMontaje) then
|
||
begin
|
||
dsDataTable.DataTable := FMontaje.DataTable;
|
||
|
||
if Assigned(FViewMontaje) then
|
||
begin
|
||
ViewMontaje.ViewClienteMontaje.Cliente := FMontaje.Cliente;
|
||
ViewMontaje.ViewClienteMontaje.OnClienteChanged := OnClienteChanged;
|
||
FViewMontaje.Montaje := FMontaje;
|
||
end;
|
||
|
||
Montaje.DataTable.Active := True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorMontaje.SetViewMontaje(const Value: IViewMontaje);
|
||
begin
|
||
FViewMontaje := Value;
|
||
|
||
if Assigned(FViewMontaje) and Assigned(Montaje) then
|
||
FViewMontaje.Montaje := Montaje;
|
||
end;
|
||
|
||
end.
|