unit Inven;

interface

uses
  SysUtils,   WinProcs,Messages, Classes, Graphics, Controls,
  StdCtrls, Forms, DBCtrls, DB, DBTables, Mask, ExtCtrls, Buttons, Menus,Dialogos,
  ComCtrls, Tabnotbk, Grids, DBGrids,checa, Graficos, Dialogs{,Concen};

type
  TFormaInventario = class(TForm)
    DataSource1: TDataSource;
    TablaInventario: TTable;
    MainMenu1: TMainMenu;
    Archivo1: TMenuItem;
    Salir1: TMenuItem;
    Registro1: TMenuItem;
    Nuevo1: TMenuItem;
    Modificar1: TMenuItem;
    Guardar1: TMenuItem;
    Buscar1: TMenuItem;
    Imprimir1: TMenuItem;
    Reportes1: TMenuItem;
    Ayuda1: TMenuItem;
    Consultas1: TMenuItem;
    Eliminar1: TMenuItem;
    TablaInventario2: TTable;
    Stocks1: TMenuItem;
    VtasyCprasAnuales1: TMenuItem;
    Existencias2: TMenuItem;
    CostoyCostoPromedio1: TMenuItem;
    TablaInventarioCLPRO_I: TStringField;
    TablaInventarioDSCPR_I: TStringField;
    TablaInventarioUMEDI_I: TStringField;
    TablaInventarioLIPRO_I: TStringField;
    TablaInventarioCODIG_I: TStringField;
    TablaInventarioUEMPA_I: TFloatField;
    TablaInventarioCLPR1_I: TStringField;
    TablaInventarioCLPR2_I: TStringField;
    TablaInventarioFEULC_I: TDateField;
    TablaInventarioFEULV_I: TDateField;
    TablaInventarioPTICA_I: TStringField;
    TablaInventarioPIVA1_I: TFloatField;
    TablaInventarioPIVA2_I: TFloatField;
    TablaInventarioSTMIN_I: TFloatField;
    TablaInventarioSTMAX_I: TFloatField;
    TablaInventarioEXIST_I: TFloatField;
    TablaInventarioCOMRE_I: TFloatField;
    TablaInventarioPESUR_I: TFloatField;
    TablaInventarioULCOS_I: TFloatField;
    TablaInventarioCPROM_I: TFloatField;
    TablaInventarioPPUBL_I: TFloatField;
    TablaInventarioPLIS2_I: TFloatField;
    TablaInventarioPLIS3_I: TFloatField;
    TablaInventarioPLIS4_I: TFloatField;
    TablaInventarioPMINI_I: TFloatField;
    TablaInventarioVANMO_I: TFloatField;
    TablaInventarioVANCA_I: TFloatField;
    Bevel1: TBevel;
    Panel2: TPanel;
    Caja: TScrollBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    EditDSCPR_I: TDBEdit;
    EditUMEDI_I: TDBEdit;
    EditLIPRO_I: TDBEdit;
    EditUEMPA_I: TDBEdit;
    EditCLPR_I: TDBEdit;
    EditCLPR_I2: TDBEdit;
    EditFEULC_I: TDBEdit;
    EditFEULV_I: TDBEdit;
    EditPTICA_I: TDBEdit;
    EditTICOS_I: TDBEdit;
    EditPIVA_I: TDBEdit;
    EditPIVA_I2: TDBEdit;
    EditSTMIN_I: TDBEdit;
    EditSTMAX_I: TDBEdit;
    EditEXIST_I: TDBEdit;
    EditCOMRE_I: TDBEdit;
    EditPESUR_I: TDBEdit;
    EditULCOS_I: TDBEdit;
    EditCPROM_I: TDBEdit;
    EditPPUBL_I: TDBEdit;
    EditPLIS_I: TDBEdit;
    EditPLIS_I2: TDBEdit;
    EditPLIS_I3: TDBEdit;
    EditPMINI_I: TDBEdit;
    EditVANMO_I: TDBEdit;
    EditVANCA_I: TDBEdit;
    EditCLPRO_I: TEdit;
    Panel1: TPanel;
    BotonNuevo: TSpeedButton;
    BotonGuardar: TSpeedButton;
    BotonImprimir: TSpeedButton;
    BotonBuscar: TSpeedButton;
    BotonSalir: TSpeedButton;
    BotonCambios: TSpeedButton;
    Usuario: TLabel;
    Navegador: TDBNavigator;
    Uno: TLabel;
    Dos: TLabel;
    Barras1: TMenuItem;
    ImprimeCdigo1: TMenuItem;
    ImprimeelRangodeCdigos1: TMenuItem;
    Bevel2: TBevel;
    Bevel5: TBevel;
    Bevel6: TBevel;
    Bevel7: TBevel;
    Bevel8: TBevel;
    Bevel9: TBevel;
    Bevel10: TBevel;
    Bevel11: TBevel;
    Bevel12: TBevel;
    Bevel13: TBevel;
    Bevel14: TBevel;
    Bevel15: TBevel;
    Bevel16: TBevel;
    Bevel17: TBevel;
    Bevel18: TBevel;
    Bevel19: TBevel;
    Bevel20: TBevel;
    Bevel21: TBevel;
    TablaInventarioTICOS_I: TStringField;
    TablaAuxiliar: TTable;
    Estructura: TBatchMove;
    AbreArchivo: TOpenDialog;
    PanelImagen: TPanel;
    Imagen: TImage;
    ImprimePlantilla1: TMenuItem;
    TamanoCaracteres: TLabel;
    Temas1: TMenuItem;
    BotonPreliminar: TSpeedButton;
    TablaInventarioIMAGE_I: TStringField;
    Opciones1: TMenuItem;
    ActualizaPrecios1: TMenuItem;
    NmerosdeSerie1: TMenuItem;
    Series: TCheckBox;
    Kit: TCheckBox;
    TablaInventarioSERIE_I: TStringField;
    TablaInventarioKITXX_I: TStringField;
    procedure FormCreate(Sender: TObject);
    procedure BotonGuardarClick(Sender: TObject);
    procedure BotonSalirClick(Sender: TObject);
    procedure BotonNuevoClick(Sender: TObject);
    procedure EditTICOS_IKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure NavegadorClick(Sender: TObject; Button: TNavigateBtn);
    procedure FormActivate(Sender: TObject);
    procedure Consultas1Click(Sender: TObject);
    procedure BotonCambiosClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Eliminar1Click(Sender: TObject);
    procedure BotonBuscarClick(Sender: TObject);
    procedure EditCLPRO_IKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure AreaGraficaPaint(Sender: TObject);
    procedure FolderChange(Sender: TObject; NewTab: Integer;
      var AllowChange: Boolean);
    procedure BotonImprimirClick(Sender: TObject);
    procedure EditCLPRO_IEnter(Sender: TObject);
    procedure EditDSCPR_IEnter(Sender: TObject);
    procedure EditUMEDI_IEnter(Sender: TObject);
    procedure EditLIPRO_IEnter(Sender: TObject);
    procedure EditUEMPA_IEnter(Sender: TObject);
    procedure EditCLPR_IEnter(Sender: TObject);
    procedure EditCLPR_I2Enter(Sender: TObject);
    procedure EditFEULC_IEnter(Sender: TObject);
    procedure EditFEULV_IEnter(Sender: TObject);
    procedure EditPTICA_IEnter(Sender: TObject);
    procedure EditTICOS_IEnter(Sender: TObject);
    procedure EditPIVA_IEnter(Sender: TObject);
    procedure EditPIVA_I2Enter(Sender: TObject);
    procedure EditSTMIN_IEnter(Sender: TObject);
    procedure EditSTMAX_IEnter(Sender: TObject);
    procedure EditEXIST_IEnter(Sender: TObject);
    procedure EditCOMRE_IEnter(Sender: TObject);
    procedure EditPESUR_IEnter(Sender: TObject);
    procedure EditULCOS_IEnter(Sender: TObject);
    procedure EditCPROM_IEnter(Sender: TObject);
    procedure EditPPUBL_IEnter(Sender: TObject);
    procedure EditPLIS_IEnter(Sender: TObject);
    procedure EditPLIS_I2Enter(Sender: TObject);
    procedure EditPLIS_I3Enter(Sender: TObject);
    procedure EditPMINI_IEnter(Sender: TObject);
    procedure EditVANMO_IEnter(Sender: TObject);
    procedure EditVANCA_IEnter(Sender: TObject);
    procedure EditCLPRO_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditDSCPR_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditUMEDI_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditLIPRO_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditUEMPA_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditCLPR_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditFEULC_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditFEULV_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPTICA_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditTICOS_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPIVA_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPIVA_I2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditSTMIN_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditSTMAX_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditEXIST_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditCOMRE_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPESUR_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditULCOS_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditCPROM_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPPUBL_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPLIS_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPLIS_I2MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPLIS_I3MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditPMINI_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditVANMO_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure EditVANCA_IMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Stocks1Click(Sender: TObject);
    procedure VtasyCprasAnuales1Click(Sender: TObject);
    procedure Existencias2Click(Sender: TObject);
    procedure CostoyCostoPromedio1Click(Sender: TObject);
    procedure ImprimeCdigo1Click(Sender: TObject);
    procedure ImprimeelRangodeCdigos1Click(Sender: TObject);
    procedure TablaInventarioEditError(DataSet: TDataSet;
      E: EDatabaseError; var Action: TDataAction);
    procedure TablaInventarioPostError(DataSet: TDataSet;
      E: EDatabaseError; var Action: TDataAction);
    procedure BotonCambiosMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonNuevoMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonGuardarMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonBuscarMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonImprimirMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure EditCLPR_I2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure EditCLPR_IKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ImagenDblClick(Sender: TObject);
    procedure PanelImagenDblClick(Sender: TObject);
    procedure ImprimePlantilla1Click(Sender: TObject);
    procedure EditCLPRO_IKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Temas1Click(Sender: TObject);
    procedure BotonPreliminarClick(Sender: TObject);
    procedure ActualizaPrecios1Click(Sender: TObject);
    procedure TablaInventarioFilterRecord(DataSet: TDataSet;
      var Accept: Boolean);
    procedure NmerosdeSerie1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FormaInventario: TFormaInventario;
  indice:integer;
  cargo,abono:array[1..12] of real;
  nombreformato:string;
  condfiltro:array[1..120] of String;

