387 lines
11 KiB
ObjectPascal
387 lines
11 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2005. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n: 01-01-2004
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.1
|
|||
|
|
Fecha versi<EFBFBD>n actual: 04-03-2005
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
04-03-2005 Se ha cambiado el bSeleccionar para que en el caso de elegir
|
|||
|
|
un unico articulo coja los datos de la tabla y no de la lista
|
|||
|
|
ya que en el caso de elegir uno la lista no refresca
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit ArticulosFabPro;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|||
|
|
Articulos, Db, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ExtCtrls, dxEditor,
|
|||
|
|
dxExEdtr, dxDBEdtr, dxDBELib, StdCtrls, RdxBarras, RdxBotones, RdxPaneles,
|
|||
|
|
RdxComboBox, Tipos;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrArticulosFabPro = class(TfrArticulos)
|
|||
|
|
cbxFabricante: TRdxComboBox;
|
|||
|
|
eFabricante: TLabel;
|
|||
|
|
eProveedor: TLabel;
|
|||
|
|
cbxProveedor: TRdxComboBox;
|
|||
|
|
procedure cbxFabricanteChange(Sender: TObject);
|
|||
|
|
procedure cbxProveedorChange(Sender: TObject);
|
|||
|
|
procedure bBuscarClick(Sender: TObject);
|
|||
|
|
|
|||
|
|
private
|
|||
|
|
FNombreProveedor: Variant;
|
|||
|
|
FListaCodArtProAux: TStringList;
|
|||
|
|
FListaCodArtPro: TStringList;
|
|||
|
|
FListaCodArtFabAux: TStringList;
|
|||
|
|
FListaCodArtFab: TStringList;
|
|||
|
|
FListaPreciosAux: TStringList;
|
|||
|
|
FListaPrecios: TStringList;
|
|||
|
|
|
|||
|
|
procedure SetListaCodArtPro (Value : TStringList);
|
|||
|
|
procedure SetListaCodArtFab (Value : TStringList);
|
|||
|
|
procedure SetListaPrecios (Value : TStringList);
|
|||
|
|
procedure SetFCodArtPro(const Value: Variant);
|
|||
|
|
procedure SetFCodArtFab(const Value: Variant);
|
|||
|
|
procedure SetFPrecio(const Value: Variant);
|
|||
|
|
function GetFCodArtPro: Variant;
|
|||
|
|
function GetFCodArtFab: Variant;
|
|||
|
|
function GetFPrecio: Variant;
|
|||
|
|
|
|||
|
|
procedure filtrar (cbxChange: Integer);
|
|||
|
|
procedure setNombreProveedor(const Value: Variant);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
procedure BuscarArticulo; override;
|
|||
|
|
procedure CambiarModo(ModoAnterior, Modo : TRdxModo); override;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
property NombreProveedor: Variant read FNombreProveedor write setNombreProveedor;
|
|||
|
|
property ListaCodArtPro : TStringList read FListaCodArtPro write SetListaCodArtPro;
|
|||
|
|
property ListaCodArtFab : TStringList read FListaCodArtFab write SetListaCodArtFab;
|
|||
|
|
property CodArtPro : Variant read GetFCodArtPro write SetFCodArtPro;
|
|||
|
|
property CodArtFab : Variant read GetFCodArtFab write SetFCodArtFab;
|
|||
|
|
|
|||
|
|
property ListaPrecios : TStringList read FListaPrecios write SetListaPrecios;
|
|||
|
|
property Precio : Variant read GetFPrecio write SetFPrecio;
|
|||
|
|
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
|
|||
|
|
published
|
|||
|
|
procedure gridArticulosSelectedCountChange2(Sender: TObject);
|
|||
|
|
procedure bSeleccionarClick(Sender: TObject); override;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frArticulosFabPro: TfrArticulosFabPro;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses Constantes, TablaArticulos, TablaFabricantes, TablaProveedores,
|
|||
|
|
BuscarArticuloFabPro, StrFunc, mensajes, literales;
|
|||
|
|
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
{ TfrArticulosFabPro }
|
|||
|
|
|
|||
|
|
constructor TfrArticulosFabPro.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
with TablaArticulos do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
DisableControls;
|
|||
|
|
SelectSQL.Assign(dmTablaArticulos.sqlGridArtFabPro);
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
dmTablaArticulos.InicializarTablaArticulosFabPro(@TablaArticulos);
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
dmTablaArticulos.InicializarGridArticulosFabPro(gridArticulos);
|
|||
|
|
|
|||
|
|
|
|||
|
|
cbxFabricante.Items := dmTablaFabricantes.DarListaFabricantes;
|
|||
|
|
cbxFabricante.ItemIndex := 0;
|
|||
|
|
|
|||
|
|
cbxProveedor.Items := dmTablaProveedores.DarListaProveedores;
|
|||
|
|
cbxProveedor.ItemIndex := 0;
|
|||
|
|
|
|||
|
|
FListaPreciosAux := TStringList.Create;
|
|||
|
|
FListaPrecios := TStringList.Create;
|
|||
|
|
|
|||
|
|
FListaCodArtProAux := TStringList.Create;
|
|||
|
|
FListaCodArtPro := TStringList.Create;
|
|||
|
|
FListaCodArtFabAux := TStringList.Create;
|
|||
|
|
FListaCodArtFab := TStringList.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.cbxFabricanteChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
filtrar(0);
|
|||
|
|
gridArticulos.SetFocus;
|
|||
|
|
gridArticulos.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.cbxProveedorChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
filtrar(1);
|
|||
|
|
gridArticulos.SetFocus;
|
|||
|
|
gridArticulos.GotoFirst;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.filtrar(cbxChange: Integer);
|
|||
|
|
begin
|
|||
|
|
if (cbxChange = 0) then
|
|||
|
|
begin
|
|||
|
|
gridArticulos.Filter.Remove(gridArticulos.FindColumnByFieldName('FABRICANTE'));
|
|||
|
|
if cbxFabricante.Text <> CTE_TODOS then
|
|||
|
|
gridArticulos.Filter.Add(gridArticulos.FindColumnByFieldName('FABRICANTE'), cbxFabricante.Text, cbxFabricante.Text);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if (cbxChange = 1) then
|
|||
|
|
begin
|
|||
|
|
gridArticulos.Filter.Remove(gridArticulos.FindColumnByFieldName('PROVEEDOR'));
|
|||
|
|
if cbxProveedor.Text <> CTE_TODOS then
|
|||
|
|
gridArticulos.Filter.Add(gridArticulos.FindColumnByFieldName('PROVEEDOR'), cbxProveedor.Text, cbxProveedor.Text);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.bBuscarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CodigoArticulo := TablaArticulos.FieldByName('CODIGO').AsString;
|
|||
|
|
Contenido := TfrBuscarArticuloFabPro.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetListaPrecios(Value: TStringList);
|
|||
|
|
begin
|
|||
|
|
if (Value = Nil) or (Value.Count = 0) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
FListaPrecios.Clear;
|
|||
|
|
FListaPrecios.Assign(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrArticulosFabPro.GetFPrecio: Variant;
|
|||
|
|
begin
|
|||
|
|
if (ListaPrecios.Count = 0) then
|
|||
|
|
Result := NULL
|
|||
|
|
else
|
|||
|
|
Result := ListaPrecios.Strings[ListaPrecios.Count-1];
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetFPrecio(const Value: Variant);
|
|||
|
|
begin
|
|||
|
|
FListaPrecios.Clear;
|
|||
|
|
if (VarIsNull(Value))
|
|||
|
|
then
|
|||
|
|
FListaPrecios.Add('')
|
|||
|
|
else
|
|||
|
|
FListaPrecios.Add(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrArticulosFabPro.Destroy;
|
|||
|
|
begin
|
|||
|
|
if FListaCodArtProAux <> NIL then
|
|||
|
|
begin
|
|||
|
|
FListaCodArtProAux.Clear;
|
|||
|
|
FListaCodArtProAux.Free;
|
|||
|
|
FListaCodArtProAux := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if FListaCodArtFabAux <> NIL then
|
|||
|
|
begin
|
|||
|
|
FListaCodArtFabAux.Clear;
|
|||
|
|
FListaCodArtFabAux.Free;
|
|||
|
|
FListaCodArtFabAux := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if FListaPreciosAux <> NIL then
|
|||
|
|
begin
|
|||
|
|
FListaPreciosAux.Clear;
|
|||
|
|
FListaPreciosAux.Free;
|
|||
|
|
FListaPreciosAux := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
FListaCodArtPro.free;
|
|||
|
|
FListaCodArtPro := NIL;
|
|||
|
|
|
|||
|
|
FListaCodArtFab.free;
|
|||
|
|
FListaCodArtFab := NIL;
|
|||
|
|
|
|||
|
|
FListaPrecios.free;
|
|||
|
|
FListaPrecios := NIL;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.gridArticulosSelectedCountChange2(
|
|||
|
|
Sender: TObject);
|
|||
|
|
var
|
|||
|
|
IndiceCol1 : Integer;
|
|||
|
|
IndiceCol2 : Integer;
|
|||
|
|
IndiceCol3 : Integer;
|
|||
|
|
IndiceSel : Integer;
|
|||
|
|
|
|||
|
|
begin
|
|||
|
|
inherited gridArticulosSelectedCountChange(Sender);
|
|||
|
|
|
|||
|
|
if TablaArticulos.Active then
|
|||
|
|
begin
|
|||
|
|
IndiceCol1 := gridArticulos.ColumnByFieldName('PRECIOFINAL').Index;
|
|||
|
|
IndiceCol2 := gridArticulos.ColumnByFieldName('CODARTPROVEEDOR').Index;
|
|||
|
|
IndiceCol3 := gridArticulos.ColumnByFieldName('CODARTFABRICANTE').Index;
|
|||
|
|
|
|||
|
|
//Limpiamos las listas
|
|||
|
|
FListaPreciosAux.Clear;
|
|||
|
|
FListaCodArtProAux.Clear;
|
|||
|
|
FListaCodArtFabAux.Clear;
|
|||
|
|
|
|||
|
|
for IndiceSel:=0 to gridArticulos.SelectedCount-1 do
|
|||
|
|
begin
|
|||
|
|
FListaPreciosAux.Add(FloatToStr(gridArticulos.SelectedNodes[IndiceSel].Values[IndiceCol1]));
|
|||
|
|
FListaCodArtProAux.Add(gridArticulos.SelectedNodes[IndiceSel].Values[IndiceCol2]);
|
|||
|
|
FListaCodArtFabAux.Add(gridArticulos.SelectedNodes[IndiceSel].Values[IndiceCol3]);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.bSeleccionarClick(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
IndiceCol1 : Integer;
|
|||
|
|
IndiceCol2 : Integer;
|
|||
|
|
IndiceCol3 : Integer;
|
|||
|
|
contador:integer;
|
|||
|
|
|
|||
|
|
begin
|
|||
|
|
if gridArticulos.SelectedCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgArtNoHayArt);
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if gridArticulos.SelectedCount = 1 then
|
|||
|
|
begin
|
|||
|
|
IndiceCol1 := gridArticulos.ColumnByFieldName('PRECIOFINAL').Index;
|
|||
|
|
IndiceCol2 := gridArticulos.ColumnByFieldName('CODARTPROVEEDOR').Index;
|
|||
|
|
IndiceCol3 := gridArticulos.ColumnByFieldName('CODARTFABRICANTE').Index;
|
|||
|
|
|
|||
|
|
Precio := FloatToStr(gridArticulos.SelectedNodes[0].Values[IndiceCol1]);
|
|||
|
|
CodArtPro := gridArticulos.SelectedNodes[0].Values[IndiceCol2];
|
|||
|
|
CodArtFab := gridArticulos.SelectedNodes[0].Values[IndiceCol3];
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
ListaPrecios := FListaPreciosAux;
|
|||
|
|
ListaCodArtPro := FListaCodArtProAux;
|
|||
|
|
ListaCodArtFab := FListaCodArtFabAux;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrArticulosFabPro.GetFCodArtPro: Variant;
|
|||
|
|
begin
|
|||
|
|
if (ListaCodArtPro.Count = 0) then
|
|||
|
|
Result := NULL
|
|||
|
|
else
|
|||
|
|
Result := ListaCodArtPro.Strings[ListaCodArtPro.Count-1];
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetFCodArtPro(const Value: Variant);
|
|||
|
|
begin
|
|||
|
|
FListaCodArtPro.Clear;
|
|||
|
|
if (VarIsNull(Value))
|
|||
|
|
then
|
|||
|
|
FListaCodArtPro.Add('')
|
|||
|
|
else
|
|||
|
|
FListaCodArtPro.Add(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetListaCodArtPro(Value: TStringList);
|
|||
|
|
begin
|
|||
|
|
if (Value = Nil) or (Value.Count = 0) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
FListaCodArtPro.Clear;
|
|||
|
|
FListaCodArtPro.Assign(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.setNombreProveedor(const Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if varIsNull(Value) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
FNombreProveedor := Value;
|
|||
|
|
cbxProveedor.ItemIndex := cbxProveedor.Items.IndexOf(FNombreProveedor);
|
|||
|
|
cbxProveedor.Enabled := False;
|
|||
|
|
cbxFabricante.Enabled := False;
|
|||
|
|
filtrar(1);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.BuscarArticulo;
|
|||
|
|
begin
|
|||
|
|
with TablaArticulos do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
Close;
|
|||
|
|
Open;
|
|||
|
|
ActualizarBotones;
|
|||
|
|
dmTablaArticulos.InicializarTablaArticulosFabPro(@TablaArticulos);
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
TablaArticulos.Locate('CODIGO',CodigoArticulo,[]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.CambiarModo(ModoAnterior, Modo: TRdxModo);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
dmTablaArticulos.InicializarTablaArticulosFabPro(@TablaArticulos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetListaCodArtFab(Value: TStringList);
|
|||
|
|
begin
|
|||
|
|
if (Value = Nil) or (Value.Count = 0) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
FListaCodArtFab.Clear;
|
|||
|
|
FListaCodArtFab.Assign(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrArticulosFabPro.SetFCodArtFab(const Value: Variant);
|
|||
|
|
begin
|
|||
|
|
FListaCodArtFab.Clear;
|
|||
|
|
if (VarIsNull(Value))
|
|||
|
|
then
|
|||
|
|
FListaCodArtFab.Add('')
|
|||
|
|
else
|
|||
|
|
FListaCodArtFab.Add(Value);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrArticulosFabPro.GetFCodArtFab: Variant;
|
|||
|
|
begin
|
|||
|
|
if (ListaCodArtFab.Count = 0) then
|
|||
|
|
Result := NULL
|
|||
|
|
else
|
|||
|
|
Result := ListaCodArtFab.Strings[ListaCodArtFab.Count-1];
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|