unit ConMovinv;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  StdCtrls, Forms, DBCtrls, DB, DBGrids,
  DBTables, Grids, ExtCtrls,checa,Apertura;

type
  TFormaConMovimiento = class(TForm)
    DBGrid1: TDBGrid;
    DBNavigator: TDBNavigator;
    Panel1: TPanel;
    DataSource1: TDataSource;
    Panel2: TPanel;
    TablaConMovinv: TTable;
    Shape1: TShape;
    Panel3: TPanel;
    Bevel20: TBevel;
    Bevel21: TBevel;
    Bevel22: TBevel;
    Panel4: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    procedure DBGrid1DblClick(Sender: TObject);
    procedure DBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
    procedure Panel4Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Panel3MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Label2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FormaConMovimiento: TFormaConMovimiento;

implementation

uses movinv;

{$R *.DFM}

procedure rutas;
var
  I: Integer;
begin

with FormaConMovimiento do
begin
  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TTable  then
     begin
       TTable(Components[I]).DatabaseName:=ruta(8);
       AbreTablaTotal(TTable(Components[I]));
//       TTable(Components[I]).Open;
     end;
    end;
end;

end;


procedure TFormaConMovimiento.DBGrid1DblClick(Sender: TObject);
begin
FormaMovimientosInventario.EditTIMOV_MI.Text:=FormaConMovimiento.TablaConMovinv.FieldByName('NUCON_CM').AsString;
FormaMovimientosInventario.TipMov.Caption:=FormaConMovimiento.TablaConMovinv.FieldByName('DECON_CM').AsString;
FormaConMovimiento.Close;
end;

procedure TFormaConMovimiento.DBGrid1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if Key=13 then
begin
FormaMovimientosInventario.EditTIMOV_MI.Text:=FormaConMovimiento.TablaConMovinv.FieldByName('NUCON_CM').AsString;
FormaMovimientosInventario.TipMov.Caption:=FormaConMovimiento.TablaConMovinv.FieldByName('DECON_CM').AsString;
FormaConMovimiento.Close;
end;
end;

procedure TFormaConMovimiento.FormActivate(Sender: TObject);
begin
if FormaConMovimiento.Tag=0 then
rutas;
FormaConMovimiento.Tag:=1;
{TablaConMovinv.FindNearest([FormaMovimientosInventario.EditTIMOV_MI.Text]);}
DBGrid1.SelectedIndex:=0;
DBGrid1.SetFocus;
end;



procedure TFormaConMovimiento.Panel4Click(Sender: TObject);
begin
Close;
end;

procedure TFormaConMovimiento.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=27 then Close;
end;

procedure TFormaConMovimiento.Panel3MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(FormaConMovimiento.Handle, WM_SYSCOMMAND, $F012, 0);
end;

procedure TFormaConMovimiento.Label2MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(FormaConMovimiento.Handle, WM_SYSCOMMAND, $F012, 0);
end;

end.