procedure posicionainventario(clave:string);
procedure datosdefiltrado(cond:string);
function filtratablatipo(nombredetabla:TDataSet):integer;
implementation

uses Tipinve, consulta, buscar, cerrar,formato, barras, formatos,
     describe,progreso,ConPromo,imagview,AyudaMod, edicion, antedi,
  PrecInve, series, Serie;

{$R *.DFM}

{**************procedimientos de filtrado******}
function tipofecha(tipo:string):Boolean;
begin

if tipo='ftDate' then
tipofecha:=True
else
tipofecha:=False;

end;




procedure FiltraPorTabla(DataSet: TDataSet;  var Accept: Boolean);
var
i,cuenta:integer;
casos:array[1..30]of boolean;
casosaux:Boolean;
begin

casosaux:=True;

for i:=1 to 30 do
casos[i]:=True;

cuenta:=1;
i:=1;
while i<120 do
begin

if condfiltro[i+1]<>'' then
begin
if   tipofecha(condfiltro[i+3]) then
begin
case tipooperador(condfiltro[i+1]) of
'=':casos[cuenta]:=(DataSet[condfiltro[i]]=StrToDateTime(condfiltro[i+2]));
'<':casos[cuenta]:=(DataSet[condfiltro[i]]<StrToDateTime(condfiltro[i+2]));
'>':casos[cuenta]:=(DataSet[condfiltro[i]]>StrToDateTime(condfiltro[i+2]));
'X':casos[cuenta]:=(DataSet[condfiltro[i]]<>StrToDateTime(condfiltro[i+2]));
'Y':casos[cuenta]:=(DataSet[condfiltro[i]]<=StrToDateTime(condfiltro[i+2]));
'Z':casos[cuenta]:=(DataSet[condfiltro[i]]>=StrToDateTime(condfiltro[i+2]));

end;
end
else
begin
case tipooperador(condfiltro[i+1]) of
'=':casos[cuenta]:=(DataSet[condfiltro[i]]=condfiltro[i+2]);
'<':casos[cuenta]:=(DataSet[condfiltro[i]]<condfiltro[i+2]);
'>':casos[cuenta]:=(DataSet[condfiltro[i]]>condfiltro[i+2]);
'X':casos[cuenta]:=(DataSet[condfiltro[i]]<>condfiltro[i+2]);
'Y':casos[cuenta]:=(DataSet[condfiltro[i]]<=condfiltro[i+2]);
'Z':casos[cuenta]:=(DataSet[condfiltro[i]]>=condfiltro[i+2]);

end;


end;
cuenta:=cuenta+1;
end;
i:=i+4;
end;

for i:=1 to 30 do
begin
casosaux:=casosaux and casos[i];

end;
Accept:=casosaux;

end;




procedure datosdefiltrado(cond:string);
var
i,pos:integer;
aux:String;
begin
{*************borra todoa la basura****}
for i:=1 to 120 do
begin
{campos[i]:='';
operadores[i]:='';
valores[i]:='';}
condfiltro[i]:='';
end;
{****************************}
pos:=1;
for i:=1 to length(cond) do
begin
if cond[i]='*' then
begin
condfiltro[pos]:=aux;
pos:=pos+1;
aux:='';
end
else
aux:=aux+cond[i];
{*****inicia la separacion****}

end;

end;

function filtratablatipo(nombredetabla:TDataSet):integer;
begin
with FormaInventario do
begin
if nombredetabla=TablaInventario then
begin
{TablaInventa.Filtered:=False;}
FormaInventario.TablaInventario.Filtered:=True;
end;

end;
end;




{terminan procedimientos de filtrado***********************}



procedure poneimagen;
begin
with FormaInventario do
begin

if FileExists(TablaInventario.FieldByName('IMAGE_I').AsString) then
begin
Imagen.Picture.LoadFromFile(TablaInventario.FieldByName('IMAGE_I').AsString);
Imagen.Visible:=True;
PanelImagen.Caption:=TablaInventario.FieldByName('IMAGE_I').AsString;
end
else
begin
Imagen.Visible:=False;
PanelImagen.Caption:='Imagen';
end;

end;
end;

procedure activabotones(cambios,nuevo,guardar,buscar,imprimir,navegar:boolean);
begin
with FormaInventario do
begin
BotonCambios.Enabled:=cambios;
Modificar1.Enabled:=cambios;

BotonNuevo.Enabled:=nuevo;
Nuevo1.Enabled:=nuevo;

BotonGuardar.Enabled:=guardar;
Guardar1.Enabled:=guardar;

BotonBuscar.Enabled:=buscar;

BotonImprimir.Enabled:=imprimir;

Navegador.Enabled:=navegar;

end;
end;

{*******************}




{proc  red*******}
procedure borraauxiliar;
begin
with FormaInventario do
begin

Tablaauxiliar.First;
while not TablaAuxiliar.Eof do
begin
TablaAuxiliar.Delete;
end;
DataSource1.DataSet:=TablaInventario;
end;
end;


procedure agregacambios;
var
i:integer;
begin
with FormaInventario do
begin
{ablaauxiliar.Edit;}
TablaAuxiliar.Post;

{for i:=1 to 15 do
begin
TablaCliente.Fields[i].AsString:=TablaAuxiliar.Fields[i].AsString;
end;}

{**************}
{TablaInventario.Edit;}
TablaInventario.FieldByName('CLPRO_I').AsString:=TablaAuxiliar.FieldByName('CLPRO_I').AsString;
TablaInventario.FieldByName('DSCPR_I').AsString:=TablaAuxiliar.FieldByName('DSCPR_I').AsString;
TablaInventario.FieldByName('UMEDI_I').AsString:=TablaAuxiliar.FieldByName('UMEDI_I').AsString;
TablaInventario.FieldByName('LIPRO_I').AsString:=TablaAuxiliar.FieldByName('LIPRO_I').AsString;
TablaInventario.FieldByName('UEMPA_I').AsString:=TablaAuxiliar.FieldByName('UEMPA_I').AsString;
TablaInventario.FieldByName('CLPR1_I').AsString:=TablaAuxiliar.FieldByName('CLPR1_I').AsString;
TablaInventario.FieldByName('CLPR2_I').AsString:=TablaAuxiliar.FieldByName('CLPR2_I').AsString;
TablaInventario.FieldByName('FEULC_I').AsString:=TablaAuxiliar.FieldByName('FEULC_I').AsString;
TablaInventario.FieldByName('FEULV_I').AsString:=TablaAuxiliar.FieldByName('FEULV_I').AsString;
TablaInventario.FieldByName('PTICA_I').AsString:=TablaAuxiliar.FieldByName('PTICA_I').AsString;
TablaInventario.FieldByName('TICOS_I').AsString:=TablaAuxiliar.FieldByName('TICOS_I').AsString;
TablaInventario.FieldByName('PIVA1_I').AsString:=TablaAuxiliar.FieldByName('PIVA1_I').AsString;
TablaInventario.FieldByName('PIVA2_I').AsString:=TablaAuxiliar.FieldByName('PIVA2_I').AsString;
TablaInventario.FieldByName('STMIN_I').AsString:=TablaAuxiliar.FieldByName('STMIN_I').AsString;
TablaInventario.FieldByName('STMAX_I').AsString:=TablaAuxiliar.FieldByName('STMAX_I').AsString;
TablaInventario.FieldByName('EXIST_I').AsString:=TablaAuxiliar.FieldByName('EXIST_I').AsString;

TablaInventario.FieldByName('COMRE_I').AsString:=TablaAuxiliar.FieldByName('COMRE_I').AsString;
TablaInventario.FieldByName('PESUR_I').AsString:=TablaAuxiliar.FieldByName('PESUR_I').AsString;
TablaInventario.FieldByName('ULCOS_I').AsString:=TablaAuxiliar.FieldByName('ULCOS_I').AsString;
TablaInventario.FieldByName('CPROM_I').AsString:=TablaAuxiliar.FieldByName('CPROM_I').AsString;
TablaInventario.FieldByName('PPUBL_I').AsString:=TablaAuxiliar.FieldByName('PPUBL_I').AsString;
TablaInventario.FieldByName('PLIS2_I').AsString:=TablaAuxiliar.FieldByName('PLIS2_I').AsString;
TablaInventario.FieldByName('PLIS3_I').AsString:=TablaAuxiliar.FieldByName('PLIS3_I').AsString;
TablaInventario.FieldByName('PLIS4_I').AsString:=TablaAuxiliar.FieldByName('PLIS4_I').AsString;
TablaInventario.FieldByName('PMINI_I').AsString:=TablaAuxiliar.FieldByName('PMINI_I').AsString;

TablaInventario.FieldByName('VANMO_I').AsString:=TablaAuxiliar.FieldByName('VANMO_I').AsString;
TablaInventario.FieldByName('VANCA_I').AsString:=TablaAuxiliar.FieldByName('VANCA_I').AsString;
TablaInventario.Edit;
{**************}
borraauxiliar;


end;
end;

procedure copiaregistro;
begin

with FormaInventario do
begin
TablaAuxiliar.Close;
Tablaauxiliar.DatabaseName:=leeruta;
Tablaauxiliar.TableName:='InveAux.dbf';
Estructura.Execute;
DataSource1.DataSet:=TablaAuxiliar;
TablaAuxiliar.Open;
TablaAuxiliar.Edit;
end;

{TablaAuxiliar.First;}

end;



{***termina proc de red********}


procedure rangodebarras;
type
claves=record
codigo:string[20];
descripcion:string[60];
end;
var
archco:File of claves;
clav:claves;
begin
With FormaInventario do
begin
AssignFile(archco,leeruta+'\tempo\leecodigo.tmp');
ReWrite(archco);
TablaInventario.First;
While not TablaInventario.Eof do
begin
clav.codigo:=TablaInventario.FieldByname('CLPRO_I').AsString;
clav.descripcion:=TablaInventario.FieldByname('DSCPR_I').AsString;
Write(archco,clav);
TablaInventario.Next;
end;
CloseFile(archco);
end;
end;

procedure generaarchivodebarras;
type
claves=record
codigo:string[20];
descripcion:string[60];
end;
var
archco:File of claves;
clav:claves;
begin
With FormaInventario do
begin
AssignFile(archco,leeruta+'\tempo\leecodigo.tmp');
ReWrite(archco);
clav.codigo:=TablaInventario.FieldByname('CLPRO_I').AsString;
clav.descripcion:=TablaInventario.FieldByname('DSCPR_I').AsString;
Write(archco,clav);
CloseFile(archco);
end;
end;

procedure asignatipo;
type
datos=record
archivo:String[60];
descrip:String[125];
end;
var
dat:datos;
faltan:Boolean;
arch,arch2:file of datos;
i:integer;
begin
with FormaConsulta do
begin
{MuestraMensaje(leeruta+'\report\inventar.for');}
AssignFile(arch,leeruta+'\report\inventar.for');
Reset(arch);
Archivo.Items.Clear;
Descripcion.Clear;
faltan:=True;
for i:=0 to FileSize(arch)-1 do
begin
Read(arch,dat);
if FileExists(Dat.archivo) then
Archivo.Items.Append(Dat.archivo)
else
faltan:=False;
end;
CloseFile(arch);


if faltan=False then
begin
AssignFile(arch,leeruta+'\report\inventar.for');
Reset(arch);
AssignFile(arch2,leeruta+'\report\Cliente2.for');
Rewrite(arch2);

