Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit2;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls;
- type
- TForm2 = class(TForm)
- TreeView1: TTreeView;
- NewTermin: TButton;
- NewSubTermin: TButton;
- Label1: TLabel;
- Edit1: TEdit;
- Label2: TLabel;
- Edit2: TEdit;
- AddBt: TButton;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- procedure AddBtClick(Sender: TObject);
- procedure NewTerminClick(Sender: TObject);
- procedure NewSubTerminClick(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure AddToHash(S: String);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form2: TForm2;
- Flag, n, m, kk, kkk: Integer;
- hash: array[1..10000] of String;
- implementation
- {$R *.dfm}
- procedure TForm2.AddToHash(S: String);
- var
- i, key: Integer;
- begin
- for i := 1 to length(s) do
- key := key + ord(s[i]);
- key := key mod 10000;
- hash[key] := S;
- end;
- procedure TForm2.AddBtClick(Sender: TObject);
- var
- Find: TTreeNode;
- i, j, key: Integer;
- FindFlag: Boolean;
- arr: array[1..100] of integer;
- S: String;
- begin
- if Flag = 1 then
- begin
- TreeView1.Items.Add(nil, Edit1.Text);
- AddToHash(Edit1.Text);
- TreeView1.Items.AddChild(TreeView1.Items.Item[n], 'Страница: ' + Edit2.Text);
- Inc(n, 2);
- Edit1.Visible := False;
- Label1.Visible := False;
- AddBt.Visible := False;
- end;
- if Flag = 2 then
- begin
- TreeView1.Items.AddChild(TreeView1.Selected, Edit1.Text);
- Find := TreeView1.Selected.GetLastChild;
- m := 0;
- While TreeView1.Items.Item[m] <> Find Do
- Inc(m);
- TreeView1.Items.AddChild(TreeView1.Items.Item[m], 'Страница: ' + Edit2.Text);
- Inc(n, 2);
- Edit1.Visible := False;
- Label1.Visible := False;
- AddBt.Visible := False;
- end;
- if Flag = 3 then
- begin
- TreeView1.Selected.Text := Edit1.Text;
- if TreeView1.Selected.getFirstChild.Text[1] = 'С' then
- TreeView1.Selected.getFirstChild.Text := 'Страница: ' + Edit2.Text
- else
- TreeView1.Selected.getLastChild.Text := 'Страница: ' + Edit2.Text;
- Edit1.Visible := False;
- Label1.Visible := False;
- AddBt.Visible := False;
- end;
- if Flag = 4 then
- begin
- FindFlag := False;
- for i := kkk to TreeView1.Items.Count - 1 do
- if TreeView1.Items.Item[i].Text = Edit1.Text then
- begin
- kkk := i + 1;
- TreeView1.Items.Item[i].Parent.Selected := True;
- TreeView1.SetFocus;
- FindFlag := True;
- break;
- end;
- if not(FindFlag) then
- begin
- MessageDlg('Подтермин не найден', mtError, [mbOK], 0);
- kkk := 0;
- Edit1.Visible := False;
- Label1.Visible := False;
- AddBt.Visible := False;
- AddBt.Caption := 'Добавить';
- end;
- end;
- if Flag = 5 then
- begin
- FindFlag := False;
- for i := kk to TreeView1.Items.Count - 1 do
- if TreeView1.Items.Item[i].Text = Edit1.Text then
- begin
- kk := i + 1;
- TreeView1.Items.Item[i].Selected := True;
- TreeView1.SetFocus;
- FindFlag := True;
- break;
- end;
- if not(FindFlag) then
- begin
- MessageDlg('Термин не найден', mtError, [mbOK], 0);
- kk := 0;
- Edit1.Visible := False;
- Label1.Visible := False;
- AddBt.Visible := False;
- AddBt.Caption := 'Добавить';
- end;
- end;
- Label2.Visible := False;
- Edit2.Visible := False;
- Edit2.Text := '';
- end;
- procedure TForm2.Button1Click(Sender: TObject);
- begin
- TreeView1.Selected.Delete;
- end;
- procedure TForm2.Button2Click(Sender: TObject);
- begin
- Flag := 3;
- AddBt.Caption := 'Изменить';
- Label1.Visible := True;
- Label2.Visible := True;
- Edit1.Visible := True;
- Edit2.Visible := True;
- AddBt.Visible := True;
- end;
- procedure TForm2.Button3Click(Sender: TObject);
- begin
- TreeView1.AlphaSort;
- end;
- procedure TForm2.Button4Click(Sender: TObject);
- begin
- Flag := 4;
- AddBt.Caption := 'Найти';
- Label1.Visible := True;
- Edit1.Visible := True;
- AddBt.Visible := True;
- end;
- procedure TForm2.Button5Click(Sender: TObject);
- begin
- Flag := 5;
- AddBt.Caption := 'Найти';
- Label1.Visible := True;
- Edit1.Visible := True;
- AddBt.Visible := True;
- end;
- procedure TForm2.NewSubTerminClick(Sender: TObject);
- begin
- Flag := 2;
- Label1.Visible := True;
- Label2.Visible := True;
- Edit1.Visible := True;
- Edit2.Visible := True;
- AddBt.Visible := True;
- end;
- procedure TForm2.NewTerminClick(Sender: TObject);
- begin
- Flag := 1;
- Label1.Visible := True;
- Label2.Visible := True;
- Edit1.Visible := True;
- Edit2.Visible := True;
- AddBt.Visible := True;
- end;
- end.
Add Comment
Please, Sign In to add comment