Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TEditForm.IsCorrectTextData(CurrentEdit: TEdit): boolean;
- var
- IsCorrectInput: boolean;
- TextLength, i: integer;
- begin
- isCorrectInput := false;
- TextLength := length(CurrentEdit.text);
- i := 2;
- if TextLength <= CurrentEdit.MaxLength then
- begin
- if TextLength = 0 then
- IsCorrectInput := true
- else
- begin
- if (TextLength = 1) and (CurrentEdit.text[1] in BIG_LETTERS) then
- IsCorrectInput := True
- else
- begin
- IsCorrectInput := CurrentEdit.text[1] in BIG_LETTERS;
- while IsCorrectInput and (i <= TextLength) do
- begin
- if not(CurrentEdit.text[i] in SMALL_LETTERS) then
- IsCorrectInput := false;
- inc(i);
- end;
- end;
- end;
- end;
- Result := IsCorrectInput;
- end;
- procedure TEditForm.fillStringGrid(SubscribersStringGrid: TStringGrid;
- TelephoneEdit, SurnameEdit, NameEdit,
- PatronymicEdit, CityEdit: TEdit);
- var
- i, j, ListLength: Integer;
- PCurrentSubscriber: TSubscriberPointer;
- RequiredSubscriber: TRequiredSubscriber;
- begin
- i := 1;
- j := 0;
- SubscriberList.deleteList();
- getRequiredSubscriber(RequiredSubscriber, TelephoneEdit.text, SurnameEdit.text, NameEdit.text,
- PatronymicEdit.text, CityEdit.text);
- readSubscribers(RequiredSubscriber);
- sortList();
- ListLength := SubscriberList.length();
- setlength(NumberArray, ListLength);
- PCurrentSubscriber := SubscriberList.getHeader()^.next;
- while (PCurrentSubscriber <> nil) do
- begin
- SubscribersStringGrid.RowCount := SubscribersStringGrid.RowCount + 1;
- SubscribersStringGrid.Cells[0, i] := intToStr(i);
- SubscribersStringGrid.Cells[1, i] := PCurrentSubscriber^.telephoneNumber;
- SubscribersStringGrid.Cells[2, i] := PCurrentSubscriber^.surname;
- SubscribersStringGrid.Cells[3, i] := PCurrentSubscriber^.name;
- SubscribersStringGrid.Cells[4, i] := PCurrentSubscriber^.patronymic;
- SubscribersStringGrid.Cells[5, i] := PCurrentSubscriber^.city;
- SubscribersStringGrid.Cells[6, i] := intToStr(PCurrentSubscriber^.numberOfDays);
- NumberArray[j] := PCurrentSubscriber^.number;
- Inc(i);
- inc(j);
- PCurrentSubscriber := PCurrentSubscriber^.next;
- end;
- end;
- procedure TEditForm.ClearButtonClick(Sender: TObject);
- begin
- TelephoneEdit.text := '';
- NameEdit.text := '';
- SurnameEdit.text := '';
- PatronymicEdit.text := '';
- CityEdit.text := '';
- TelephoneRButton.Checked := false;
- SurnameRButton.Checked := false;
- NameRButton.Checked := false;
- PatronymicRButton.Checked := false;
- CityRButton.Checked := false;
- DateRButton.Checked := false;
- CurrentRadioButton := 0;
- SubscribersStringGrid.RowCount := 1;
- EditButton.Enabled := false;
- DeleteButton.Enabled := false;
- end;
- procedure TEditForm.DataEditKeyPress(Sender: TObject; var Key: Char);
- begin
- if (Key <> #08) then
- begin
- if length((Sender as TEdit).text) = 0 then
- begin
- if not (Key in BIG_LETTERS) then
- Key := #0
- end
- else
- if not(Key in SMALL_LETTERS) then
- Key := #0;
- end;
- end;
- procedure TEditForm.ShowButtonClick(Sender: TObject);
- begin
- if areEditsCorrect() then
- begin
- clearStringGrid();
- if not isFileEmpty() then
- begin
- fillStringGrid(SubscribersStringGrid, TelephoneEdit, SurnameEdit, NameEdit,
- PatronymicEdit, CityEdit);
- setEditButtonsCondition();
- end
- else
- MessageDlg('Subscriber file is empty.', mtError, [mbOk], 0, mbOk);
- end
- else
- begin
- MessageDlg('Wrong data.', mtError, [mbCancel], 0);
- clearButtonClick(Sender);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement