Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TStudent = record
- Group : integer;
- Number : byte;
- Name : string[30];
- Birth : TDateTime;
- Sex : string[1];
- end;
- procedure TAnya.Recording(Sender: TObject);
- var
- i: byte;
- begin
- with Table do
- begin
- for i := 1 to RowCount - 1 do
- with ArrayOfStudents[i - 1] do
- begin
- Group := StrToInt(Cells[0, i]);
- Number := StrToInt(Cells[1, i]);
- Name := Cells[2, i];
- Birth := StrToDate(Cells[3, i]);
- Sex := Cells[4, i];
- end;
- end;
- end;
- procedure TAnya.TableKeyPress(Sender: TObject; var Key: Char);
- const
- Numbers = ['0'..'9', #8];
- Date = Numbers + ['.'];
- var
- i, j, StrCount: byte;
- str: string[30];
- symbol: AnsiChar;
- sym: Char;
- s: string[1];
- isCorrect: boolean;
- begin
- // Recording(Sender);
- with Sender as TStringGrid do
- begin
- SetLength(ArrayOfStudents, RowCount - 1);
- if Key = #13 then
- begin
- isCorrect := true;
- for j := 1 to RowCount - 1 do
- for i := 0 to 4 do
- if Length(Cells[i, j]) < 1 then
- isCorrect := false;
- if isCorrect then
- begin
- Height := Height + 41;
- RowCount := RowCount + 1;
- Col := 0;
- Row := RowCount - 1;
- end;
- end;
- if Col = 0 then
- begin
- if (not (Key in Numbers)) then
- Key := #0;
- if (Length(Cells[0, Row]) > 5) and (Key <> #8) then
- Key := #0;
- end;
- if Col = 1 then
- begin
- if ((not (Key in Numbers)) or (Length(Cells[1, Row]) > 1) and (Key <> #8)) then
- Key := #0;
- end;
- if Col = 2 then
- begin
- if ((Key >= 'а') and (Key <= 'я')) or ((Key >= 'А') and (Key <= 'Я')) or (Key = ' ') or (Key = '.') or (Key = #8) then
- Key := Key
- else
- Key := #0;
- if (Key = '.') and (Length(Cells[2, Row]) = 0) then
- Key := #0;
- if (Length(Cells[2, Row]) > 30) and (Key <> #8) then
- Key := #0;
- end;
- if Col = 3 then
- begin
- if (Key = '.') and (Length(Cells[3, Row]) = 0) then
- Key := #0;
- Table.Options := Table.Options + [goAlwaysShowEditor];
- if (Length(Cells[3, Row]) = 2) and (Key <> #8) then
- begin
- Cells[3, Row] := Cells[3, Row] + '.';
- SetCaretPosition(Table, 3, Row, 4);
- end
- else
- if (Length(Cells[3, Row]) = 5) and (Key <> #8) then
- begin
- Cells[3, Row] := Cells[3, Row] + '.';
- SetCaretPosition(Table, 3, Row, 7);
- end;
- if ((not (Key in Date)) or ((Length(Cells[3, Row]) > 9) and (Key <> #8))) then
- Key := #0;
- end;
- if Col = 4 then
- begin
- if ((Key <> 'м') and (Key <> 'ж') and (Key <> #8)) then
- Key := #0;
- if (Length(Cells[4, Row]) > 0) and (Key <> #8) then
- Key := #0;
- end;
- if (Col <> 2) and (Length(Cells[2, Row]) > 0) then
- begin
- str := Cells[2, Row];
- s := str[1];
- s := AnsiUpperCase(s);
- str[1] := s[1];
- for i := 2 to Length(str) do
- if str[i] = ' ' then
- begin
- s := str[i + 1];
- s := AnsiUpperCase(s);
- str[i + 1] := s[1];
- end;
- Cells[2, Row] := str;
- end;
- end;
- end;
- procedure TAnya.DeleteRecordMenuItemClick(Sender: TObject);
- begin
- DeleteUnit.Delete.Show;
- Anya.Enabled := false;
- DeleteUnit.Delete.SearchingBox.SetFocus;
- DeleteUnit.Delete.ToDelete.Enabled := false;
- DeleteUnit.Delete.OkeyButton.Enabled := false;
- DeleteUnit.Delete.ToDelete.Clear;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement