unit Principa;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogos, Menus, Grids, Calendar, ExtCtrls,dbtables, Buttons,
  StdCtrls, Db,Checa,dbctrls,dbgrids,Describe,Dialogs;

type
  TFormaPrincipal = class(TForm)
    Panel1: TPanel;
    BotonEmpresa: TSpeedButton;
    BotonClientes: TSpeedButton;
    BotonProveedo: TSpeedButton;
    BotonVendedor: TSpeedButton;
    BotonFactu: TSpeedButton;
    BotonInventa: TSpeedButton;
    BotonMovinv: TSpeedButton;
    BotonCompra: TSpeedButton;
    Usuario: TLabel;
    MainMenu1: TMainMenu;
    Archivo1: TMenuItem;
    Modulos1: TMenuItem;
    Inventario1: TMenuItem;
    N1: TMenuItem;
    General1: TMenuItem;
    Clientes1: TMenuItem;
    Proveedores1: TMenuItem;
    Vendedores1: TMenuItem;
    Facturacion1: TMenuItem;
    Producto1: TMenuItem;
    Compras1: TMenuItem;
    MovalInventario1: TMenuItem;
    opciones1: TMenuItem;
    Utilerias1: TMenuItem;
    Empresa1: TMenuItem;
    Salir1: TMenuItem;
    Reportes1: TMenuItem;
    Factura1: TMenuItem;
    Respaldos1: TMenuItem;
    Ayuda1: TMenuItem;
    Acercade1: TMenuItem;
    Sistema1: TMenuItem;
    VerTemas1: TMenuItem;
    AltadeConceptosCobranza1: TMenuItem;
    AltadeConceptosMovimientos1: TMenuItem;
    Calculadora1: TMenuItem;
    Divisas1: TMenuItem;
    Catalogos1: TMenuItem;
    Clientes2: TMenuItem;
    Proveedores2: TMenuItem;
    Vendedores2: TMenuItem;
    Facturacin1: TMenuItem;
    Compras2: TMenuItem;
    CuentasPorPagar1: TMenuItem;
    Inventario2: TMenuItem;
    MovimientosalInventario1: TMenuItem;
    BotonSalir: TSpeedButton;
    CatlogoconImgenes1: TMenuItem;
    ReportesSQL1: TMenuItem;
    Reindexar1: TMenuItem;
    SpeedButton1: TSpeedButton;
    Logo: TPanel;
    Image8: TImage;
    CapturaRpida1: TMenuItem;
    Panel2: TPanel;
    IniciarenCapturaRpida1: TMenuItem;
    CapturaRapidadeClaves1: TMenuItem;
    Panel3: TPanel;
    Image2: TImage;
    procedure Clientes1Click(Sender: TObject);
    procedure Proveedores1Click(Sender: TObject);
    procedure Vendedores1Click(Sender: TObject);
    procedure Facturacin2Click(Sender: TObject);
    procedure Producto1Click(Sender: TObject);
    procedure Compras1Click(Sender: TObject);
    procedure Movimientos1Click(Sender: TObject);
    procedure General1Click(Sender: TObject);
    procedure Acercade1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Conceptos1Click(Sender: TObject);
    procedure Reportes1Click(Sender: TObject);
    procedure Indices1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Empresa1Click(Sender: TObject);
    procedure Formatos1Click(Sender: TObject);
    procedure Calculadora1Click(Sender: TObject);
    procedure Respaldos1Click(Sender: TObject);
    procedure ControldeArchivos1Click(Sender: TObject);
    procedure Salir1Click(Sender: TObject);
    procedure Sistema1Click(Sender: TObject);
    procedure VerTemas1Click(Sender: TObject);
    procedure AltadeConceptosCobranza1Click(Sender: TObject);
    procedure AltadeConceptosMovimientos1Click(Sender: TObject);
    procedure Divisas1Click(Sender: TObject);
    procedure Clientes2Click(Sender: TObject);
    procedure Proveedores2Click(Sender: TObject);
    procedure Vendedores2Click(Sender: TObject);
    procedure Facturacin1Click(Sender: TObject);
    procedure Compras2Click(Sender: TObject);
    procedure Inventario2Click(Sender: TObject);
    procedure MovimientosalInventario1Click(Sender: TObject);
    procedure CuentasPorPagar1Click(Sender: TObject);
    procedure Panel3Click(Sender: TObject);
    procedure BotonSalirClick(Sender: TObject);
    procedure CatlogoconImgenes1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BotonEmpresaMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonClientesMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonProveedoMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonVendedorMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonFactuMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonInventaMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonMovinvMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BotonCompraMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ReportesSQL1Click(Sender: TObject);
    procedure Reindexar1Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure IniciarenCapturaRpida1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CapturaRapidadeClaves1Click(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormClick(Sender: TObject);
    procedure Panel2Click(Sender: TObject);
  private
    { Private declarations }
  public
procedure AppMessage(var Msg: TMsg; var Handled: Boolean);
    { Public declarations }
  end;

var
  FormaPrincipal: TFormaPrincipal;
   FormAux: TForm;
  contador:integer;
  direc:string;

  implementation

  uses Cliente,Proveedo,Vendedor,Factu,Comovinv,Inven,{CuCobra,CxP,}Compras,movinv,
  General, Acerca{, presenta}, graficas, Lista, utileria,{ cxcd, cxpd,}
  formatos, {ConCobra,} respaldo, ConPromo,{ control,} Empresas, CONVEN,
  {concupag,} Sistema, moneda, adminis, ConsCata,  Elipse,
  ConPro, CONCLIE, consulta,ayudaMod,   IndiTodo, CaptuRap,
  ClaveRapida, SQLRepo{, Factura};
  {$R *.DFM}


procedure PoneBitmap(forma:Tform;Imagen:TImage;archi:string);
var
  Bitmap : TBitMap;
  ancho,largo:integer;
  i,j,cuenta,cuenta2:integer;
begin
if FileExists(archi) then
begin
  Bitmap := TBitmap.Create;
  try
    with Bitmap do begin
      LoadFromFile(archi);

//      Transparent := true;
//      TransParentColor := BitMap.canvas.pixels[5,5];
//    FormaCapturaRapida.Detalle.Canvas.Draw(0,0,BitMap);
//    ShowMessage('');
//      TransparentMode := tmAuto;   // Transparent color now is clDefault = TColor($20000000);

ancho:=Bitmap.Width;
largo:=Bitmap.Height;


cuenta:=Trunc(Forma.Width/ancho);
cuenta2:=Trunc(Forma.Height/largo);
//ShowMessage(IntTostr(cuenta));

//k:=2;
for j:=0 to cuenta2 do
for i:=0 to cuenta do
begin
//if j mod k=0 then
  Imagen.Canvas.Draw(i*ancho,j*largo,BitMap);
end;

//          ShowMessage('');
    end;

  finally
  Bitmap.Free;

  end;
end;//if fileexists
end;


{****Activa la tecla enter como tabulador******}


procedure TFormaPrincipal.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
 if (Msg.wParam = VK_RETURN)or (Msg.wParam = VK_DOWN) then
 begin
  if ((Screen.ActiveControl) is TStringGrid) then
 Msg.wParam := VK_TAB;
 end;

{ if (Msg.wParam = VK_PRIOR) then
 begin

  if ((Screen.ActiveControl) is TStringGrid) then
 Msg.wParam := VK_SHIFT+VK_TAB;
 end; }


{end;}
end;



{***termina procedimiento  de enter******}

procedure rutas(FormAux:TForm);
var
  I: Integer;
begin

with FormAux do
begin
try
  for I := 0 to ComponentCount -1 do
    begin
     if Components[I] is TTable  then
     begin
        if TTable(Components[I]).State=dsBrowse	 then
             TTable(Components[I]).Close;
     end;
    end;
    FormAux.Tag:=0;
except
end;    
end;

end;

procedure formas;
begin
try
 rutas(FormaClientes);
 rutas(FormaProveedo);
 rutas(FormaVendedor);
// rutas(FormaFactura);
{ rutas(FormaCuCobra);
 rutas(FormaCxPagar);}
 rutas(FormaInventario);
 rutas(FormaCompras);
// rutas(FormaMovimientosInventario);
// rutas(FormaComovinv);
// rutas(FormaGraficas);
{***consultas**************}
// rutas(FormaConsulta);
// rutas(FormaConClientes);
 //rutas(FormaConProduct);
// rutas(FormaConProvee);
 //rutas(FormaConVendedores);
{ rutas(FormaConsultaCuePagar);}
// rutas(FormaCatalogo);
 except
 //nada
 end;

end;

procedure ChecaCerradoFormas;
begin

{ if Msg.wParam = VK_RETURN then
 begin
 if ((Screen.ActiveControl) is TEdit)or((Screen.ActiveControl) is TDBEdit)
  or ((Screen.ActiveControl) is TDBGrid)and((Screen.ActiveForm) is TFormaPrincipal) then
 Msg.wParam := VK_TAB;
 end;}

 if FormaClientes.Visible=True then
 begin
 FormaClientes.Show;
 FormaClientes.Close;
 end;

 if FormaProveedo.Visible=True then
 begin
 FormaProveedo.Show;
 FormaProveedo.Close;
 end;

 if FormaVendedor.Visible=True then
 begin
 FormaVendedor.Show;
 FormaVendedor.Close;
 end;

// if FormaFactura.Visible=True then
// begin
// FormaFactura.Show;
// FormaFactura.Close;
// end;

 if FormaInventario.Visible=True then
 begin
 FormaInventario.Show;
 FormaInventario.Close;
 end;

 if FormaCompras.Visible=True then
 begin
 FormaCompras.Show;
 FormaCompras.Close;
 end;

 if FormaCompras.Visible=True then
 begin
 FormaCompras.Show;
 FormaCompras.Close;
 end;

// if FormaMovimientosInventario.Visible=True then
// begin
// FormaMovimientosInventario.Show;
// FormaMovimientosInventario.Close;
// end;

{ if FormaCatalogo.Visible=True then
 begin
 FormaCatalogo.Show;
 FormaCatalogo.Close;
 end;}

end;

{***************************}


procedure TFormaPrincipal.Clientes1Click(Sender: TObject);
begin
FormaClientes.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),1) then
begin
    FormaClientes.Show;
