Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Base;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.Menus, Vcl.StdCtrls;
- type
- TBaseForm = class(TForm)
- Data: TStringGrid;
- MainMenu1: TMainMenu;
- About: TMenuItem;
- Update: TMenuItem;
- Find: TButton;
- Ans: TMemo;
- procedure FormCreate(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure UpdateClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure AboutClick(Sender: TObject);
- procedure FindClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- BaseForm: TBaseForm;
- implementation
- Uses
- Menu, ChangeMenu, Add, DeleteRef, Change;
- {$R *.dfm}
- procedure TBaseForm.FindClick(Sender: TObject);
- var
- a, b: array of TRef;
- i, k, j, l, r: Integer;
- s, sDay, sMonth: String;
- Day, Month: array of Byte;
- TempDay, TempMonth: Byte;
- Temp: TRef;
- begin
- for i := 0 to n - 1 do
- begin
- s := Ref[i].Date;
- k := 2;
- while k > 0 do
- begin
- if s[1] = '.' then
- Dec(k);
- delete(s, 1, 1);
- end;
- if s = '2021' then
- begin
- SetLength(a, Length(a) + 1);
- a[High(a)] := Ref[i];
- end;
- end;
- for i := 0 to High(a) do
- if a[i].Str <= 20 then
- begin
- SetLength(b, Length(b) + 1);
- SetLength(Day, Length(Day) + 1);
- SetLength(Month, Length(Month) + 1);
- b[High(b)] := a[i];
- s := a[i].Date;
- k := 2;
- sDay := '';
- sMonth := '';
- while k > 0 do
- begin
- if s[1] = '.' then
- Dec(k)
- else
- if k = 2 then
- sDay := sDay + s[1]
- else
- SMonth := sMonth + s[1];
- delete(s, 1, 1);
- end;
- Day[High(Day)] := StrToInt(sDay);
- Month[High(Month)] := StrToInt(sMonth);
- end;
- for i := 0 to High(b) - 1 do
- for j := i to High(b) - i do
- if Month[i] > Month[j] then
- begin
- Temp := b[i];
- b[i] := b[j];
- b[j] := Temp;
- TempDay := Day[i];
- Day[i] := Day[j];
- Day[j] := TempDay;
- TempMonth := Month[i];
- Month[i] := Month[j];
- Month[j] := TempMonth;
- end;
- l := 0;
- r := 0;
- while l <= High(b) do
- begin
- while (Month[l] = Month[r]) and (r < Length(b)) do
- Inc(r);
- Dec(r);
- for i := l to r - 1 do
- for j := i to r - i do
- if Day[i] > Day[j] then
- begin
- Temp := b[i];
- b[i] := b[j];
- b[j] := Temp;
- TempDay := Day[i];
- Day[i] := Day[j];
- Day[j] := TempDay;
- TempMonth := Month[i];
- Month[i] := Month[j];
- Month[j] := TempMonth;
- end;
- Inc(r);
- l := r;
- end;
- Ans.Lines.Clear;
- for i := 0 to High(b) do
- begin
- s := b[i].Topic;
- s := s + ' ' + b[i].Author;
- s := s + ' ' + IntToStr(b[i].Str);
- s := s + ' ' + b[i].Date;
- Ans.Lines.Add(s);
- end;
- ShowMessage(Ans.Text);
- end;
- procedure TBaseForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- CanClose := MessageDlg('Вы уверены, что хотите выйти из программы?' +
- #10#13 + 'Все несохраненные данные будут утеряны.',
- mtConfirmation, [mbYes, mbNo], 0) = mrYes;
- MenuForm.Close;
- ChangeMenuForm.Close;
- AddForm.Close;
- DeleteForm.Close;
- ChangeForm.Close;
- end;
- procedure TBaseForm.FormCreate(Sender: TObject);
- begin
- Data.Cells[0, 0] := 'Тема';
- Data.Cells[1, 0] := 'Фамилия';
- Data.Cells[2, 0] := 'Кол-во страниц';
- Data.Cells[3, 0] := 'Дата страниц';
- end;
- procedure TBaseForm.FormShow(Sender: TObject);
- var
- i: Integer;
- begin
- Data.RowCount := n + 1;
- for i := 0 to n - 1 do
- begin
- Data.Cells[0, i + 1] := Ref[i].Topic;
- Data.Cells[1, i + 1] := Ref[i].Author;
- Data.Cells[2, i + 1] := IntToStr(Ref[i].Str);
- Data.Cells[3, i + 1] := Ref[i].Date;
- end;
- if n <> 0 then
- Data.Rows[n + 1].Clear
- else
- Data.Rows[1].Clear;
- end;
- procedure TBaseForm.AboutClick(Sender: TObject);
- var
- Info: String;
- begin
- Info := 'База данных о рефератах с возможностью редактирования' + #10#13 +
- 'Кнопка "Найти" показывает ведения о рефератах, написанных в текущем году с количеством страниц не более 20 в порядке дат написания '
- + #10#13 + 'Автор - Пестунов Илья, гр. 051007';
- MessageDlg(Info, mtInformation, [mbOK], 0);
- end;
- procedure TBaseForm.UpdateClick(Sender: TObject);
- var
- i: Integer;
- begin
- BaseForm.Hide;
- ChangeMenuForm.Show;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement