115 lines
3.0 KiB
ObjectPascal
115 lines
3.0 KiB
ObjectPascal
unit uViewFiltroArticulos;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewBase, cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit,
|
|
StdCtrls, Buttons, TBXDkPanels, uViewParametrosInforme, uBizArticulos,
|
|
uArticulosController, uIViewFiltroArticulos;
|
|
|
|
type
|
|
|
|
|
|
TfrViewFiltroArticulos = class(TfrViewParametrosInforme, IViewFiltroArticulos)
|
|
TBXLabel2: TTBXLabel;
|
|
rbTodosArticulos: TRadioButton;
|
|
rbUnArticulo: TRadioButton;
|
|
cbxDesglosado: TCheckBox;
|
|
bElegirArticulo: TBitBtn;
|
|
edtArticulo: TcxTextEdit;
|
|
procedure rbTodosArticulosClick(Sender: TObject);
|
|
procedure rbUnArticuloClick(Sender: TObject);
|
|
procedure CustomViewCreate(Sender: TObject);
|
|
procedure bElegirArticuloClick(Sender: TObject);
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|
private
|
|
FArticulo : IBizArticulo;
|
|
FArticulosController : IArticulosController;
|
|
function getIdArticulo: Integer;
|
|
procedure setIdArticulo(const IdArticulo:Integer);
|
|
public
|
|
property IdArticulo : Integer read getIdArticulo write setIdArticulo;
|
|
property Articulo : IBizArticulo read FArticulo;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure TfrViewFiltroArticulos.bElegirArticuloClick(Sender: TObject);
|
|
var
|
|
AArticulos : IBizArticulo;
|
|
begin
|
|
inherited;
|
|
AArticulos := IBizArticulo(FArticulosController.BuscarTodos);
|
|
try
|
|
FArticulo := IBizArticulo(FArticulosController.ElegirArticulos(AArticulos, '', False));
|
|
if Assigned(FArticulo) then
|
|
begin
|
|
FArticulo.Open;
|
|
edtArticulo.Text := FArticulo.DESCRIPCION;
|
|
end;
|
|
finally
|
|
AArticulos := NIL;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewFiltroArticulos.CustomViewCreate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FArticulo := NIL;
|
|
FArticulosController := NIL;
|
|
end;
|
|
|
|
procedure TfrViewFiltroArticulos.CustomViewDestroy(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FArticulo := NIL;
|
|
FArticulosController := NIL;
|
|
end;
|
|
|
|
function TfrViewFiltroArticulos.getIdArticulo: Integer;
|
|
begin
|
|
Result := FArticulo.ID;
|
|
end;
|
|
|
|
procedure TfrViewFiltroArticulos.rbTodosArticulosClick(Sender: TObject);
|
|
begin
|
|
if rbTodosArticulos.Checked then
|
|
begin
|
|
cbxDesglosado.Enabled := True;
|
|
FArticulo := NIL;
|
|
bElegirArticulo.Enabled := False;
|
|
edtArticulo.Clear;
|
|
edtArticulo.Enabled := False;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewFiltroArticulos.rbUnArticuloClick(Sender: TObject);
|
|
begin
|
|
if rbUnArticulo.Checked then
|
|
begin
|
|
cbxDesglosado.Enabled := False;
|
|
bElegirArticulo.Enabled := True;
|
|
edtArticulo.Enabled := True;
|
|
if not Assigned(FArticulosController) then
|
|
FArticulosController := TArticulosController.Create;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewFiltroArticulos.setIdArticulo(const IdArticulo: Integer);
|
|
begin
|
|
if not Assigned(FArticulosController) then
|
|
FArticulosController := TArticulosController.Create;
|
|
|
|
FArticulo := IBizArticulo(FArticulosController.Buscar(IdArticulo));
|
|
if Assigned(FArticulo) then
|
|
begin
|
|
FArticulo.Open;
|
|
edtArticulo.Text := FArticulo.DESCRIPCION;
|
|
end;
|
|
end;
|
|
|
|
end.
|