end;
end;

procedure TFormaPrincipal.Proveedores1Click(Sender: TObject);
begin
FormaProveedo.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),3) then
begin
FormaProveedo.Saldo.Visible:=False;
FormaProveedo.Show;
end;

end;

procedure TFormaPrincipal.Vendedores1Click(Sender: TObject);
begin
FormaVendedor.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),2) then
begin
{FormaVendedor.Show;}
FormaVendedor.Show;
end;
end;

procedure TFormaPrincipal.Facturacin2Click(Sender: TObject);
begin
FormaFactura:=TFormaFactura.Create(Application);
FormaFactura.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),4) then
begin
FormaFactura.ShowModal;
end;
FormaFactura.Free;
end;

procedure TFormaPrincipal.Producto1Click(Sender: TObject);
var
entrar:boolean;
begin
entrar:=False;
FormaInventario.Usuario.Caption:=Usuario.Caption;
if Usuario.Caption<>'0' then
begin
FormaAdministrador:=TFormaAdministrador.Create(Application);
FormaAdministrador.ShowModal;
FormaReindexaTodo:=TFormaReindexaTodo.Create(Application);
if FormaAdministrador.Tag=1 then
begin
entrar:=True;
end;

end;

if entrar then
begin
FormaInventario.Usuario.Caption:='0';
FormaInventario.Show;
end
else
begin
if (caso(StrToInt(usuario.Caption),8)) then
begin
FormaInventario.Show;
end;
end;

end;

procedure TFormaPrincipal.Compras1Click(Sender: TObject);
begin

FormaCompras.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),5) then
begin
FormaCompras.BotonPagos.Visible:=False;
FormaCompras.Show;
end;
end;

procedure TFormaPrincipal.Movimientos1Click(Sender: TObject);
begin
FormaMovimientosInventario:=TFormaMovimientosInventario.Create(Application);
FormaMovimientosInventario.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(Usuario.Caption),9) then
begin
FormaMovimientosInventario.ShowModal;
end;
FormaMovimientosInventario.Free;

end;

procedure TFormaPrincipal.General1Click(Sender: TObject);
begin
FormaAdministrador:=TFormaAdministrador.Create(Application);
FormaConfiguracionGeneral:=TFormaConfiguracionGeneral.Create(Application);
FormaAdministrador.ShowModal;
if FormaAdministrador.Tag=1 then
begin

FormaConfiguracionGeneral.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),10) then
begin
FormaConfiguracionGeneral.Tag:=0;
FormaConfiguracionGeneral.ShowModal;
end;

end
else
begin
if FormaAdministrador.Tag=0 then
MuestraMensaje('No se Tienen Acceso a este Módulo');
end;


FormaAdministrador.Tag:=0;

FormaConfiguracionGeneral.Free;
FormaAdministrador.Free;
end;

procedure TFormaPrincipal.Acercade1Click(Sender: TObject);
begin
FormaAcerca:=TFormaAcerca.Create(Application);
FormaAcerca.Timer1.Enabled:=True;
FormaAcerca.ShowModal;
FormaAcerca.Timer1.Enabled:=False;
FormaAcerca.Free;

end;

procedure TFormaPrincipal.FormCreate(Sender: TObject);
begin
try
GetDir(0,direc);
//PoneBitmap(FormaPrincipal,Image2,direc+'\LOGOPV.bmp');
Application.OnMessage := AppMessage;
leeruta();
FormaPrincipal.Enabled:=False;
contador:=0;
except
ShowMessage('Esta es la Primera vez que Ejecuta el Programa');
end;
//WindowState:=wsMaximized;
end;

procedure TFormaPrincipal.Conceptos1Click(Sender: TObject);
begin
FormaComovinv:=TFormaComovinv.Create(Application);
FormaComovinv.Tag:=0;
FormaComovinv.ShowModal;
FormaComovinv.Free;

end;

procedure TFormaPrincipal.Reportes1Click(Sender: TObject);
begin
FormaDisenoVista:=TFormaDisenoVista.Create(Application);
{FormaDisenoVista.ShowModal;}
FormaDisenoVista.ShowModal;
FormaDisenoVista.Free;

{FormaDisenoVista.Tag:=0;
FormaDisenoVista.Show;}
end;


procedure TFormaPrincipal.Indices1Click(Sender: TObject);
begin
FormaUtilerias:=TFormaUtilerias.Create(Application);
FormaUtilerias.ShowModal;
FormaUtilerias.Free;

{FormaUtilerias.Tag:=0;
FormaUtilerias.Show;}
end;

procedure TFormaPrincipal.FormActivate(Sender: TObject);
var
arch:TextFile;
linea:string[1];
begin
{FormaPrincipal.Visible:=False; }
{FormaPresenta.ShowModal;}
{FormaPrincipal.Visible:=True;}
if FormaEmpresas.Tag=0 then
begin
{FormaPresentacion.Left:=FormaPrincipal.Left+Trunc(FormaPrincipal.Width/2)-Trunc(FormaPresentacion.Width/2);
FormaPresentacion.Top:=FormaPrincipal.Top+Trunc(FormaPrincipal.Height/2)-Trunc(FormaPresentacion.Height/2)+10;

FormaPresentacion.ShowModal;}
//FormaElipse.ShowModal;
FormaPrincipal.Color:=clMenu;
FormaEmpresas.ShowModal;
FormaPrincipal.Color:=clMenu;
//MuestraMensaje('ejecuta');
//***********ejecuta por captura rapida
if FileExists(leeruta+'\rapida.cnf') then
begin
AssignFile(arch,leeruta+'\rapida.cnf');
Reset(arch);
readln(arch,linea);
if linea='S' then
begin
Panel2Click(Sender);
IniciarenCapturaRpida1.Checked:=True;
end;
CloseFile(arch);

end;//fileexists


end;

end;

procedure TFormaPrincipal.Empresa1Click(Sender: TObject);
begin
formas;
FormaEmpresas.ShowModal;
{FormaParametros.ShowModal;}
end;

procedure TFormaPrincipal.Formatos1Click(Sender: TObject);
begin
FormaFormatos:=TFormaFormatos.Create(Application);

FormaFormatos.Rangos.Visible:=False;
FormaFormatos.Formatos.Visible:=True;
FormaFormatos.ShowModal;
FormaFormatos.Free;


end;

procedure TFormaPrincipal.Calculadora1Click(Sender: TObject);
begin

{if FileExists('c:\windows\calc.exe') then}
WinExec('calc.exe',SW_SHOWNORMAL);

end;

procedure TFormaPrincipal.Respaldos1Click(Sender: TObject);
begin
FormaAdministrador:=TFormaAdministrador.Create(Application);
FormaAdministrador.ShowModal;
if FormaAdministrador.Tag=1 then
begin
FormaRespaldo:=TFormaRespaldo.Create(Application);
FormaRespaldo.ShowModal;
FormaRespaldo.Free;
end
else
begin
if FormaAdministrador.Tag=0 then
MuestraMensaje('No se Tiene Acceso a este Módulo');
end;

FormaAdministrador.Tag:=0;

{FormaRespaldo.Show;}
FormaAdministrador.Free;
end;

procedure TFormaPrincipal.ControldeArchivos1Click(Sender: TObject);
begin
{Formacontrol:=TFormacontrol.Create(Application);
Formacontrol.ShowModal;
Formacontrol.Free;}
end;


procedure TFormaPrincipal.Salir1Click(Sender: TObject);
begin
Close;
end;



procedure TFormaPrincipal.Sistema1Click(Sender: TObject);
begin
FormaSistema:=TFormaSistema.Create(Application);

FormaSistema.ShowModal;
FormaSistema.Free;
{
  with FormaSistema.Create(Self) do
  try
    ShowModal;
  finally
    Free;
  end;}

end;

procedure TFormaPrincipal.VerTemas1Click(Sender: TObject);
begin
{
if FileExists('c:\ayuda\ayuda.exe') then
WinExec('c:\ayuda\ayuda.exe',SW_SHOWDEFAULT)
else
MuestraMensaje('No Existe el Archivo de Ayuda');}
{FormaAyudaLinea.Show;}
FormaAyudaLinea:=TFormaAyudaLinea.Create(Application);
PoneAyuda(leeruta+'\ayuda\principal.rtf',0);
FormaAyudaLinea.Free;

end;

procedure TFormaPrincipal.AltadeConceptosCobranza1Click(Sender: TObject);
begin
//FormaConceptos.ShowModal;
end;

procedure TFormaPrincipal.AltadeConceptosMovimientos1Click(
  Sender: TObject);
begin
FormaComovinv:=TFormaComovinv.Create(Application);
FormaCoMovInv.ShowModal;
FormaComovinv.Free;
end;

procedure TFormaPrincipal.Divisas1Click(Sender: TObject);
begin
FormaDivisa:=TFormaDivisa.Create(Application);
FormaDivisa.ShowModal;
FormaDivisa.Free;
end;

procedure TFormaPrincipal.Clientes2Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),1) then
begin
 FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('cliente.dbf');
poneparametros('cliente.dbf','CLCLI_C','NOMBR_C','RFCXX_C','c4','c5','c6','c7','c8','c9','Cliente','Nombre','R.F.C','e4','e5','e6','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;
end;

procedure TFormaPrincipal.Proveedores2Click(Sender: TObject);
begin
//FormaProveedo.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),3) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('proveedo.dbf');
poneparametros('proveedo.dbf','CLAVE_P','NOMBR_P','RFCXX_P','CARGO_P','ABONO_P','SALDO_P','c7','c8','c9','Cliente','Nombre','R.F.C','Cargos','Abonos','Saldo','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;
end;

procedure TFormaPrincipal.Vendedores2Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),2) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
{poneparametros('vendedor.dbf','CLVEN_V','NOMBR_V','COMIS_V','CLASV_V','c5','c6','c7','c8','c9','Vendedor','Nombre','Comisión','Clasificación','e5','e6','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');}
abretabla('vendedor.dbf');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;
end;