for i:=0 to FileSize(arch)-1 do
begin
Read(arch,dat);
if FileExists(Dat.archivo) then
write(arch2,dat);
end;
CloseFile(arch);
CloseFile(arch2);
{******************}
AssignFile(arch,leeruta+'\report\inventar.for');
Rewrite(arch);
AssignFile(arch2,leeruta+'\report\Cliente2.for');
Reset(arch2);

for i:=0 to FileSize(arch2)-1 do
begin
Read(arch2,dat);
if FileExists(Dat.archivo) then
write(arch,dat);
end;
CloseFile(arch);
CloseFile(arch2);
end;


Archivo.Text:=Archivo.Items[0];
Descripcion.lines.Add(Dat.Descrip);

ReporteDe.Caption:='Reporte de Clientes';
Archi.Caption:='inventar.for';
end;

end;





procedure dibujabarras;
begin
end;

{function ruta(linea:integer):String;
var
arch:TextFile;
aux:string;
i:integer;
begin
AssignFile(arch,leeempresa);
Reset(arch);
for i:=1 to linea do
Readln(arch,aux);
CloseFile(arch);
ruta:=aux;

end;}

procedure rutas;
var
  I: Integer;
begin

with FormaInventario do
begin
  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TTable  then
       begin
       TTable(Components[I]).DatabaseName:=ruta(8);
       try
       TTable(Components[I]).Open;
       except
       MuestraMensaje('Ha Ocurrido un Error al Abrir una de las Bases de Datos.');
       end;
       
       end;
    end;
end;

end;


procedure limpiar;
var
  I: Integer;
begin

with FormaInventario do
begin
  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TDBEdit  then
       TDBEdit(Components[I]).Text :='';
     if Components[I] is TEdit  then
       TEdit(Components[I]).Text :='';

  end;
end;

end;


procedure activa;
var
  I: Integer;
begin
with FormaInventario do
begin
{  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TDBEdit  then
       TDBEdit(Components[I]).Enabled :=True;
     if Components[I] is TEdit  then
       TEdit(Components[I]).Enabled :=True;
     if Components[I] is TLabel then
       TLabel(Components[I]).Enabled :=True;
end;}
Caja.Enabled:=True;
Imagen.Visible:=True;
end;
end;

procedure desactiva;
var
  I: Integer;
begin
with FormaInventario do
begin
{  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TDBEdit then
       TDBEdit(Components[I]).Enabled :=False;
     if Components[I] is TEdit then
       TEdit(Components[I]).Enabled :=False;
     if Components[I] is TLabel then
       TLabel(Components[I]).Enabled :=False;
end;}
Caja.Enabled:=False;

end;
end;


procedure cursor1;
begin
with FormaInventario do
begin

if indice>27 then indice:=1;
if indice<1 then indice:=1;

case indice of
   1: EditCLPRO_I.SetFocus;
   2: EditDSCPR_I.SetFocus;
   3: EditUMEDI_I.SetFocus;
   4: EditLIPRO_I.SetFocus;
   5: EditUEMPA_I.SetFocus;
   6: EditCLPR_I.SetFocus;
   7: EditCLPR_I2.SetFocus;
   8: EditFEULC_I.SetFocus;
   9: EditFEULV_I.SetFocus;
   10: EditPTICA_I.SetFocus;
   11: EditTICOS_I.SetFocus;
   12: EditPIVA_I.SetFocus;
   13: EditPIVA_I2.SetFocus;
   14: EditSTMIN_I.SetFocus;
   15: EditSTMAX_I.SetFocus;
   16: EditEXIST_I.SetFocus;
   17: EditCOMRE_I.SetFocus;
   18: EditPESUR_I.SetFocus;
   19: EditULCOS_I.SetFocus;
   20: EditCPROM_I.SetFocus;
   21: EditPPUBL_I.SetFocus;
   22: EditPLIS_I.SetFocus;
   23: EditPLIS_I2.SetFocus;
   24: EditPLIS_I3.SetFocus;
   25: EditPMINI_I.SetFocus;
   26: EditVANMO_I.SetFocus;
   27: EditVANCA_I.SetFocus;
end;

end;
end;

{xxx*************}
procedure posicionainventario(clave:string);
begin
with Formainventario do
begin
if FormaInventario.Tag=0 then
begin
rutas;
desactiva;
limpiar;
TablaInventario.Open;
EditCLPRO_I.Text:=TablaInventario.FieldByName('CLPRO_I').AsString;
BotonGuardar.Enabled:=False;
indice:=1;
BotonCambios.Tag:=0;
TablaInventario.Edit;
TablaInventario.UpdateRecord;
TablaInventario.Post;
end;
FormaInventario.Tag:=1;
TablaInventario.FindKey([clave]);
end;
end;
{**********************}

procedure TFormaInventario.FormCreate(Sender: TObject);
begin
  {rutas;
  TablaInventario.Open;
  TablaInventario2.Open;}

  nombreformato:=leeruta+'\consulta\'+ruta(23+1);
  FormatosPais;
end;

procedure TFormaInventario.BotonGuardarClick(Sender: TObject);
begin
TablaInventario2.First;
if BotonCambios.Tag<>1 then
if TablaInventario2.FindKey([EditCLPRO_I.Text]) then
begin
MuestraMensaje('La Clave del Producto ya Existe No Es Posible Darlo de Alta');
EditCLPRO_I.SetFocus;
end
else
begin
TablaInventario.Edit;
TablaInventario.FieldByName('CLPRO_I').AsString:= EditCLPRO_I.Text;
TablaInventario.FieldByName('IMAGE_I').AsString:=PanelImagen.Caption;

if Series.Checked then TablaInventario.FieldByName('SERIE_I').AsString:='S'
else
TablaInventario.FieldByName('SERIE_I').AsString:='N';

if Kit.Checked then TablaInventario.FieldByName('KITXX_I').AsString:='S'
else
TablaInventario.FieldByName('KITXX_I').AsString:='N';

if BotonCambios.Tag=1 then
begin
agregacambios;

end;
{TablaInventario.Edit;}
TablaInventario.Post;
desactiva;
activabotones(True,True,False,True,True,True);
BotonCambios.Tag:=0;
BotonNuevo.Tag:=0;
end
else
begin
TablaInventario.Edit;
TablaInventario.FieldByName('CLPRO_I').AsString:= EditCLPRO_I.Text;
TablaInventario.FieldByName('IMAGE_I').AsString:=PanelImagen.Caption;

if Series.Checked then TablaInventario.FieldByName('SERIE_I').AsString:='S'
else
TablaInventario.FieldByName('SERIE_I').AsString:='N';

if Kit.Checked then TablaInventario.FieldByName('KITXX_I').AsString:='S'
else
TablaInventario.FieldByName('KITXX_I').AsString:='N';

if BotonCambios.Tag=1 then
begin
agregacambios;
{borraauxiliar;}
end;
{TablaInventario.Edit;}
TablaInventario.Post;
desactiva;
activabotones(True,True,False,True,True,True);
BotonCambios.Tag:=0;
BotonNuevo.Tag:=0;
end;
poneimagen;
BotonCambios.Tag:=0;
BotonNuevo.Tag:=0;

end;

procedure TFormaInventario.BotonSalirClick(Sender: TObject);
begin
Close;

end;

