Fórum Conversor arquivo txt para tabela em firebird #408406
10/10/2011
0
Gilberto
Curtir tópico
+ 0Posts
11/10/2011
Edgard Leal
Gostei + 0
12/10/2011
Leandro
pode ser usado um objeto TStringList
exemplo:
var
lTexto : TStringList;
i: Integer;
begin
//CRIA O OBJETO
lTexto := TStringList.Create;
//CARREGA O ARQUIVO
lTexto.LoadFromFile(SeuArquivo.text);
//VARRE A LISTA COM AS LINHAS
for i:=0 lTexto.Count-1 do
begin
SuaTabela.Append;
SuaTabelaCampo1.AsSreing := Copy(lTexto[i],1,10);
SuaTabela.Post;
end;
end;
O PRÉ REQUISITO DO ARQUIVO QUE ELE TRANHA UM PADRAO TAMANHO DAS COLUNAS
SENDO QUE VC EXECUTANDO SuaTabelaCampo1.AsSreing := Copy(lTexto[i],1,10);
DEFINIMOS AS POSIÇOES E ALIMENTAMOS AS COLUNAS DE NOSSA TABELA.
GRATO.
Gostei + 0
12/10/2011
Gilberto
chamado orcament.dbf.
checa
orcamento se orcament
codigo produto produto quantidade unidad preco total numero data foi importado
00581 FERRADURA 0000001,00 UNI 0000012,00 0000012,00 052047 16/06/2011 SIM
00162 CRAVO 0000024,00 UNI 0000000,35 0000008,40 052047 16/06/2011 SIM
como houve troca de base de dados para firebird, preciso alterar a rotina para passar a gravar os orcamentos em uma
base de dados firebird na tabela orcament que pelo que vejo tem os mesmo campos do arquivo orcament.dbf, como a rotina
foi feita por outra pessoa que nao mais trabalha com delphi,preciso de ajuda para refazer a rotina.
segue abaixo a rotina que gravava em arquivo dbf:
object frmInterfaceOrcamento: TfrmInterfaceOrcamento
Left = 98
Top = 46
Width = 777
Height = 515
Caption = frmInterfaceOrcamento
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = MS Sans Serif
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
WindowState = wsMinimized
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label4: TLabel
Left = 336
Top = 320
Width = 87
Height = 13
Caption = Codigo do produto
end
object Label5: TLabel
Left = 336
Top = 336
Width = 48
Height = 13
Caption = Descri#231#227o
end
object Label3: TLabel
Left = 72
Top = 360
Width = 100
Height = 13
Caption = Registros regravados
end
object Label2: TLabel
Left = 72
Top = 336
Width = 91
Height = 13
Caption = Registros gravados
end
object Label1: TLabel
Left = 72
Top = 416
Width = 110
Height = 13
Caption = Importando, aguarde ...
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = MS Sans Serif
Font.Style = []
ParentFont = False
end
object Label7: TLabel
Left = 336
Top = 304
Width = 42
Height = 13
Caption = 00:00:00
end
object Label8: TLabel
Left = 459
Top = 304
Width = 42
Height = 13
Caption = 00:00:00
end
object Label9: TLabel
Left = 72
Top = 392
Width = 64
Height = 13
Caption = Observa#231#227o:
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = MS Sans Serif
Font.Style = []
ParentFont = False
end
object Label10: TLabel
Left = 336
Top = 272
Width = 65
Height = 13
Caption = Retaguarda.:
end
object Label11: TLabel
Left = 336
Top = 288
Width = 83
Height = 13
Caption = Frente de Caixa.:
end
object Label12: TLabel
Left = 456
Top = 272
Width = 38
Height = 13
Caption = Label12
end
object Label13: TLabel
Left = 456
Top = 288
Width = 38
Height = 13
Caption = Label13
end
object Label6: TLabel
Left = 336
Top = 352
Width = 32
Height = 13
Caption = Label6
Visible = False
end
object DBGrid1: TDBGrid
Left = 14
Top = 14
Width = 739
Height = 251
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = MS Sans Serif
TitleFont.Style = []
end
object Edit2: TEdit
Left = 184
Top = 360
Width = 41
Height = 21
TabOrder = 1
Text = 0
end
object Edit1: TEdit
Left = 184
Top = 328
Width = 41
Height = 21
TabOrder = 2
Text = 0
end
object Button4: TButton
Left = 654
Top = 456
Width = 101
Height = 23
Caption = Sair
TabOrder = 3
OnClick = Button4Click
end
object Button2: TButton
Left = 541
Top = 456
Width = 101
Height = 23
Caption = Importar
TabOrder = 4
OnClick = Button2Click
end
object Button1: TButton
Left = 430
Top = 456
Width = 101
Height = 23
Caption = Limpar o Arquivo
TabOrder = 5
OnClick = Button1Click
end
object RadioGroup1: TRadioGroup
Left = 72
Top = 264
Width = 153
Height = 57
Caption = Timer (10 seg.)
TabOrder = 6
end
object RadioButton1: TRadioButton
Left = 96
Top = 280
Width = 113
Height = 17
Caption = Ativado
Checked = True
TabOrder = 7
TabStop = True
OnClick = RadioButton1Click
end
object RadioButton2: TRadioButton
Left = 96
Top = 296
Width = 113
Height = 17
Caption = Desativado
TabOrder = 8
OnClick = RadioButton2Click
end
object Query1: TQuery
AutoCalcFields = False
AutoRefresh = True
DatabaseName = C:\Arquivos de programas\SmallSoft\Small Commerce
DataSource = DataSource2
SQL.Strings = (
select * from orcament where Pedido = :Pedido and Codigo = :Codi +
go)
Left = 520
Top = 272
ParamData = <
item
DataType = ftString
Name = Pedido
ParamType = ptInput
Size = 6
Value =
end
item
DataType = ftString
Name = Codigo
ParamType = ptInput
Size = 5
Value =
end>
object Query1CODIGO: TStringField
FieldName = CODIGO
Size = 5
end
object Query1DESCRICAO: TStringField
FieldName = DESCRICAO
Size = 45
end
object Query1QUANTIDADE: TFloatField
FieldName = QUANTIDADE
end
object Query1MEDIDA: TStringField
FieldName = MEDIDA
Size = 3
end
object Query1UNITARIO: TFloatField
FieldName = UNITARIO
end
object Query1TOTAL: TFloatField
FieldName = TOTAL
end
object Query1DATA: TDateField
FieldName = DATA
end
object Query1TIPO: TStringField
FieldName = TIPO
Size = 6
end
object Query1PEDIDO: TStringField
FieldName = PEDIDO
Size = 6
end
object Query1CLIFOR: TStringField
FieldName = CLIFOR
Size = 35
end
object Query1VENDEDOR: TStringField
FieldName = VENDEDOR
Size = 30
end
object Query1CAIXA: TStringField
FieldName = CAIXA
Size = 3
end
object Query1VALORICM: TFloatField
FieldName = VALORICM
end
object Query1ALIQUICM: TStringField
FieldName = ALIQUICM
Size = 5
end
end
object Query3: TQuery
AutoRefresh = True
DatabaseName = C:\Arquivos de programas\CompuFour\Aplicativos Comerciais
DataSource = DataSource1
SQL.Strings = (
Insert into orcament
(Descricao, Quantidade, Unitario, Total, Data, Tipo, +
Pedido, codigo)
values (:Descricao, :Quantidade, :Unitario, :Total, :Data, :Tipo +
, :Pedido, :codigo))
Left = 600
Top = 272
ParamData = <
item
DataType = ftString
Name = DESCRICAO
ParamType = ptUnknown
Size = 46
end
item
DataType = ftFloat
Name = QUANTIDADE
ParamType = ptUnknown
Size = 8
end
item
DataType = ftFloat
Name = UNITARIO
ParamType = ptUnknown
Size = 8
end
item
DataType = ftFloat
Name = TOTAL
ParamType = ptUnknown
Size = 8
end
item
DataType = ftDate
Name = DATA
ParamType = ptUnknown
Size = 4
end
item
DataType = ftString
Name = TIPO
ParamType = ptUnknown
Size = 7
end
item
DataType = ftString
Name = PEDIDO
ParamType = ptUnknown
Size = 7
end
item
DataType = ftString
Name = CODIGO
ParamType = ptUnknown
Size = 6
end>
end
object Query2: TQuery
AutoCalcFields = False
AutoRefresh = True
DatabaseName = C:\Arquivos de programas\CompuFour\Aplicativos Comerciais
DataSource = DataSource1
SQL.Strings = (
Update orcament
set Descricao = :Descricao,
Quantidade = :Quantidade,
Unitario = :Unitario,
Total = :Total,
Data = :Data,
Tipo = :Tipo,
Pedido = :Pedido
Where Codigo = :Codigo)
Left = 560
Top = 272
ParamData = <
item
DataType = ftString
Name = DESCRICAO
ParamType = ptUnknown
Size = 46
end
item
DataType = ftFloat
Name = QUANTIDADE
ParamType = ptUnknown
Size = 8
end
item
DataType = ftFloat
Name = UNITARIO
ParamType = ptUnknown
Size = 8
end
item
DataType = ftFloat
Name = TOTAL
ParamType = ptUnknown
Size = 8
end
item
DataType = ftDate
Name = DATA
ParamType = ptUnknown
Size = 4
end
item
DataType = ftString
Name = TIPO
ParamType = ptUnknown
Size = 7
end
item
DataType = ftString
Name = PEDIDO
ParamType = ptUnknown
Size = 7
end
item
DataType = ftString
Name = CODIGO
ParamType = ptUnknown
Size = 6
end>
end
object OpenDialog1: TOpenDialog
FileName = C:\Fatura\Interfac\OR060725.TXT
Filter = Arquivo Texto (or*.txt)|OR*.txt
InitialDir = C:\FATURA\INTERFAC
Left = 656
Top = 272
end
object OpenDialog2: TOpenDialog
FileName = C:\Arquivos de programas\SmallSoft\Small Commerce\ORCAMENT.DBF
Filter = Arquivo Dbase (Orc*.dbf)|Orc*.dbf
InitialDir = C:\Arquivos de programas\SmallSoft\Small Commerce
Left = 720
Top = 272
end
object DataSource1: TDataSource
DataSet = Table1
Left = 722
Top = 338
end
object Table1: TTable
AutoRefresh = True
DatabaseName = C:\Arquivos de programas\SmallSoft\Small Commerce
TableName = ORCAMENT
TableType = ttDBase
Left = 720
Top = 386
object Table1CODIGO: TStringField
FieldName = CODIGO
Size = 5
end
object Table1DESCRICAO: TStringField
FieldName = DESCRICAO
Size = 45
end
object Table1PEDIDO: TStringField
FieldName = PEDIDO
Size = 6
end
object Table1QUANTIDADE: TFloatField
FieldName = QUANTIDADE
end
object Table1MEDIDA: TStringField
FieldName = MEDIDA
Size = 3
end
object Table1UNITARIO: TFloatField
FieldName = UNITARIO
end
object Table1TOTAL: TFloatField
FieldName = TOTAL
end
object Table1DATA: TDateField
FieldName = DATA
end
object Table1TIPO: TStringField
FieldName = TIPO
Size = 6
end
object Table1CLIFOR: TStringField
FieldName = CLIFOR
Size = 35
end
object Table1VENDEDOR: TStringField
FieldName = VENDEDOR
Size = 30
end
object Table1CAIXA: TStringField
FieldName = CAIXA
Size = 3
end
object Table1VALORICM: TFloatField
FieldName = VALORICM
end
object Table1ALIQUICM: TStringField
FieldName = ALIQUICM
Size = 5
end
end
object Timer1: TTimer
Interval = 10000
OnTimer = Timer1Timer
Left = 512
Top = 368
end
object DataSource2: TDataSource
DataSet = Table2
Left = 634
Top = 338
end
object Table2: TTable
AutoRefresh = True
DatabaseName = C:\Arquivos de programas\SmallSoft\Small Commerce
TableName = ORCAMENT
TableType = ttDBase
Left = 632
Top = 386
object StringField1: TStringField
FieldName = CODIGO
Size = 5
end
object StringField2: TStringField
FieldName = DESCRICAO
Size = 45
end
object FloatField1: TFloatField
FieldName = QUANTIDADE
end
object StringField3: TStringField
FieldName = MEDIDA
Size = 3
end
object FloatField2: TFloatField
FieldName = UNITARIO
end
object FloatField3: TFloatField
FieldName = TOTAL
end
object DateField1: TDateField
FieldName = DATA
end
object StringField4: TStringField
FieldName = TIPO
Size = 6
end
object StringField5: TStringField
FieldName = PEDIDO
Size = 6
end
object StringField6: TStringField
FieldName = CLIFOR
Size = 35
end
object StringField7: TStringField
FieldName = VENDEDOR
Size = 30
end
object StringField8: TStringField
FieldName = CAIXA
Size = 3
end
object FloatField4: TFloatField
FieldName = VALORICM
end
object StringField9: TStringField
FieldName = ALIQUICM
Size = 5
end
end
end
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)