Changeset 20 for trunk/Forms/UFormTables.pas
- Timestamp:
- Mar 23, 2018, 1:59:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormTables.pas
r15 r20 45 45 Selected: Boolean); 46 46 private 47 FDatabase: TDatabase; 48 procedure SetDatabase(AValue: TDatabase); 49 { private declarations } 47 FTables: TTables; 48 procedure SetTables(AValue: TTables); 50 49 public 51 property Database: TDatabase read FDatabase write SetDatabase;50 property Tables: TTables read FTables write SetTables; 52 51 procedure UpdateInterface; 53 52 procedure ReloadList; … … 74 73 procedure TFormTables.ListView1Data(Sender: TObject; Item: TListItem); 75 74 begin 76 if (Item.Index >= 0) and (Item.Index < Database.Tables.Count) then77 with TTable( Database.Tables[Item.Index]) do begin75 if (Item.Index >= 0) and (Item.Index < FTables.Count) then 76 with TTable(FTables[Item.Index]) do begin 78 77 Item.Caption := Caption; 79 78 Item.SubItems.Add(IntToStr(RecordsCount)); 80 Item.Data := Database.Tables[Item.Index];79 Item.Data := FTables[Item.Index]; 81 80 end 82 81 end; … … 88 87 end; 89 88 90 procedure TFormTables.Set Database(AValue: TDatabase);91 begin 92 if F Database= AValue then Exit;93 F Database:= AValue;89 procedure TFormTables.SetTables(AValue: TTables); 90 begin 91 if FTables = AValue then Exit; 92 FTables := AValue; 94 93 ReloadList; 95 94 end; … … 97 96 procedure TFormTables.UpdateInterface; 98 97 begin 99 ListView1.Enabled := Assigned( Database);100 AAdd.Enabled := Assigned( Database);101 AModify.Enabled := Assigned( Database) and Assigned(ListView1.Selected);102 ARemove.Enabled := Assigned( Database) and Assigned(ListView1.Selected);103 AShowRecords.Enabled := Assigned( Database) and Assigned(ListView1.Selected);104 AShowFields.Enabled := Assigned( Database) and Assigned(ListView1.Selected);98 ListView1.Enabled := Assigned(Tables); 99 AAdd.Enabled := Assigned(Tables); 100 AModify.Enabled := Assigned(Tables) and Assigned(ListView1.Selected); 101 ARemove.Enabled := Assigned(Tables) and Assigned(ListView1.Selected); 102 AShowRecords.Enabled := Assigned(Tables) and Assigned(ListView1.Selected); 103 AShowFields.Enabled := Assigned(Tables) and Assigned(ListView1.Selected); 105 104 end; 106 105 … … 111 110 NewTable := TTable.Create; 112 111 NewTable.Name := SNewTable; 113 NewTable.D atabase := Database;112 NewTable.DbClient := Tables.DbClient; 114 113 FormTable.Load(NewTable); 115 114 if FormTable.ShowModal = mrOk then begin 116 115 FormTable.Save(NewTable); 117 Database.Tables.Add(NewTable);116 Tables.Add(NewTable); 118 117 ReloadList; 119 118 end else NewTable.Free; … … 136 135 if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView1.Selected.Data).Name]), 137 136 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 138 Database.Tables.Remove(ListView1.Selected.Data);137 Tables.Remove(ListView1.Selected.Data); 139 138 ReloadList; 140 139 end; … … 202 201 procedure TFormTables.FormClose(Sender: TObject; var CloseAction: TCloseAction); 203 202 begin 204 Database.Save;203 //Tables.DbClient.Save; 205 204 end; 206 205 … … 218 217 I: Integer; 219 218 begin 220 for I := 0 to Database.Tables.Count - 1 do221 TTable( Database.Tables[I]).LoadRecordsCount;222 if Assigned( Database) then begin223 ListView1.Items.Count := Database.Tables.Count;219 for I := 0 to Tables.Count - 1 do 220 TTable(Tables[I]).LoadRecordsCount; 221 if Assigned(Tables) then begin 222 ListView1.Items.Count := Tables.Count; 224 223 ListView1.Repaint; 225 224 end else ListView1.Items.Count := 0;
Note:
See TracChangeset
for help on using the changeset viewer.