123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- unit editlearningformunit;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Spin,
- ButtonPanel, database, LCLTranslator;
- type
- { TEditLearningForm }
- TEditLearningForm = class(TForm)
- ResultButtonPanel: TButtonPanel;
- NoteEdit: TEdit;
- NoteLabel: TLabel;
- SkillComboBox: TComboBox;
- SkillLabel: TLabel;
- LevelLabel: TLabel;
- LevelSpinEdit: TSpinEdit;
- procedure CancelButtonClick(Sender: TObject);
- procedure LevelSpinEditChange(Sender: TObject);
- procedure NoteEditChange(Sender: TObject);
- procedure OKButtonClick(Sender: TObject);
- procedure SkillComboBoxChange(Sender: TObject);
- procedure FillItems;
- private
- ResultWasAccepted: Boolean;
- Db: TDatabase;
- public
- SelectedSkillId: Integer;
- SelectedLevel: Integer;
- SelectedNote: String;
- function ShowLearningEdit(ADb: TDatabase; ASkillLevel: Integer = 1; ASkillId: Integer = 1; ANote: String = ''): Boolean;
- end;
- var
- EditLearningForm: TEditLearningForm;
- implementation
- {$R *.lfm}
- { TEditLearningForm }
- procedure TEditLearningForm.SkillComboBoxChange(Sender: TObject);
- begin
- SelectedSkillId := SkillComboBox.ItemIndex + 1;
- end;
- procedure TEditLearningForm.FillItems;
- var
- SkillNames: TStringList;
- begin
- if Db = nil then begin
- SkillComboBox.Items.Clear;
- Exit
- end;
- SkillNames := Db.GetNames(Db.Skills);
- try
- SkillComboBox.Items.Assign(SkillNames);
- finally
- SkillNames.Free;
- end;
- end;
- function TEditLearningForm.ShowLearningEdit(ADb: TDatabase;
- ASkillLevel: Integer = 1; ASkillId: Integer = 1; ANote: String = ''): Boolean;
- begin
- ResultWasAccepted := False;
- Db := ADb;
- LevelSpinEdit.Value := ASkillLevel;
- SelectedLevel := ASkillLevel;
- FillItems;
- SkillComboBox.ItemIndex := ASkillId - 1;
- SelectedSkillId := ASkillId;
- NoteEdit.Text := ANote;
- SelectedNote := ANote;
- ShowModal;
- ShowLearningEdit := ResultWasAccepted
- end;
- procedure TEditLearningForm.OKButtonClick(Sender: TObject);
- begin
- ResultWasAccepted := True;
- Close
- end;
- procedure TEditLearningForm.CancelButtonClick(Sender: TObject);
- begin
- ResultWasAccepted := False;
- Close
- end;
- procedure TEditLearningForm.LevelSpinEditChange(Sender: TObject);
- begin
- SelectedLevel := LevelSpinEdit.Value;
- end;
- procedure TEditLearningForm.NoteEditChange(Sender: TObject);
- begin
- SelectedNote := NoteEdit.Text;
- end;
- end.
|