Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. type
  2. TStudent = record
  3. Group : integer;
  4. Number : byte;
  5. Name : string[30];
  6. Birth : TDateTime;
  7. Sex : string[1];
  8. end;
  9.  
  10. procedure TAnya.Recording(Sender: TObject);
  11. var
  12. i: byte;
  13. begin
  14. with Table do
  15. begin
  16. for i := 1 to RowCount - 1 do
  17. with ArrayOfStudents[i - 1] do
  18. begin
  19. Group := StrToInt(Cells[0, i]);
  20. Number := StrToInt(Cells[1, i]);
  21. Name := Cells[2, i];
  22. Birth := StrToDate(Cells[3, i]);
  23. Sex := Cells[4, i];
  24. end;
  25. end;
  26. end;
  27.  
  28.  
  29. procedure TAnya.TableKeyPress(Sender: TObject; var Key: Char);
  30. const
  31. Numbers = ['0'..'9', #8];
  32. Date = Numbers + ['.'];
  33. var
  34. i, j, StrCount: byte;
  35. str: string[30];
  36. symbol: AnsiChar;
  37. sym: Char;
  38. s: string[1];
  39. isCorrect: boolean;
  40. begin
  41. // Recording(Sender);
  42. with Sender as TStringGrid do
  43. begin
  44. SetLength(ArrayOfStudents, RowCount - 1);
  45. if Key = #13 then
  46. begin
  47. isCorrect := true;
  48. for j := 1 to RowCount - 1 do
  49. for i := 0 to 4 do
  50. if Length(Cells[i, j]) < 1 then
  51. isCorrect := false;
  52. if isCorrect then
  53. begin
  54. Height := Height + 41;
  55. RowCount := RowCount + 1;
  56. Col := 0;
  57. Row := RowCount - 1;
  58. end;
  59. end;
  60. if Col = 0 then
  61. begin
  62. if (not (Key in Numbers)) then
  63. Key := #0;
  64. if (Length(Cells[0, Row]) > 5) and (Key <> #8) then
  65. Key := #0;
  66. end;
  67. if Col = 1 then
  68. begin
  69. if ((not (Key in Numbers)) or (Length(Cells[1, Row]) > 1) and (Key <> #8)) then
  70. Key := #0;
  71. end;
  72. if Col = 2 then
  73. begin
  74. if ((Key >= 'а') and (Key <= 'я')) or ((Key >= 'А') and (Key <= 'Я')) or (Key = ' ') or (Key = '.') or (Key = #8) then
  75. Key := Key
  76. else
  77. Key := #0;
  78. if (Key = '.') and (Length(Cells[2, Row]) = 0) then
  79. Key := #0;
  80. if (Length(Cells[2, Row]) > 30) and (Key <> #8) then
  81. Key := #0;
  82. end;
  83. if Col = 3 then
  84. begin
  85. if (Key = '.') and (Length(Cells[3, Row]) = 0) then
  86. Key := #0;
  87. Table.Options := Table.Options + [goAlwaysShowEditor];
  88. if (Length(Cells[3, Row]) = 2) and (Key <> #8) then
  89. begin
  90. Cells[3, Row] := Cells[3, Row] + '.';
  91. SetCaretPosition(Table, 3, Row, 4);
  92. end
  93. else
  94. if (Length(Cells[3, Row]) = 5) and (Key <> #8) then
  95. begin
  96. Cells[3, Row] := Cells[3, Row] + '.';
  97. SetCaretPosition(Table, 3, Row, 7);
  98. end;
  99. if ((not (Key in Date)) or ((Length(Cells[3, Row]) > 9) and (Key <> #8))) then
  100. Key := #0;
  101. end;
  102. if Col = 4 then
  103. begin
  104. if ((Key <> 'м') and (Key <> 'ж') and (Key <> #8)) then
  105. Key := #0;
  106. if (Length(Cells[4, Row]) > 0) and (Key <> #8) then
  107. Key := #0;
  108. end;
  109. if (Col <> 2) and (Length(Cells[2, Row]) > 0) then
  110. begin
  111. str := Cells[2, Row];
  112. s := str[1];
  113. s := AnsiUpperCase(s);
  114. str[1] := s[1];
  115. for i := 2 to Length(str) do
  116. if str[i] = ' ' then
  117. begin
  118. s := str[i + 1];
  119. s := AnsiUpperCase(s);
  120. str[i + 1] := s[1];
  121. end;
  122. Cells[2, Row] := str;
  123. end;
  124. end;
  125. end;
  126.  
  127.  
  128. procedure TAnya.DeleteRecordMenuItemClick(Sender: TObject);
  129. begin
  130. DeleteUnit.Delete.Show;
  131. Anya.Enabled := false;
  132. DeleteUnit.Delete.SearchingBox.SetFocus;
  133. DeleteUnit.Delete.ToDelete.Enabled := false;
  134. DeleteUnit.Delete.OkeyButton.Enabled := false;
  135. DeleteUnit.Delete.ToDelete.Clear;
  136. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement