Урок на Делфи 76. База даных из INI


задание на delphi. база данных на базе tinifiles

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids, Data.DB,inifiles,
Vcl.DBGrids, Data.Win.ADODB;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Label1: TLabel;
StringGrid1: TStringGrid;
procedure Button3Click(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
k_x,k_y:integer;
bd:TIniFile;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
for j := 1 to 4 do
begin
for I := 0 to StringGrid1.RowCount do
begin
bd.WriteString('stolb'+IntToStr(j),IntToStr(i),StringGrid1.Cells[j,i]);
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
stolb:TStringList;
i,j:integer;
begin
for j := 1 to 4 do
begin
for I := 0 to StringGrid1.RowCount do
begin
StringGrid1.Cells[j,i]:=bd.ReadString('stolb'+IntToStr(j),IntToStr(i),'');
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
StringGrid1.Cells[k_x,k_y]:=Edit1.Text;
Edit1.Clear;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i:integer;
begin
bd:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'bd.ini');
StringGrid1.DefaultColWidth:=145;
StringGrid1.RowCount:=50;
StringGrid1.ColCount:=5;
StringGrid1.Cells[0,0]:='';
StringGrid1.Cells[1,0]:='';
StringGrid1.Cells[2,0]:=' ';
StringGrid1.Cells[3,0]:='';
StringGrid1.Cells[4,0]:='-';
for I := 0 to StringGrid1.RowCount do
begin
StringGrid1.Cells[0,i]:=IntToStr(i);
end;
end;
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Edit1.SetFocus;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
k_x:=ACol;
k_y:=ARow;
Label1.Caption:=IntToStr(k_x)+' '+IntToStr(k_y);
end;
end.



Скачать