procedure TFormaPrincipal.Facturacin1Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),4) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('FacturaE.dbf');
poneparametros('FacturaE.dbf','CLDOC_F','CLCLI_F','NOMBR_F','FEDOC_F','FEVEN_F','IMTOD_F','c7','c8','c9','Documento','Clave','Nombre','Fech. Doc.','Fech. Venc.','Importe','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;

end;

procedure TFormaPrincipal.Compras2Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),5) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('comprasE.dbf');
poneparametros('comprasE.dbf','CLDOC_O','CLPRV_O','NOMBR_O','FEDOC_O','FEPAG_O','IMDOC_O','c7','c8','c9','Documento','Clave','Nombre','Fech. Doc.','Fech. Pag.','Importe','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;
end;

procedure TFormaPrincipal.Inventario2Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),8) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('inventar.dbf');
poneparametros('inventar.dbf','CLPRO_I','DSCPR_I','UMEDI_I','EXIST_I','PPUBL_I','c6','c7','c8','c9','Producto','Descripción','unid. Med.','Existencias','Precio Publ.','e6','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.Usuario.Caption:= usuario.Caption;

FormaCatalogo.ShowModal;
FormaCatalogo.Free;

end;

end;

procedure TFormaPrincipal.MovimientosalInventario1Click(Sender: TObject);
begin
if caso(StrToInt(usuario.Caption),9) then
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('movinven.dbf');
poneparametros('movinven.dbf','CLDOC_MI','CLPRO_MI','CLPRV_MI','DESCR_MI','TIMOV_MI','FEDOC_MI','CANTI_MI','c8','c9','Documento','Producto','Proveedor','Descripción','Tip. Mov.','Fecha Doc.','Cantidad','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;

end;

procedure TFormaPrincipal.CuentasPorPagar1Click(Sender: TObject);
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);
abretabla('cuepagar.dbf');
poneparametros('cuepagar.dbf','NUDOC_CP','CLCLI_CP','NOMBR_CP','CONCE_CP','IMCUE_CP','SALDO_CP','FEAPL_CP','FEVEN_CP','c9','Clave','Nombre','Documento','Concepto','Importe','Saldo','Fech. Aplic.','Fech. Venc.','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;


procedure TFormaPrincipal.Panel3Click(Sender: TObject);
begin
Close;
end;

procedure TFormaPrincipal.BotonSalirClick(Sender: TObject);
begin

Close;
BotonSalir.Tag:=1000;

end;

procedure TFormaPrincipal.CatlogoconImgenes1Click(Sender: TObject);
begin
FormaCatalogo:=TFormaCatalogo.Create(Application);

abretabla('inventar.dbf');
poneparametros('inventar.dbf','CLPRO_I','DSCPR_I','UMEDI_I','EXIST_I','PPUBL_I','c6','c7','c8','c9','Producto','Descripción','unid. Med.','Existencias','Precio Publ.','e6','e7','e8','e9','t1','t2','t3','t4','t5','t6','t7','t8','t9');
abrepanelimagen;
poneimagenes;
FormaCatalogo.ShowModal;
FormaCatalogo.Free;
end;

procedure TFormaPrincipal.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
ChecaCerradoformas;

BotonSalir.Tag:=1000;

end;

procedure TFormaPrincipal.BotonEmpresaMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonEmpresa.Left,FormaPrincipal.Top+BotonEmpresa.Top+BotonEmpresa.Height,110);
end;

procedure TFormaPrincipal.BotonClientesMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonClientes.Left,FormaPrincipal.Top+BotonClientes.Top+BotonClientes.Height,111);
end;

procedure TFormaPrincipal.BotonProveedoMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonProveedo.Left,FormaPrincipal.Top+BotonProveedo.Top+BotonProveedo.Height,112);
end;

procedure TFormaPrincipal.BotonVendedorMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonVendedor.Left,FormaPrincipal.Top+BotonVendedor.Top+BotonVendedor.Height,113);
end;

procedure TFormaPrincipal.BotonFactuMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonFactu.Left,FormaPrincipal.Top+BotonFactu.Top+BotonFactu.Height,114);
end;

procedure TFormaPrincipal.BotonInventaMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonInventa.Left,FormaPrincipal.Top+BotonInventa.Top+BotonInventa.Height,117);
end;

procedure TFormaPrincipal.BotonMovinvMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonMovinv.Left,FormaPrincipal.Top+BotonMovinv.Top+BotonMovinv.Height,118);
end;

procedure TFormaPrincipal.BotonCompraMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
describir(Button,FormaPrincipal.Left+BotonCompra.Left,FormaPrincipal.Top+BotonCompra.Top+BotonCompra.Height,119);
end;

procedure TFormaPrincipal.ReportesSQL1Click(Sender: TObject);
begin
{WinExec(PChar(leeruta+'\SQLSIF.Exe'),SW_SHOWNORMAL);}

