zmiana ValueListEditor1 na listview

0

znowu mam problem ten program mi zapisuje ale wszystko w 2 tabelach po 3 rzeczy a chce zeby to normala tabela byla tz zeby wszystko odzielnie sie zapisywalo ?? mozna to tak zrobic i jak mozna edytowac w tej tabeli i ja odczytywac

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ValEdit;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Label4: TLabel;
Button3: TButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Label5: TLabel;
Label6: TLabel;
ComboBox3: TComboBox;
Button4: TButton;
lista: TValueListEditor;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure Button4Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
dane : TFileStream;
begin
lista.InsertRow(Edit1.Text+'| '+ Edit2.Text+'| '+Edit3.Text, ComboBox1.Text+ '| '+ComboBox2.text+ '| '+ComboBox3.text, True);

dane := TFileStream.Create('E:\osoby\baza.txt', fmCreate);

lista.Strings.SaveToStream(dane);

dane.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
lista.DeleteRow(lista.Row);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
dane : TFileStream;
begin

If not FileExists('E:\osoby\baza.txt') Then

Exit;

dane := TFileStream.Create('E:\osoby\baza.txt', fmOpenRead);

lista.Strings.LoadFromStream(dane);

dane.Free;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
dane : TFileStream;
begin

dane := TFileStream.Create('E:\osoby\baza.txt', fmCreate);

lista.Strings.SaveToStream(dane);

dane.Free;

end;

procedure TForm1.Edit3Change(Sender: TObject);
var blad :boolean;
r, i : integer;
v : string;
begin
v:=('00000000000');
while((blad=true)or(length(Edit3.Text)<>11))do
begin
blad:=false;
r:= MessageBox(Handle,'Czy chcesz podac pesel?','pesel', MB_YESNO + MB_ICONQUESTION);
case r of
IdYES : Edit3.Text := InputBox('pesel', 'Podaj pesel(11 cyfr): ','');
IdNO : Edit3.Text :=(v);
end;
// potrzeba na nowo sprawdzić czy nie ma bledu
for i:=1 to length(Edit3.text) do
if not(Edit3.Text[i] in ['0'..'9'])then
blad:=true;
end;

end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if (Edit1.text) = '' then
ShowMessage('brak imienia');

if (Edit2.text) = '' then
ShowMessage('brak nazwiska');

if (Edit3.text) = '' then
ShowMessage('brak peselu');

if (ComboBox1.text) = '' then
ShowMessage('brak Stopnia');

if (ComboBox2.text) = '' then
ShowMessage('brak odzialu');

if (ComboBox3.text) = '' then
ShowMessage('brak wydzialu');

ShowMessage( Edit1.text +'| '+ Edit2.text + '| '+Edit3.text +'| '+ ComboBox1.text + '| ' + ComboBox2.text+ '| ' + ComboBox3.text );
end;
end.

0

chce napisac ze ten program nie jest jeszcze zrobiony do konca wiec na jakies razace niedociagniecia nie patrzcie ;)

1 użytkowników online, w tym zalogowanych: 0, gości: 1