Changeset 28 for trunk/Forms/UFormRecords.pas
- Timestamp:
- Sep 10, 2022, 10:21:48 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormRecords.pas
r26 r28 16 16 AModify: TAction; 17 17 ARemove: TAction; 18 ListView 1: TListView;18 ListViewRecords: TListView; 19 19 MenuItem1: TMenuItem; 20 20 MenuItem2: TMenuItem; … … 29 29 procedure ARemoveExecute(Sender: TObject); 30 30 procedure FormShow(Sender: TObject); 31 procedure ListView 1Data(Sender: TObject; Item: TListItem);32 procedure ListView 1SelectItem(Sender: TObject; Item: TListItem;31 procedure ListViewRecordsData(Sender: TObject; Item: TListItem); 32 procedure ListViewRecordsSelectItem(Sender: TObject; Item: TListItem; 33 33 Selected: Boolean); 34 34 public … … 38 38 end; 39 39 40 var41 FormRecords: TFormRecords;42 40 43 41 implementation … … 65 63 end; 66 64 67 procedure TFormRecords.ListView 1Data(Sender: TObject; Item: TListItem);65 procedure TFormRecords.ListViewRecordsData(Sender: TObject; Item: TListItem); 68 66 var 69 67 I: Integer; … … 79 77 end; 80 78 81 procedure TFormRecords.ListView 1SelectItem(Sender: TObject; Item: TListItem;79 procedure TFormRecords.ListViewRecordsSelectItem(Sender: TObject; Item: TListItem; 82 80 Selected: Boolean); 83 81 begin … … 87 85 procedure TFormRecords.AModifyExecute(Sender: TObject); 88 86 begin 89 if Assigned(ListView1.Selected) then begin 90 FormRecord.Table := Table; 91 FormRecord.Load(TRecord(ListView1.Selected.Data)); 92 if FormRecord.ShowModal = mrOk then begin 93 FormRecord.Save(TRecord(ListView1.Selected.Data)); 94 ReloadList; 87 if Assigned(ListViewRecords.Selected) then begin 88 with TFormRecord.Create(nil) do 89 try 90 Table := Self.Table; 91 Load(TRecord(ListViewRecords.Selected.Data)); 92 if ShowModal = mrOk then begin 93 Save(TRecord(ListViewRecords.Selected.Data)); 94 ReloadList; 95 end; 96 finally 97 Free; 95 98 end; 96 99 end; … … 99 102 procedure TFormRecords.ARemoveExecute(Sender: TObject); 100 103 begin 101 if Assigned(ListView 1.Selected) then104 if Assigned(ListViewRecords.Selected) then 102 105 if MessageDlg(SRemoveRecord, SRemoveRecordConfirm, 103 106 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 104 Table.Records.Remove(ListView 1.Selected.Data);107 Table.Records.Remove(ListViewRecords.Selected.Data); 105 108 ReloadList; 106 109 end; … … 123 126 end; 124 127 125 FormRecord.Table := Table; 126 FormRecord.Load(NewRecord); 127 if FormRecord.ShowModal = mrOk then begin 128 FormRecord.Save(NewRecord); 129 Table.Records.Add(NewRecord); 130 ReloadList; 131 end else NewRecord.Free; 128 with TFormRecord.Create(nil) do 129 try 130 Table := Self.Table; 131 Load(NewRecord); 132 if ShowModal = mrOk then begin 133 Save(NewRecord); 134 Table.Records.Add(NewRecord); 135 ReloadList; 136 end else NewRecord.Free; 137 finally 138 Free; 139 end; 132 140 end; 133 141 134 142 procedure TFormRecords.UpdateInterface; 135 143 begin 136 AModify.Enabled := Assigned(ListView 1.Selected);137 ARemove.Enabled := Assigned(ListView 1.Selected);144 AModify.Enabled := Assigned(ListViewRecords.Selected); 145 ARemove.Enabled := Assigned(ListViewRecords.Selected); 138 146 end; 139 147 … … 144 152 Table.LoadRecords; 145 153 146 ListView 1.Columns.BeginUpdate;147 while ListView 1.Columns.Count > Table.Fields.Count do148 ListView 1.Columns[ListView1.ColumnCount - 1].Free;149 while ListView 1.Columns.Count < Table.Fields.Count do150 ListView 1.Columns.Add;154 ListViewRecords.Columns.BeginUpdate; 155 while ListViewRecords.Columns.Count > Table.Fields.Count do 156 ListViewRecords.Columns[ListViewRecords.ColumnCount - 1].Free; 157 while ListViewRecords.Columns.Count < Table.Fields.Count do 158 ListViewRecords.Columns.Add; 151 159 for I := 0 to Table.Fields.Count - 1 do begin 152 ListView 1.Columns[I].Caption := TField(Table.Fields[I]).TextBefore;153 ListView 1.Columns[I].Width := 200;160 ListViewRecords.Columns[I].Caption := TField(Table.Fields[I]).TextBefore; 161 ListViewRecords.Columns[I].Width := 200; 154 162 end; 155 ListView 1.Columns.EndUpdate;163 ListViewRecords.Columns.EndUpdate; 156 164 157 ListView 1.Items.Count := Table.Records.Count;158 ListView 1.Repaint;165 ListViewRecords.Items.Count := Table.Records.Count; 166 ListViewRecords.Repaint; 159 167 end; 160 168
Note:
See TracChangeset
for help on using the changeset viewer.