procedure TFormaInventario.BotonNuevoClick(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),32) then
begin
activa;
TablaInventario.Insert;
TablaInventario.Post;
TablaInventario.Edit;
EditCLPRO_I.SetFocus;
EditCLPRO_I.Clear;
activabotones(False,False,True,False,False,False);
BotonCambios.Tag:=0;
Botonnuevo.Tag:=1;
TamanoCaracteres.Caption:='Caracteres '+IntToStr(Length(EditCLPRO_I.Text));
poneimagen;
end;
end;

procedure TFormaInventario.EditTICOS_IKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if Ord(Char(Key))=113 then
FormaTipoInventario.ShowModal;
if (Ord(Char(Key))=13) or (Ord(Char(Key))=40) then
begin
indice:=indice+1;
cursor1;
end;
if Ord(Char(Key))=38 then
begin
indice:=indice-1;
cursor1;
end;


end;

procedure TFormaInventario.NavegadorClick(Sender: TObject;
  Button: TNavigateBtn);
begin
EditCLPRO_I.Text:=TablaInventario.FieldByName('CLPRO_I').AsString;

if TablaInventario.FieldByName('SERIE_I').AsString='S' then Series.Checked:=True
else
Series.Checked:=False;

if TablaInventario.FieldByName('KITXX_I').AsString='S' then Kit.Checked:=True
else
Kit.Checked:=False;

TamanoCaracteres.Caption:='Caracteres '+IntToStr(Length(EditCLPRO_I.Text));
poneimagen;
{BotonNuevo.Enabled:=True;
BotonGuardar.Enabled:=True;
BotonCambios.Enabled:=True;}
end;

procedure TFormaInventario.FormActivate(Sender: TObject);
begin

if FormaInventario.Tag=0 then
begin
rutas;
desactiva;
limpiar;
TablaInventario.Open;
EditCLPRO_I.Text:=TablaInventario.FieldByName('CLPRO_I').AsString;
BotonGuardar.Enabled:=False;
indice:=1;
BotonCambios.Tag:=0;
TablaInventario.Edit;
TablaInventario.UpdateRecord;
TablaInventario.Post;
PanelImagen.Caption:=EditCLPRO_I.Text;

if FileExists(TablaInventario.FieldByName('IMAGE_I').AsString) then
begin
Imagen.Picture.LoadFromFile(TablaInventario.FieldByName('IMAGE_I').AsString);
Imagen.Visible:=True;
PanelImagen.Caption:=TablaInventario.FieldByName('IMAGE_I').AsString;
end

{abreimagen(PanelImagen.Caption);}
end;
FormaInventario.Tag:=1;
end;

procedure TFormaInventario.Consultas1Click(Sender: TObject);
begin
FormaConsulta.TablaConsulta.DataBaseName:=ruta(8);
FormaConsulta.TablaConsulta.IndexName:='ICLPRO';
FormaConsulta.TablaConsulta.TableName:='INVENTAR.dbf';

FormaConsulta.TablaConsulta.Open;
FormaConsulta.TablaConsulta.First;
FormaConsulta.De.Text:=FormaConsulta.TablaConsulta.Fields[0].AsString;
FormaConsulta.TablaConsulta.Last;
FormaConsulta.Hasta.Text:=FormaConsulta.TablaConsulta.Fields[0].AsString;
FormaConsulta.TablaConsulta.First;

FormaConsulta.RutaCampos.Text:=leeruta+'\consulta\INVENTAR.CMP';
FormaConsulta.TipoVista.Text:=leeruta+'\consulta\INVENTAR.VIS';
FormaConsulta.Destino.Text:=leeruta+'\tempo\repinv.rep';
FormaConsulta.NumCampo.Caption:='0';
asignatipo;
leearchivocampos(228,248);
FormaConsulta.ShowModal;

end;

procedure TFormaInventario.BotonCambiosClick(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),34) then
begin
activa;
if (TablaInventario.State=dsEdit) or (TablaInventario.State=dsInsert) then
TablaInventario.Post;
{TablaInventario.Edit;}
copiaregistro;
activabotones(False,False,True,False,False,False);
BotonCambios.Tag:=1;
Botonnuevo.Tag:=0;

end;
end;

procedure TFormaInventario.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
{TablaInventario.Close;}
if (BotonCambios.Tag=1)or (BotonNuevo.Tag=1) then
begin
FormaCerrar.ShowModal;
if FormaCerrar.Tag=1 then
begin
if BotonCambios.Tag=1 then
agregacambios;
TablaInventario.Post;
activabotones(True,True,False,True,True,True);
BotonCambios.Tag:=0;
BotonNuevo.Tag:=0;
end;

if FormaCerrar.Tag=2 then
begin
{TablaInventario.Cancel;}
if BotonCambios.Tag=1 then
borraauxiliar
else
TablaInventario.Delete;
activabotones(True,True,False,True,True,True);
BotonCambios.Tag:=0;
BotonNuevo.Tag:=0;
end;

if FormaCerrar.Tag=3 then
Action:=caNone;
FormaCerrar.Tag:=0;

end;
BotonSalir.Tag:=1000;
end;


procedure TFormaInventario.Eliminar1Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),33) then
begin
TablaInventario.Delete;
end;
end;

procedure TFormaInventario.BotonBuscarClick(Sender: TObject);
begin
activa;
FormaBusqueda.ShowModal;

if FormaBusqueda.Clave.Checked then
begin
TablaInventario.IndexName:='ICLPRO';
{TablaInventario.FindNearest([FormaBusqueda.CajaBuscar.Text]);}
end
else
begin
TablaInventario.IndexName:='DSCPR_I';
{TablaInventario.FindNearest([FormaBusqueda.CajaBuscar.Text]);}
end;
TablaInventario.FindNearest([FormaBusqueda.CajaBuscar.Text]);
EditCLPRO_I.Text:=TablaInventario.FieldByName('CLPRO_I').AsString;
poneimagen;
end;

procedure TFormaInventario.EditCLPRO_IKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if (Ord(Char(Key))=13) or (Ord(Char(Key))=40) then
begin
indice:=indice+1;
cursor1;
end;
if Ord(Char(Key))=38 then
begin
indice:=indice-1;
cursor1;
end;

if key=113 then
begin
EditCLPRO_I.Text:=leeproveedor(EditCLPRO_I.Text);
end;
end;

procedure TFormaInventario.AreaGraficaPaint(Sender: TObject);
begin
dibujabarras;
end;

procedure TFormaInventario.FolderChange(Sender: TObject; NewTab: Integer;
  var AllowChange: Boolean);
begin
dibujabarras;
end;

procedure TFormaInventario.BotonImprimirClick(Sender: TObject);
begin
if ImpresoraLista then
begin
forma(TablaInventario,TablaInventario,leeruta+'\consulta\inventa.fmt','i');
end
else
MuestraMensaje('La Impresora No Se Encuentra Lista...');
end;

procedure TFormaInventario.EditCLPRO_IEnter(Sender: TObject);
begin
indice:=1;
Uno.Caption:=comenta(1,'inventa.des');
Dos.Caption:=comenta(2,'inventa.des');
end;

procedure TFormaInventario.EditDSCPR_IEnter(Sender: TObject);
begin
indice:=2;
Uno.Caption:=comenta(3,'inventa.des');
Dos.Caption:=comenta(4,'inventa.des');
end;

procedure TFormaInventario.EditUMEDI_IEnter(Sender: TObject);
begin
indice:=3;
Uno.Caption:=comenta(5,'inventa.des');
Dos.Caption:=comenta(6,'inventa.des');
end;


procedure TFormaInventario.EditLIPRO_IEnter(Sender: TObject);
begin
indice:=4;
Uno.Caption:=comenta(9,'inventa.des');
Dos.Caption:=comenta(10,'inventa.des');
end;

procedure TFormaInventario.EditUEMPA_IEnter(Sender: TObject);
begin
indice:=5;
Uno.Caption:=comenta(7,'inventa.des');
Dos.Caption:=comenta(8,'inventa.des');
end;

procedure TFormaInventario.EditCLPR_IEnter(Sender: TObject);
begin
indice:=6;
Uno.Caption:=comenta(11,'inventa.des');
Dos.Caption:=comenta(12,'inventa.des');
end;

procedure TFormaInventario.EditCLPR_I2Enter(Sender: TObject);
begin
indice:=7;
end;

procedure TFormaInventario.EditFEULC_IEnter(Sender: TObject);
begin
indice:=8;
Uno.Caption:=comenta(13,'inventa.des');
Dos.Caption:=comenta(14,'inventa.des');
end;

procedure TFormaInventario.EditFEULV_IEnter(Sender: TObject);
begin
indice:=9;
Uno.Caption:=comenta(15,'inventa.des');
Dos.Caption:=comenta(16,'inventa.des');
end;

procedure TFormaInventario.EditPTICA_IEnter(Sender: TObject);
begin
indice:=10;
Uno.Caption:=comenta(17,'inventa.des');
Dos.Caption:=comenta(18,'inventa.des');
end;

procedure TFormaInventario.EditTICOS_IEnter(Sender: TObject);
begin
indice:=11;
Uno.Caption:=comenta(19,'inventa.des');
Dos.Caption:=comenta(20,'inventa.des');
end;

procedure TFormaInventario.EditPIVA_IEnter(Sender: TObject);
begin
indice:=12;
Uno.Caption:=comenta(21,'inventa.des');
Dos.Caption:=comenta(22,'inventa.des');
end;

procedure TFormaInventario.EditPIVA_I2Enter(Sender: TObject);
begin
indice:=13;
Uno.Caption:=comenta(23,'inventa.des');
Dos.Caption:=comenta(24,'inventa.des')
end;

procedure TFormaInventario.EditSTMIN_IEnter(Sender: TObject);
begin
indice:=14;
Uno.Caption:=comenta(25,'inventa.des');
Dos.Caption:=comenta(26,'inventa.des');
end;

procedure TFormaInventario.EditSTMAX_IEnter(Sender: TObject);
begin
indice:=15;
Uno.Caption:=comenta(27,'inventa.des');
Dos.Caption:=comenta(28,'inventa.des');
end;

procedure TFormaInventario.EditEXIST_IEnter(Sender: TObject);
begin
indice:=16;
Uno.Caption:=comenta(29,'inventa.des');
Dos.Caption:=comenta(30,'inventa.des');
end;

procedure TFormaInventario.EditCOMRE_IEnter(Sender: TObject);
begin
indice:=17;
Uno.Caption:=comenta(31,'inventa.des');
Dos.Caption:=comenta(32,'inventa.des');
end;


procedure TFormaInventario.EditPESUR_IEnter(Sender: TObject);
begin
indice:=18;
Uno.Caption:=comenta(33,'inventa.des');
Dos.Caption:=comenta(34,'inventa.des');
end;

procedure TFormaInventario.EditULCOS_IEnter(Sender: TObject);
begin
indice:=19;
Uno.Caption:=comenta(35,'inventa.des');
Dos.Caption:=comenta(36,'inventa.des');
end;

procedure TFormaInventario.EditCPROM_IEnter(Sender: TObject);
begin
indice:=20;
Uno.Caption:=comenta(37,'inventa.des');
Dos.Caption:=comenta(38,'inventa.des');
end;

procedure TFormaInventario.EditPPUBL_IEnter(Sender: TObject);
begin
indice:=21;
Uno.Caption:=comenta(39,'inventa.des');
Dos.Caption:=comenta(40,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_IEnter(Sender: TObject);
begin
indice:=22;
Uno.Caption:=comenta(41,'inventa.des');
Dos.Caption:=comenta(42,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_I2Enter(Sender: TObject);
begin
indice:=23;
Uno.Caption:=comenta(43,'inventa.des');
Dos.Caption:=comenta(44,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_I3Enter(Sender: TObject);
begin
indice:=24;
Uno.Caption:=comenta(45,'inventa.des');
Dos.Caption:=comenta(46,'inventa.des');
end;

procedure TFormaInventario.EditPMINI_IEnter(Sender: TObject);
begin
indice:=25;
Uno.Caption:=comenta(47,'inventa.des');
Dos.Caption:=comenta(48,'inventa.des');
end;

procedure TFormaInventario.EditVANMO_IEnter(Sender: TObject);
begin
indice:=26;
Uno.Caption:=comenta(49,'inventa.des');
Dos.Caption:=comenta(50,'inventa.des');
end;

procedure TFormaInventario.EditVANCA_IEnter(Sender: TObject);
begin
indice:=27;
Uno.Caption:=comenta(51,'inventa.des');
Dos.Caption:=comenta(52,'inventa.des');
end;

procedure TFormaInventario.EditCLPRO_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(1,'inventa.des');
Dos.Caption:=comenta(2,'inventa.des');

end;

procedure TFormaInventario.EditDSCPR_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(3,'inventa.des');
Dos.Caption:=comenta(4,'inventa.des');
end;

procedure TFormaInventario.EditUMEDI_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(5,'inventa.des');
Dos.Caption:=comenta(6,'inventa.des');
end;

procedure TFormaInventario.EditLIPRO_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(9,'inventa.des');
Dos.Caption:=comenta(10,'inventa.des');
end;

procedure TFormaInventario.EditUEMPA_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(7,'inventa.des');
Dos.Caption:=comenta(8,'inventa.des');
end;

procedure TFormaInventario.EditCLPR_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(11,'inventa.des');
Dos.Caption:=comenta(12,'inventa.des');
end;

procedure TFormaInventario.EditFEULC_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(13,'inventa.des');
Dos.Caption:=comenta(14,'inventa.des');
end;

procedure TFormaInventario.EditFEULV_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(15,'inventa.des');
Dos.Caption:=comenta(16,'inventa.des');
end;

procedure TFormaInventario.EditPTICA_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(17,'inventa.des');
Dos.Caption:=comenta(18,'inventa.des');
end;

procedure TFormaInventario.EditTICOS_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(19,'inventa.des');
Dos.Caption:=comenta(20,'inventa.des');
end;

procedure TFormaInventario.EditPIVA_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(21,'inventa.des');
Dos.Caption:=comenta(22,'inventa.des');
end;

procedure TFormaInventario.EditPIVA_I2MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(23,'inventa.des');
Dos.Caption:=comenta(24,'inventa.des');
end;

procedure TFormaInventario.EditSTMIN_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(25,'inventa.des');
Dos.Caption:=comenta(26,'inventa.des');
end;

procedure TFormaInventario.EditSTMAX_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(27,'inventa.des');
Dos.Caption:=comenta(28,'inventa.des');
end;

procedure TFormaInventario.EditEXIST_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(29,'inventa.des');
Dos.Caption:=comenta(30,'inventa.des');
end;

procedure TFormaInventario.EditCOMRE_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(31,'inventa.des');
Dos.Caption:=comenta(32,'inventa.des');
end;

procedure TFormaInventario.EditPESUR_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(33,'inventa.des');
Dos.Caption:=comenta(34,'inventa.des');
end;

procedure TFormaInventario.EditULCOS_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(35,'inventa.des');
Dos.Caption:=comenta(36,'inventa.des');
end;

procedure TFormaInventario.EditCPROM_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(37,'inventa.des');
Dos.Caption:=comenta(38,'inventa.des');
end;

procedure TFormaInventario.EditPPUBL_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(39,'inventa.des');
Dos.Caption:=comenta(40,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(41,'inventa.des');
Dos.Caption:=comenta(42,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_I2MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(43,'inventa.des');
Dos.Caption:=comenta(44,'inventa.des');
end;

procedure TFormaInventario.EditPLIS_I3MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(45,'inventa.des');
Dos.Caption:=comenta(46,'inventa.des');
end;

procedure TFormaInventario.EditPMINI_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(47,'inventa.des');
Dos.Caption:=comenta(48,'inventa.des');
end;

procedure TFormaInventario.EditVANMO_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(49,'inventa.des');
Dos.Caption:=comenta(50,'inventa.des');
end;

procedure TFormaInventario.EditVANCA_IMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
Uno.Caption:=comenta(51,'inventa.des');
Dos.Caption:=comenta(52,'inventa.des');
end;

procedure TFormaInventario.Stocks1Click(Sender: TObject);
var
desde,hastavalor:string;

begin
FormaFormatos.Rangos.Visible:=True;
FormaFormatos.Formatos.Visible:=False;
activacondiciones(true,true,False,False,False,true,true,true,true,'inventar.cmp');
TablaInventario.First;
desde:=TablaInventario.FieldByName('CLPRO_I').AsString;
Tablainventario.Last;
hastavalor:=TablaInventario.FieldByName('CLPRO_I').AsString;
valoresiniciales('','',desde,hastavalor);

FormaFormatos.ShowModal;
if FormaFormatos.Tag=1 then
begin
condiciones(FormaFormatos.C1.Caption,tipooperador(FormaFormatos.Operador1.Text),FormaFormatos.Valor1.Text,FormaFormatos.T1.Caption,FormaFormatos.C2.Caption,tipooperador(FormaFormatos.Operador2.Text),FormaFormatos.Valor2.Text,FormaFormatos.T2.Caption,FormaFormatos.C3.Caption,tipooperador(FormaFormatos.Operador3.Text),FormaFormatos.Valor3.Text,FormaFormatos.T3.Caption);
Concentrar(TablaInventario,Formaformatos.De.Text,FormaFormatos.Hasta.Text,'f','f','f','CLPRO_I','DSCPR_I','STMIN_I','STMAX_I','','','','','','','','X','','D');
poneetiquetas('Clave','Artículo','-Stock Mínimo','-Stock Máximo','','','','','','','');
Poneanchos(20,20,20,20,20,20,20,20,20,20,0);
FormaBarras.Tag:=0;
FormaBarras.Panel2.Tag:=0;
FormaBarras.botonGrafica.Tag:=2;
FormaBarras.Concentrado.Clear;
FormaBarras.Caption:='Reporte de Stocks de Productos';
FormaBarras.ShowModal;
FormaBarras.Tag:=0;
end;

FormaFormatos.Tag:=1;

end;

procedure TFormaInventario.VtasyCprasAnuales1Click(Sender: TObject);
var
desde,hastavalor:string;

begin
FormaFormatos.Rangos.Visible:=True;
FormaFormatos.Formatos.Visible:=False;
activacondiciones(true,true,False,False,False,true,true,true,true,'inventar.cmp');
TablaInventario.First;
desde:=TablaInventario.FieldByName('CLPRO_I').AsString;
Tablainventario.Last;
hastavalor:=TablaInventario.FieldByName('CLPRO_I').AsString;
valoresiniciales('','',desde,hastavalor);

FormaFormatos.ShowModal;
if FormaFormatos.Tag=1 then
begin
condiciones(FormaFormatos.C1.Caption,tipooperador(FormaFormatos.Operador1.Text),FormaFormatos.Valor1.Text,FormaFormatos.T1.Caption,FormaFormatos.C2.Caption,tipooperador(FormaFormatos.Operador2.Text),FormaFormatos.Valor2.Text,FormaFormatos.T2.Caption,FormaFormatos.C3.Caption,tipooperador(FormaFormatos.Operador3.Text),FormaFormatos.Valor3.Text,FormaFormatos.T3.Caption);
Concentrar(TablaInventario,FormaFormatos.De.Text,FormaFormatos.Hasta.Text,'f','f','f','CLPRO_I','DSCPR_I','VANMO_I','COMRE_I','','','','','','','','X','','D');
poneetiquetas('Clave','Artículo','Ventas Anuales','Compras Anuales','','','','','','','');
Poneanchos(20,20,20,20,20,20,20,20,20,20,0);
FormaBarras.Tag:=0;
FormaBarras.Panel2.Tag:=0;
FormaBarras.botonGrafica.Tag:=2;

FormaBarras.Concentrado.Clear;
FormaBarras.Caption:='Reporte de Ventas y Compras Anuales de Productos';
FormaBarras.ShowModal;
FormaBarras.Tag:=0;
end;
FormaFormatos.Tag:=0;

end;

procedure TFormaInventario.Existencias2Click(Sender: TObject);
var
desde,hastavalor:string;

begin
FormaFormatos.Rangos.Visible:=True;
FormaFormatos.Formatos.Visible:=False;
activacondiciones(true,true,False,False,False,true,true,true,true,'inventar.cmp');
TablaInventario.First;
desde:=TablaInventario.FieldByName('CLPRO_I').AsString;
Tablainventario.Last;
hastavalor:=TablaInventario.FieldByName('CLPRO_I').AsString;
valoresiniciales('','',desde,hastavalor);

FormaFormatos.ShowModal;
if FormaFormatos.Tag=1 then
begin
condiciones(FormaFormatos.C1.Caption,tipooperador(FormaFormatos.Operador1.Text),FormaFormatos.Valor1.Text,FormaFormatos.T1.Caption,FormaFormatos.C2.Caption,tipooperador(FormaFormatos.Operador2.Text),FormaFormatos.Valor2.Text,FormaFormatos.T2.Caption,FormaFormatos.C3.Caption,tipooperador(FormaFormatos.Operador3.Text),FormaFormatos.Valor3.Text,FormaFormatos.T3.Caption);
Concentrar(TablaInventario,Formaformatos.De.Text,FormaFormatos.Hasta.Text,'f','f','f','CLPRO_I','DSCPR_I','EXIST_I','','','','','','','','','X','','D');
poneetiquetas('Clave','Artículo','-Existencias','','','','','','','','');
Poneanchos(20,20,20,20,20,20,20,20,20,20,0);
FormaBarras.Tag:=0;
FormaBarras.Panel2.Tag:=0;
FormaBarras.botonGrafica.Tag:=2;
FormaBarras.Concentrado.Clear;
FormaBarras.Caption:='Reporte de Existencias de Productos';
FormaBarras.ShowModal;
FormaBarras.Tag:=0;
end;
FormaFormatos.Tag:=0;

end;

procedure TFormaInventario.CostoyCostoPromedio1Click(Sender: TObject);
var
desde,hastavalor:string;

begin
FormaFormatos.Rangos.Visible:=True;
FormaFormatos.Formatos.Visible:=False;
activacondiciones(true,true,False,False,False,true,true,true,true,'inventar.cmp');
TablaInventario.First;
desde:=TablaInventario.FieldByName('CLPRO_I').AsString;
Tablainventario.Last;
hastavalor:=TablaInventario.FieldByName('CLPRO_I').AsString;
valoresiniciales('','',desde,hastavalor);
FormaFormatos.ShowModal;

if FormaFormatos.Tag=1 then
begin
condiciones(FormaFormatos.C1.Caption,tipooperador(FormaFormatos.Operador1.Text),FormaFormatos.Valor1.Text,FormaFormatos.T1.Caption,FormaFormatos.C2.Caption,tipooperador(FormaFormatos.Operador2.Text),FormaFormatos.Valor2.Text,FormaFormatos.T2.Caption,FormaFormatos.C3.Caption,tipooperador(FormaFormatos.Operador3.Text),FormaFormatos.Valor3.Text,FormaFormatos.T3.Caption);
Concentrar(TablaInventario,Formaformatos.De.Text,FormaFormatos.Hasta.Text,'f','f','f','CLPRO_I','DSCPR_I','ULCOS_I','CPROM_I','','','','','','','','X','','D');
poneetiquetas('Clave','Artículo','Costo','Costo Promedio','','','','','','','');
Poneanchos(20,20,20,20,20,20,20,20,20,20,0);
FormaBarras.Tag:=0;
FormaBarras.Panel2.Tag:=0;
FormaBarras.botonGrafica.Tag:=2;
FormaBarras.Concentrado.Clear;
FormaBarras.Caption:='Reporte de Costo y Costo Promedio de Productos';
FormaBarras.ShowModal;
FormaBarras.Tag:=0;
end;
FormaFormatos.Tag:=0;

end;




procedure TFormaInventario.ImprimeCdigo1Click(Sender: TObject);
begin
generaarchivodebarras;
WinExec('c:\BARRAS\BARRAS.exe',SW_SHOWNORMAL);

end;

procedure TFormaInventario.ImprimeelRangodeCdigos1Click(Sender: TObject);
begin
{rangodebarras;
WinExec('c:\BARRAS\BARRAS.exe',SW_SHOWNORMAL);}

{FormaCodigoBarras.ShowModal;}

end;




















procedure TFormaInventario.TablaInventarioEditError(DataSet: TDataSet;
  E: EDatabaseError; var Action: TDataAction);
begin
DatabaseError('No se Pueden Editar los Datos ha Ocurrido un Error');
end;

procedure TFormaInventario.TablaInventarioPostError(DataSet: TDataSet;
  E: EDatabaseError; var Action: TDataAction);
begin
DatabaseError('No se Pueden Guardar los Datos ha Ocurrido un Error');
end;


procedure TFormaInventario.BotonCambiosMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaInventario.Left+BotonCambios.Left,FormaInventario.Top+BotonCambios.Top+BotonCambios.Height,32);
end;

procedure TFormaInventario.BotonNuevoMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaInventario.Left+BotonNuevo.Left,FormaInventario.Top+BotonNuevo.Top+Botonnuevo.Height,33);
end;

procedure TFormaInventario.BotonGuardarMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaInventario.Left+BotonGuardar.Left,FormaInventario.Top+BotonGuardar.Top+BotonGuardar.Height,34);
end;

procedure TFormaInventario.BotonBuscarMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaInventario.Left+BotonBuscar.Left,FormaInventario.Top+BotonBuscar.Top+BotonBuscar.Height,35);
end;

procedure TFormaInventario.BotonImprimirMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaInventario.Left+BotonImprimir.Left,FormaInventario.Top+BotonImprimir.Top+BotonImprimir.Height,36);
end;

procedure TFormaInventario.EditCLPR_I2KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if (Ord(Char(Key))=13) or (Ord(Char(Key))=40) then
begin
indice:=indice+1;
cursor1;
end;
if Ord(Char(Key))=38 then
begin
indice:=indice-1;
cursor1;
end;

if key=113 then
begin
EditCLPR_I2.Text:=leeproveedor(EditCLPR_I2.Text);
end;

end;

procedure TFormaInventario.EditCLPR_IKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if (Ord(Char(Key))=13) or (Ord(Char(Key))=40) then
begin
indice:=indice+1;
cursor1;
end;
if Ord(Char(Key))=38 then
begin
indice:=indice-1;
cursor1;
end;

if key=113 then
begin
EditCLPR_I.Text:=leeproveedor(EditCLPRO_I.Text);
end;

end;

{****ampliar imagen***}
procedure ampliaimagen;
begin
with FormaInventario do
begin

end;
end;

procedure TFormaInventario.ImagenDblClick(Sender: TObject);
begin

if ((BotonNuevo.Tag=1)or(BotonCambios.Tag=1)) then
begin
if AbreArchivo.Execute then
begin
if (FileExists(AbreArchivo.FileName)) then
begin
Imagen.Picture.LoadFromFile(AbreArchivo.FileName);
PanelImagen.Caption:=AbreArchivo.FileName;
end
else
PanelImagen.Caption:='Imagen';
end;
end
else
abreimagen(PanelImagen.Caption);


end;


procedure TFormaInventario.PanelImagenDblClick(Sender: TObject);
begin
abreimagen(PanelImagen.Caption);
end;


procedure TFormaInventario.ImprimePlantilla1Click(Sender: TObject);
begin
FormaInventario.Print;
end;

procedure TFormaInventario.EditCLPRO_IKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
TamanoCaracteres.Caption:='Caracteres '+IntToStr(Length(EditCLPRO_I.Text));
end;

procedure TFormaInventario.Temas1Click(Sender: TObject);
begin
PoneAyuda(leeruta+'\ayuda\inventar.rtf',0);
end;


procedure TFormaInventario.BotonPreliminarClick(Sender: TObject);
begin
if FileExists(nombreformato) then
begin
forma(TablaInventario,TablaInventario,nombreformato,'p');
end
else
MuestraMensaje('El Formato '+nombreformato+'No Existe');
FormaEdicion.Hoja.Tag:=0;
FormaAnteriorEdicion.ShowModal;

end;

procedure TFormaInventario.ActualizaPrecios1Click(Sender: TObject);
var i:integer;
begin

for i:=1 to 120 do
begin
condfiltro[i]:='';
end;
ponecampos('inventar.cmp');

{ponecampos(tipodetabla(DataSource1.DataSet));}
FormaPreciosInventario.Tag:=0;
FormaPreciosInventario.ShowModal;
FormaInventario.Refresh;

if FormaPreciosInventario.Tag=1 then
begin
{datosdefiltrado(condiciones1);
filtratablatipo(TablaInventario);
TablaInventario.Filtered:=True;
EjecutaFiltrado;
TablaInventario.Filtered:=False;}

end;
{FormaPreciosInventario.Close;}


{FormaPreciosInventario.ShowModal;}
end;

procedure TFormaInventario.TablaInventarioFilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
FiltraPorTabla(TablaInventario,Accept);
end;

procedure TFormaInventario.NmerosdeSerie1Click(Sender: TObject);
begin
{FormaSeries.ShowModal;}
if Series.Checked then
AbreNumerosSerie(EditCLPRO_I.Text)
else
MuestraMensaje('El Producto No Tiene Numeros de Serie');

end;

end.
