unit catfor;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  StdCtrls,checa, ExtCtrls;

type
  TFormaCampos = class(TForm)
    Label1: TLabel;
    Bases: TComboBox;
    Label2: TLabel;
    Campos: TListBox;
    Panel1: TPanel;
    Bevel3: TBevel;
    Bevel4: TBevel;
    Bevel5: TBevel;
    Panel2: TPanel;
    Shape1: TShape;
    Label3: TLabel;
    Label4: TLabel;
    procedure BasesChange(Sender: TObject);
    procedure CamposDblClick(Sender: TObject);
    procedure Panel2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Label4MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormaCampos: TFormaCampos;

implementation

{$R *.DFM}




uses edicion;

function leerangocampos(inicio,fin:integer):boolean;
var
i,conta:integer;
nume:String[5];
begin
conta:=0;
for i:=inicio to fin do
begin
nume:='';

if conta<10 then
nume:='[00'+IntToStr(conta)+']'
else
nume:='[0'+IntToStr(conta)+']';
FormaCampos.Campos.Items.Add(nume+'  '+leecampos(i,2));
conta:=conta+1;
end;
end;


function existe(archivo:string):Boolean;
begin
if FileExists(archivo) then
existe:=True
else
existe:=False;

end;

procedure TFormaCampos.BasesChange(Sender: TObject);
begin

Campos.Items.Clear;

if Bases.Text='Clientes' then
leerangocampos(1,18);

{if existe(leeruta+'\define\Clientes.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Clientes.cam');}
if Bases.Text='Compras' then
leerangocampos(135,151);
{if existe(leeruta+'\define\Compras.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Compras.cam');}

if Bases.Text='Ctas. Cobrar' then
leerangocampos(268,280);
{if existe(leeruta+'\define\CtasXC.cam')then Campos.Items.LoadFromFile(leeruta+'\define\CtasXC.cam');}

if Bases.Text='Ctas. Pagar' then
leerangocampos(295,306);
{if existe(leeruta+'\define\CtasXP.cam')then Campos.Items.LoadFromFile(leeruta+'\define\CtasXP.cam');}

if Bases.Text='Facturas' then
leerangocampos(74,101);
{leerangocampos(116,123);}

{if existe(leeruta+'\define\Factu.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Factu.cam');}
if Bases.Text='Inventarios' then
leerangocampos(228,255);
{if existe(leeruta+'\define\Inventa.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Inventa.cam');}
if Bases.Text='Mov. Inventario' then
leerangocampos(185,196);
{if existe(leeruta+'\define\MovInv.cam')then Campos.Items.LoadFromFile(leeruta+'\define\MovInv.cam');}
if Bases.Text='Vendedores' then
leerangocampos(31,34);
{if existe(leeruta+'\define\Vende.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Vende.cam');}
if Bases.Text='Proveedores' then
leerangocampos(47,61);
{if existe(leeruta+'\define\Provee.cam')then Campos.Items.LoadFromFile(leeruta+'\define\Provee.cam');}

end;

procedure TFormaCampos.CamposDblClick(Sender: TObject);
var
trunca:string[5];
begin

trunca:=Campos.Items[Campos.ItemIndex];
if StrToInt(FormaEdicion.lineas.Caption)-1>=0 then
FormaEdicion.Codigo.Lines[StrToInt(FormaEdicion.lineas.Caption)-1]:=FormaEdicion.Codigo.Lines[StrToInt(FormaEdicion.lineas.Caption)-1]+trunca;
end;


procedure TFormaCampos.Panel2Click(Sender: TObject);
begin
Close;
end;

procedure TFormaCampos.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=27 then Close;
end;

procedure TFormaCampos.Panel1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(FormaCampos.Handle, WM_SYSCOMMAND, $F012, 0);
end;

procedure TFormaCampos.Label4MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(FormaCampos.Handle, WM_SYSCOMMAND, $F012, 0);
end;

end.
