Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit InfoUnit;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls, ClipBrd;
- type
- TTeamInfo = class(TForm)
- MainLabel: TLabel;
- NameLabel: TLabel;
- PointsLabel: TLabel;
- CountryLabel: TLabel;
- CoachLable: TLabel;
- NameEdit: TEdit;
- PointsEdit: TEdit;
- CountryEdit: TEdit;
- CoachEdit: TEdit;
- ConfirmButton: TButton;
- PopupMenu: TPopupMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- procedure InstractionClick(Sender: TObject);
- procedure CutClick(Sender: TObject);
- procedure CopyClick(Sender: TObject);
- procedure DeleteClick(Sender: TObject);
- procedure KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
- procedure StrEditPress(Sender: TObject; var Key: Char);
- procedure IntEditPress(Sender: TObject; var Key: Char);
- procedure ButtonClick(Sender: TObject);
- procedure CloseInfo(Sender: TObject; var CanClose: Boolean);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- TeamInfo: TTeamInfo;
- implementation
- {$R *.dfm}
- uses lab4_1;
- procedure TTeamInfo.ButtonClick(Sender: TObject);
- var
- temp: Integer;
- RowNum: String;
- begin
- if not((NameEdit.Text = '') or (PointsEdit.Text = '') or (CountryEdit.Text = '') or (CoachEdit.Text = '')) then
- begin
- if (MainLAbel.Caption[Length(MainLAbel.Caption)] = 'е') then
- begin
- MainForm.Enabled := True;
- MainForm.TeamSGrid.Enabled := True;
- MainForm.TeamSGrid.RowCount := MainForm.TeamSGrid.RowCount + 1;
- temp := MainForm.TeamSGrid.RowCount - 1;
- MainForm.TeamSGrid.Cells[0,temp]:= NameEdit.Text;
- MainForm.TeamSGrid.Cells[1,temp]:= PointsEdit.Text;
- MainForm.TeamSGrid.Cells[2,temp]:= CountryEdit.Text;
- MainForm.TeamSGrid.Cells[3,temp]:= CoachEdit.Text;
- NameEdit.text :='';
- PointsEdit.text := '';
- CountryEdit.text :='';
- CoachEdit.text :='';
- MainForm.Height := MainForm.Height + 24;
- MainForm.TeamSGrid.Height := MainForm.TeamSGrid.Height + 24;
- TeamInfo.Close;
- MainForm.Savetofilemenu.Enabled := True;
- MainForm.TeamSGrid.Enabled := False;
- end
- else
- begin
- MainForm.Enabled := True;
- MainForm.TeamSGrid.Enabled := True;
- RowNum := MainLabel.Caption;
- Delete(RowNum, 1, Pos('е',RowNum) + 2);
- Temp := StrToInt(RowNum);
- MainForm.TeamSGrid.Cells[0,temp]:= NameEdit.Text;
- MainForm.TeamSGrid.Cells[1,temp]:= PointsEdit.Text;
- MainForm.TeamSGrid.Cells[2,temp]:= CountryEdit.Text;
- MainForm.TeamSGrid.Cells[3,temp]:= CoachEdit.Text;
- NameEdit.text :='';
- PointsEdit.text := '';
- CountryEdit.text :='';
- CoachEdit.text :='';
- RowNum := MainLabel.Caption;
- Delete(RowNum, Length(RowNum) - 2,3);
- MainLabel.Caption := RowNum;
- MainLabel.Font.Size := 11;
- MainLabel.Left := 24;
- TeamInfo.Close;
- MainForm.Savetofilemenu.Enabled := True;
- MainForm.TeamSGrid.Enabled := False;
- end;
- end
- else
- Application.MessageBox('Заполните все ячейки!', 'Ошибка', MB_ICONERROR);
- end;
- procedure TTeamInfo.CloseInfo(Sender: TObject; var CanClose: Boolean);
- begin
- MainForm.Enabled := True;
- end;
- procedure TTeamInfo.CopyClick(Sender: TObject);
- begin
- if PopupMenu.PopupComponent = NameEdit then
- begin
- ClipBoard.AsText := NameEdit.Text;
- end;
- if PopupMenu.PopupComponent = PointsEdit then
- begin
- ClipBoard.AsText := PointsEdit.Text;
- end;
- if PopupMenu.PopupComponent = CountryEdit then
- begin
- ClipBoard.AsText := CountryEdit.Text;
- end;
- if PopupMenu.PopupComponent = CoachEdit then
- begin
- ClipBoard.AsText := CoachEdit.Text;
- end;
- end;
- procedure TTeamInfo.CutClick(Sender: TObject);
- begin
- if PopupMenu.PopupComponent = NameEdit then
- begin
- ClipBoard.AsText := NameEdit.Text;
- NameEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = PointsEdit then
- begin
- ClipBoard.AsText := PointsEdit.Text;
- PointsEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = CountryEdit then
- begin
- ClipBoard.AsText := CountryEdit.Text;
- CountryEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = CoachEdit then
- begin
- ClipBoard.AsText := CoachEdit.Text;
- CoachEdit.Text := '';
- end;
- end;
- procedure TTeamInfo.DeleteClick(Sender: TObject);
- begin
- if PopupMenu.PopupComponent = NameEdit then
- begin
- NameEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = PointsEdit then
- begin
- PointsEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = CountryEdit then
- begin
- CountryEdit.Text := '';
- end;
- if PopupMenu.PopupComponent = CoachEdit then
- begin
- CoachEdit.Text := '';
- end;
- end;
- procedure TTeamInfo.InstractionClick(Sender: TObject);
- begin
- Application.MessageBox('Заполните поля, как указано в примерах','Инструкция');
- end;
- procedure TTeamInfo.IntEditPress(Sender: TObject; var Key: Char);
- begin
- if (TEdit(Sender).Text = '0') and (Key in ['0'..'9']) then
- Key := #0;
- if not(Key in ['0'..'9', #08]) then
- Key := #0;
- if (Length(TEdit(Sender).Text) = 2) and not(Key = #08) then
- Key := #0;
- end;
- procedure TTeamInfo.KeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- begin
- TEdit(Sender).ReadOnly := (((Shift=[ssShift]) and (Key = VK_INSERT)) or (Shift=[ssCtrl]) or (Shift=[ssAlt]));
- end;
- procedure TTeamInfo.StrEditPress(Sender: TObject; var Key: Char);
- begin
- if (Length(TEdit(Sender).Text) = 15) and not(Key = #08) then
- Key := #0;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement