Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Change;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, System.Actions, Vcl.ActnList,
- Vcl.StdCtrls;
- type
- TChangeForm = class(TForm)
- ComboBox1: TComboBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- Button1: TButton;
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure ComboBox1DropDown(Sender: TObject);
- procedure ComboBox1Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Edit2KeyPress(Sender: TObject; var Key: Char);
- procedure Edit3KeyPress(Sender: TObject; var Key: Char);
- procedure Edit4KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- ChangeForm: TChangeForm;
- ChangeIndex: Integer;
- Flag: Boolean;
- implementation
- Uses
- Base, ChangeMenu, Add, DeleteRef, Menu;
- {$R *.dfm}
- procedure TChangeForm.Button1Click(Sender: TObject);
- var
- i: Integer;
- Temp: TRef;
- begin
- Inc(ChangeIndex);
- seek(MyFile, ChangeIndex - 1);
- Temp.Topic := Edit1.Text;
- Temp.Author := Edit2.Text;
- Temp.Str := StrToInt(Edit3.Text);
- Temp.Date := Edit4.Text;
- Write(MyFile, Temp);
- for i := ChangeIndex to FileSize(MyFile) - 3 do
- begin
- seek(MyFile, i + 1);
- read(MyFile, Temp);
- seek(MyFile, i);
- Write(MyFile, Temp);
- end;
- seek(MyFile, FileSize(MyFile));
- truncate(MyFile);
- Reset(MyFile);
- i := 0;
- While not eof(MyFile) do
- begin
- Read(MyFile, Ref[i]);
- Inc(i);
- end;
- n := i;
- ComboBox1.Clear;
- ChangeForm.Hide;
- BaseForm.Show;
- end;
- procedure TChangeForm.ComboBox1Click(Sender: TObject);
- begin
- Button1.Visible := True;
- ChangeIndex := ComboBox1.Items.IndexOf(ComboBox1.Text);
- Edit1.Text := Ref[ChangeIndex].Topic;
- Edit2.Text := Ref[ChangeIndex].Author;
- Edit3.Text := IntToStr(Ref[ChangeIndex].Str);
- Edit4.Text := Ref[ChangeIndex].Date;
- Edit1.Visible := True;
- Edit2.Visible := True;
- Edit3.Visible := True;
- Edit4.Visible := True;
- Label1.Visible := True;
- Label2.Visible := True;
- Label3.Visible := True;
- Label4.Visible := True;
- end;
- procedure TChangeForm.ComboBox1DropDown(Sender: TObject);
- var
- i: Integer;
- begin
- ComboBox1.Clear;
- for i := 0 to n - 1 do
- ComboBox1.Items.Add(Ref[i].Topic);
- end;
- procedure TChangeForm.Edit2KeyPress(Sender: TObject; var Key: Char);
- const
- Digit: set of Char = ['a'..'z', #8, 'A'..'Z'];
- begin
- with (Sender as TEdit) do
- begin
- if not(Key in Digit) then
- Key := #0;
- end;
- end;
- procedure TChangeForm.Edit3KeyPress(Sender: TObject; var Key: Char);
- const
- Digit: set of Char = ['0'..'9', #8];
- begin
- with (Sender as TEdit) do
- begin
- if not(Key in Digit) then
- Key := #0;
- end;
- end;
- procedure TChangeForm.Edit4KeyPress(Sender: TObject; var Key: Char);
- const
- Digit: set of Char = ['0'..'9', #8, '.'];
- begin
- with (Sender as TEdit) do
- begin
- if not(Key in Digit) then
- Key := #0;
- end;
- end;
- procedure TChangeForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- BaseForm.Show;
- MenuForm.Hide;
- ChangeMenuForm.Hide;
- AddForm.Hide;
- DeleteForm.Hide;
- ChangeForm.Hide;
- end;
- procedure TChangeForm.FormShow(Sender: TObject);
- begin
- ComboBox1.Clear;
- Button1.Visible := False;
- Edit1.Visible := False;
- Edit2.Visible := False;
- Edit3.Visible := False;
- Edit4.Visible := False;
- Label1.Visible := False;
- Label2.Visible := False;
- Label3.Visible := False;
- Label4.Visible := False;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement