Einzelnen Beitrag anzeigen

libFelix.so

Registriert seit: 9. Mär 2004
24 Beiträge
 
Delphi 7 Enterprise
 
#7

Re: wie schreibe ich daten in eine paradox7 tabelle?

  Alt 9. Mär 2004, 10:27
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DBCtrls, DB, DBTables;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Label10: TLabel;
    Edit11: TEdit;
    ComboBox1: TComboBox;
    Button3: TButton;
    DBRadioGroup1: TDBRadioGroup;
    DBRadioGroup2: TDBRadioGroup;
    DBRadioGroup3: TDBRadioGroup;
    DBRadioGroup4: TDBRadioGroup;
    Query1: TQuery;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  MyQuery: TQuery;
  wupb1, wupb2, wupb3, wupb4, wupb1d, wupb2d, wupb3d, wupb4d, wupgesd, wupges: integer;
implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

  //Einlesen der Variablen
  wupb1 := StrToInt(Edit2.Text);
  wupb2 := StrToInt(Edit3.Text);
  wupb3 := StrToInt(Edit4.Text);
  wupb4 := StrToInt(Edit5.Text);
  wupb1d := StrToInt (Edit7.Text);
  wupb2d := StrToInt (Edit8.Text);
  wupb3d := StrToInt (Edit9.Text);
  wupb4d := StrToInt (Edit10.Text);

  //Abzüge pro Bahn
  //Bahn1
  case DBRadioGroup1.ItemIndex of
    0 : wupb1 := wupb1 - 1;
    1 : wupb1 := wupb1 - 2;
    2 : wupb1 := wupb1 - 5;
  end;
  //Bahn2
  case DBRadioGroup2.ItemIndex of
    0 : wupb2 := wupb2 - 1;
    1 : wupb2 := wupb2 - 2;
    2 : wupb2 := wupb2 - 5;
  end;
  //Bahn3
  case DBRadioGroup3.ItemIndex of
    0 : wupb3 := wupb3 - 1;
    1 : wupb3 := wupb3 - 2;
    2 : wupb3 := wupb3 - 5;
  end;
  //Bahn4
  case DBRadioGroup4.ItemIndex of
    0 : wupb4 := wupb4 - 1;
    1 : wupb4 := wupb4 - 2;
    2 : wupb4 := wupb4 - 5;
  end;

  //Drops pro Bahn incl. Zuzüge
  wupb1 := (wupb1d * 2) + wupb1;
  wupb2 := (wupb2d * 2) + wupb2;
  wupb3 := (wupb3d * 2) + wupb3;
  wupb4 := (wupb4d * 2) + wupb4;

  //GesamtDrops
  wupgesd := wupb1d + wupb2d + wupb3d + wupb4d;

  //GesamtSchläge incl. Abzüge
  wupges := wupb1 + wupb2 + wupb3 + wupb4;

  //Ausgabe - Gesamt Drops
  Edit11.Text := IntToStr(wupgesd);

  //Ausgabe - Gesamt Schläge incl. Zu-/Abzüge
  Edit6.Text := IntToStr(wupges);

end;

procedure TForm1.Button3Click(Sender: TObject);
var
  name: string[15];
  f :textfile;

begin
  //Name aus ComboBox einlesen
  case combobox1.itemIndex of
    0 : name := 'Felixxx';
    1 : name := 'Katja';
    2 : name := 'Lenni';
    3 : name := 'Markus';
    4 : name := 'Oli';
    5 : name := 'Peter';
    6 : name := 'Rase';
    7 : name := 'Togi';
    8 : name := 'Wasi';
  end;

  //In Datei schreiben
  AssignFile(f,'erg_wup.txt');
    {$i-}
      Append(f);
    {$i+}
    if IOResult <> 0 then halt;
      Writeln(f,name + ',' + Edit2.Text + ',' + Edit7.Text + ',' + Edit3.Text + ',' + Edit8.Text + ',' + Edit4.Text + ',' + Edit9.Text + ',' + Edit5.Text + ',' + Edit10.Text + ',' + Edit6.Text + ',' + Edit11.Text);
    CloseFile(f)
end;

procedure PEinlesen;
var StrTable: String; // Pfad und Name der Tabelle
begin
  StrTable := ExtractFilePath(ParamStr(0)) + 'db/abzuege.db';
  // Datensätze mit Query einfügen
  with MyQuery do
  begin
    clear;
    Sql.Close;
    Sql.Add('Insert into "' + StrTable + '" values (' + IntToStr(wupb1) + ', ' + IntToStr(wupb1d) + ', ' + IntToStr(wupb2) + ', ' + IntToStr(wupb2d) + ', ' + IntToStr(wupb3) + ', ' + IntToStr(wupb3d) + ', ' + IntToStr(wupb4) + ', ' + IntToStr(wupb4d) + ')'); // Statt den Punkten die weiteren Variablen einsetzen
    ExecSql;
  end;
end;

end.
  Mit Zitat antworten Zitat