unit Unit2 ;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, Buttons, Db, DBTables;
type
TForm2 = class(TForm)
MainMenu1: TMainMenu;
Inicio1: TMenuItem;
Busqueda1: TMenuItem;
salir1: TMenuItem;
Ayuda1: TMenuItem;
Creditos1: TMenuItem;
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
BitBtn2: TBitBtn;
Label3: TLabel;
BitBtn3: TBitBtn;
Query1: TQuery;
Database1: TDatabase;
Query2: TQuery;
Query3: TQuery;
Query4: TQuery;
Edit1: TEdit;
function Split(input:string;schar:char;s:integer):string;
//function Trim(const S: string): string;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure salir1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
function TForm2.Split(input:string;schar:char;s:integer):string;
var
i,n:integer;
schop: string;
begin
n := 1;
for i := 1 to length(input) do
begin
if (input[i] = schar) then
begin
inc(n);
if n = s then
split := schop
else
schop := '';
end
else
schop := schop + input[i];
end;
end;
// boton de carga de archivos buenos
procedure TForm2.BitBtn1Click(Sender: TObject);
var
Texto: TStringList;
a :integer; // xcancelacion
b :String; // tarjeta
c :integer; // numero operacion
d :String; // fecha
e :String; // hora
f :integer; // tipo operacion
g :integer; // num_cancelacion torniquete
h :integer; // estacion
l :integer; // pos
j :integer; // cajero
k :integer; // monto
m :integer; // remanente
i: integer;
cont:integer;
begin
Texto:=TStringList.Create;
Texto.LoadFromFile('C:\Documents and Settings\Felipe\Escritorio\Sistema EFE\export\prueba.txt');
cont:=0;
for i:=0 to 1 do
begin
a :=StrToInt(Split(Texto.Strings[i], ';', 2));
b :=Split(Texto.Strings[i], ';', 3);
c :=StrToInt(Split (Texto.Strings[i], ';', 4));
d :=Split (Texto.Strings[i], ';', 5);
e :=Split(Texto.Strings[i], ';', 6);
f :=StrToInt(Split(Texto.Strings[i], ';', 7));
g :=StrToInt(Split(Texto.Strings[i], ';', 8));
h :=StrToInt(Split(Texto.Strings[i], ';', 9));
l :=StrToInt(Split(Texto.Strings[i], ';', 10));
j :=StrToInt(Split(Texto.Strings[i], ';', 11));
k :=StrToInt(Split(Texto.Strings[i], ';', 12));
m :=StrToInt(Split(Texto.Strings[i], ';', 13));
cont := cont+1;
// carga de datos de archivo con Pos
if ( ( f =6) or (f =7) or (f =8) or (f =9) or (f =10)or (f =11)) then
begin
query1.Close;
query1.Params[0].Value := cont; // numero contador
query1.params[1].Value := b; // numero tarjeta
query1.params[2].Value := c; // numero de operacion
query1.Params[3].value := d; // fecha
query1.Params[4].Value := StrToTime(e); // hora
query1.Params[5].Value := f; // tipo operacion
query1.Params[6].Value := l; // identificacion estacion
query1.Params[7].Value := j; // identificacion pos
query1.Params[8].Value := h; // id caajero
query1.Params[9].Value := k; // monto
query1.Params[10].Value := m; // remanente
query1.ExecSql;
//query1.Open;
end;
// carga de archivos de torniquetes
if ( (f=1) or (f=2)or (f=3)or (f=4) or (f=5))then
begin
query4.close;
query4.Params[0].Value := Cont; // contador
query4.params[1].Value := b; // numero de tarjeta
query4.params[2].Value := c; // numero de operacion
query4.Params[3].value := d; // fecha
query4.Params[4].Value := e; // hora
query4.Params[5].Value := f; // tipo operacion
query4.Params[6].Value := g; // numero de torniquete
query4.Params[7].Value := h; // identificacion de estacion
query4.Params[8].Value := k; // monto
query4.Params[9].Value := m; // Remanente
query4.ExecSql;
//query4.Open;
end;
end;
Texto.Free;
end;