добавил часть модулей, нужно переделать БД на records
This commit is contained in:
+63
-1
@@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
System.Rtti, FMX.Grid.Style, FMX.Memo.Types, FMX.Grid, FMX.Layouts,
|
||||
System.Rtti, FMX.Grid.Style, FMX.Memo.Types, FMX.Grid, FMX.Layouts, uRecords,
|
||||
FMX.ListBox, FMX.Memo, FMX.Edit, FMX.Controls.Presentation, FMX.ScrollBox;
|
||||
|
||||
type
|
||||
@@ -82,14 +82,76 @@ type
|
||||
btnAIGenAdd: TButton;
|
||||
btnAIGenDel: TButton;
|
||||
btnAIGetTextUser: TButton;
|
||||
procedure btnRandAddClick(Sender: TObject);
|
||||
procedure btnRandDelClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
procedure UpdateGridFromArray;
|
||||
public
|
||||
{ Public declarations }
|
||||
RandomCounters: TArray<TRandomCounters>;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses uGeneral;
|
||||
|
||||
procedure TfrCommands.btnRandDelClick(Sender: TObject);
|
||||
var
|
||||
i, RowIndex: Integer;
|
||||
begin
|
||||
RowIndex := sgRandomInt.Row;
|
||||
if (RowIndex < 0) or (RowIndex > High(RandomCounters)) then Exit;
|
||||
|
||||
// Ñäâèãàåì ýëåìåíòû ìàññèâà
|
||||
for i := RowIndex to High(RandomCounters)-1 do
|
||||
RandomCounters[i] := RandomCounters[i+1];
|
||||
|
||||
SetLength(RandomCounters, Length(RandomCounters) - 1);
|
||||
|
||||
UpdateGridFromArray;
|
||||
DB.SaveGridToTable('sgRandomInt', sgRandomInt);
|
||||
end;
|
||||
|
||||
procedure TfrCommands.UpdateGridFromArray;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
sgRandomInt.BeginUpdate;
|
||||
try
|
||||
sgRandomInt.RowCount := 1; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
|
||||
|
||||
for i := 0 to High(RandomCounters) do
|
||||
begin
|
||||
sgRandomInt.RowCount := i + 1;
|
||||
sgRandomInt.Cells[0, i] := RandomCounters[i].Name;
|
||||
sgRandomInt.Cells[1, i] := IntToStr(RandomCounters[i].Ot);
|
||||
sgRandomInt.Cells[2, i] := IntToStr(RandomCounters[i].ToValue);
|
||||
end;
|
||||
finally
|
||||
sgRandomInt.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrCommands.btnRandAddClick(Sender: TObject);
|
||||
var
|
||||
NewRec: TRandomCounters;
|
||||
begin
|
||||
NewRec.Name := edtRandomName.Text;
|
||||
NewRec.Ot := StrToIntDef(edtOt.Text, 0);
|
||||
NewRec.ToValue := StrToIntDef(edtTo.Text, 100);
|
||||
|
||||
SetLength(RandomCounters, Length(RandomCounters) + 1);
|
||||
RandomCounters[High(RandomCounters)] := NewRec;
|
||||
|
||||
UpdateGridFromArray;
|
||||
// DB.SaveGridToTable('sgRandomInt', sgRandomInt);
|
||||
DB.SaveRecordArray<TRandomCounters>('RandomCounters', RandomCounters);
|
||||
edtRandomName.Text := '';
|
||||
edtOt.Text := '0';
|
||||
edtTo.Text := '100';
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user