FormaSQL:=TFormaSQL.Create(Application);
FormaSQL.ShowModal;
FormaSQL.Free;



end;

procedure TFormaPrincipal.Reindexar1Click(Sender: TObject);
begin
FormaAdministrador:=TFormaAdministrador.Create(Application);
FormaAdministrador.ShowModal;
FormaReindexaTodo:=TFormaReindexaTodo.Create(Application);
if FormaAdministrador.Tag=1 then
begin

FormaReindexaTodo.Showmodal;
end
else
MuestraMensaje('No se Tiene Acceso a este Módulo');
FormaAdministrador.Free;
FormaReindexaTodo.Free;
end;


procedure TFormaPrincipal.SpeedButton1Click(Sender: TObject);
begin
{FormaFactura2:=TFormaFactura2.Create(Application);
FormaFactura2.Usuario.Caption:=Usuario.Caption;
FormaFactura2.ShowModal;
FormaFactura2.Free;}

end;


procedure TFormaPrincipal.FormResize(Sender: TObject);
begin

BotonSalir.Left:=Panel1.Width-BotonSalir.Width-4;
Logo.Left:=Trunc((FormaPrincipal.Width/2)-(Logo.Width/2));
Logo.Top:=Trunc((FormaPrincipal.Height/2)-(Logo.Height/2));
PoneBitmap(FormaPrincipal,Image2,direc+'\LOGOPV.bmp');
end;


procedure TFormaPrincipal.IniciarenCapturaRpida1Click(Sender: TObject);
var
arch:TextFile;
begin
if usuario.Caption='0' then
begin
 IniciarenCapturaRpida1.Checked:=not IniciarenCapturaRpida1.Checked;
 AssignFile(arch,leeruta+'\Rapida.cnf');
 Rewrite(arch);
 if  IniciarenCapturaRpida1.Checked then
 Writeln(arch,'S')
 else
 Writeln(arch,'N');
 CloseFile(arch);
end;

end;


procedure TFormaPrincipal.FormShow(Sender: TObject);
var
rgn:hrgn;
begin

rgn:=CreateRoundRectRgn(0,0,Logo.width,Logo.height,15,15);
SetWindowRgn(Logo.handle,rgn,True);

rgn:=CreateRoundRectRgn(0,0,Panel2.width,Panel2.height,15,15);
SetWindowRgn(Panel2.handle,rgn,True);

rgn:=CreateRoundRectRgn(0,0,Panel1.width,Panel1.height,15,15);
SetWindowRgn(Panel1.handle,rgn,True);


//FormResize(Sender);
// WindowState:=wsMaximized;

// FormResize(Sender);
 
end;

procedure TFormaPrincipal.CapturaRapidadeClaves1Click(Sender: TObject);
begin
FormaClaveRapida:=TFormaClaveRapida.Create(Application);
FormaClaveRapida.BotonNuevo.Visible:=True;
FormaClaveRapida.BotonNuevo.Enabled:=False;
if ruta(59)<>'' then
AltaRapidaClave(ruta(59),'')
else
AltaRapidaClave(ruta(8),'');

FormaClaveRapida.Free;
end;

procedure TFormaPrincipal.FormPaint(Sender: TObject);
begin
PoneBitmap(FormaPrincipal,Image2,direc+'\LOGOPV.bmp');
end;

procedure TFormaPrincipal.FormClick(Sender: TObject);
begin
PoneBitmap(FormaPrincipal,Image2,direc+'\LOGOPV.bmp');
end;

procedure TFormaPrincipal.Panel2Click(Sender: TObject);
begin
FormaCapturaRapida:=TFormaCapturaRapida.Create(Application);
FormaCapturaRapida.Usuario.Caption:=Usuario.Caption;
if caso(StrToInt(usuario.Caption),4) then
begin
FormaCapturaRapida.Caption:=FormaCapturaRapida.Caption+'   '+UpperCase(NombreUsuario(usuario.Caption,leeruta))+'           '+DateToStr(Date);
// FormaCapturaRapida.Panel2Click(Sender);
FormaCapturaRapida.ShowModal;
//FormaCapturaRapida.Show;
end;
FormaCapturaRapida.Free;

end;

end.




















