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)
- Refs: TComboBox;
- LTopic: TLabel;
- LSecName: TLabel;
- LStr: TLabel;
- LDate: TLabel;
- Topic: TEdit;
- SecName: TEdit;
- Str: TEdit;
- Date: TEdit;
- Save: TButton;
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure RefsDropDown(Sender: TObject);
- procedure RefsClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure SaveClick(Sender: TObject);
- procedure SecNameKeyPress(Sender: TObject; var Key: Char);
- procedure StrKeyPress(Sender: TObject; var Key: Char);
- procedure DateKeyPress(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.SaveClick(Sender: TObject);
- var
- i, kol: Integer;
- Temp: TRef;
- s: string;
- begin
- kol := 0;
- s := Date.Text;
- for i := 1 to length(s) do
- if s[i] = '.' then
- inc(kol);
- if kol <> 2 then
- MessageDlg('Введите дату в формате день.месяц.год', mtError, [mbOK], 0)
- else
- begin
- Inc(ChangeIndex);
- seek(MyFile, ChangeIndex - 1);
- Temp.Topic := Topic.Text;
- Temp.Author := SecName.Text;
- Temp.Str := StrToInt(Str.Text);
- Temp.Date := Date.Text;
- Write(MyFile, Temp);
- Inc(ChangeIndex);
- seek(MyFIle, ChangeIndex - 1);
- for i := n - 1 to FileSize(MyFile) - 2 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;
- Refs.Clear;
- ChangeForm.Hide;
- BaseForm.Show;
- end;
- end;
- procedure TChangeForm.RefsClick(Sender: TObject);
- begin
- Save.Visible := True;
- ChangeIndex := Refs.Items.IndexOf(Refs.Text);
- Topic.Text := Ref[ChangeIndex].Topic;
- SecName.Text := Ref[ChangeIndex].Author;
- Str.Text := IntToStr(Ref[ChangeIndex].Str);
- Date.Text := Ref[ChangeIndex].Date;
- Topic.Visible := True;
- SecName.Visible := True;
- Str.Visible := True;
- Date.Visible := True;
- LTopic.Visible := True;
- LSecName.Visible := True;
- LStr.Visible := True;
- LDate.Visible := True;
- end;
- procedure TChangeForm.RefsDropDown(Sender: TObject);
- var
- i: Integer;
- begin
- Refs.Clear;
- for i := 0 to n - 1 do
- Refs.Items.Add(Ref[i].Topic);
- end;
- procedure TChangeForm.SecNameKeyPress(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.StrKeyPress(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.DateKeyPress(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
- Refs.Clear;
- Save.Visible := False;
- Topic.Visible := False;
- SecName.Visible := False;
- Str.Visible := False;
- Date.Visible := False;
- LTopic.Visible := False;
- LSecName.Visible := False;
- LStr.Visible := False;
- LDate.Visible := False;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement