unit uViewTiendas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewBase, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridBandedTableView,
  cxGridDBBandedTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
  uDADataTable, Grids, DBGrids, ActnList, ImgList, PngImageList, ComCtrls,
  ToolWin, cxGridDBTableView, uViewDetallesGenerico, cxCurrencyEdit,
  uDAInterfaces;

type
  TfrViewTiendas = class(TfrViewDetallesGenerico)
    cxGridViewDIRECCION: TcxGridDBColumn;
    cxGridViewPOBLACION: TcxGridDBColumn;
    cxGridViewCP: TcxGridDBColumn;
    cxGridViewPROVINCIA: TcxGridDBColumn;
    cxGridViewPERSONA_CONTACTO: TcxGridDBColumn;
    cxGridViewNOMBRE: TcxGridDBColumn;
    cxGridViewTELEFONO: TcxGridDBColumn;
    cxGridViewEMAIL: TcxGridDBColumn;
    cxGridViewPORTE: TcxGridDBColumn;
    cxGridViewCODIGO_CONTABLE: TcxGridDBColumn;
    procedure cxGridViewDblClick(Sender: TObject);
    procedure actEliminarExecute(Sender: TObject);
    procedure CustomViewCreate(Sender: TObject);
  protected
    procedure AnadirInterno; override;
    procedure ModificarInterno; override;
  public
    { Public declarations }
  end;

implementation
{$R *.dfm}
{$INCLUDE ..\..\..\FactuGES.inc}

uses
  uDialogUtils, uTiendasEmpresaController, uBizEmpresasTiendas;

procedure TfrViewTiendas.actEliminarExecute(Sender: TObject);
begin
  if (ShowConfirmMessage('Eliminar una tienda', '¿Desea eliminar esta tienda?') = IDYES) then
    inherited;
end;

procedure TfrViewTiendas.AnadirInterno;
var
  ATiendasController : ITiendasEmpresaController;
begin
  inherited;

  ATiendasController := TTiendasEmpresaController.Create;
  try
    ATiendasController.Ver((dsDetalles.DataTable) as IBizEmpresaTienda);
    if (dsDetalles.DataTable.State in dsEditModes) then
      dsDetalles.DataTable.Post;
  finally
    ATiendasController := NIL;
  end;
end;

procedure TfrViewTiendas.CustomViewCreate(Sender: TObject);
begin
  inherited;

  {$IFDEF CONTABILIDAD}
    cxGridViewCODIGO_CONTABLE.VisibleForCustomization := true;
    cxGridViewCODIGO_CONTABLE.Visible := true;
  {$ELSE}
    cxGridViewCODIGO_CONTABLE.VisibleForCustomization := false;
    cxGridViewCODIGO_CONTABLE.Visible := false;
  {$ENDIF}
end;

procedure TfrViewTiendas.cxGridViewDblClick(Sender: TObject);
begin
  inherited;
  actModificar.Execute;
end;

procedure TfrViewTiendas.ModificarInterno;
var
  AController : ITiendasEmpresaController;
begin
  inherited;
  AController := TTiendasEmpresaController.Create;
  try
    AController.Ver((dsDetalles.DataTable) as IBizEmpresaTienda);
  finally
    AController := NIL;
  end;
end;

end.



