Changeset 31 for trunk/Forms
- Timestamp:
- Nov 24, 2011, 10:03:48 AM (13 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UItemAdd.pas
r22 r31 28 28 { private declarations } 29 29 public 30 SelectedObject: TChronisObject; 31 SelectedItemId: Integer; 30 32 Report: TReport; 31 33 end; … … 59 61 for I := 0 to Report.Columns.Count - 1 do 60 62 if not (TReportColumn(Report.Columns[I]).CustomType is TDataTypeRelationMany) then 61 if TReportColumn(Report.Columns[I]).ColumnName <> MainForm.SelectedObject.PrimaryKey then begin63 if TReportColumn(Report.Columns[I]).ColumnName <> SelectedObject.PrimaryKey then begin 62 64 DataType := TReportColumn(Report.Columns[I]).CustomType; 63 65 Data.Add(TReportColumn(Report.Columns[I]).ColumnName, 64 66 DataType.GetControlValue(TWinControl(TReportColumn(Report.Columns[I]).Control))); 65 67 end; 66 Database.Insert( MainForm.SelectedObject.Table, Data, MainForm.SelectedObject.Schema);68 Database.Insert(SelectedObject.Table, Data, SelectedObject.Schema); 67 69 finally 68 70 Data.Free; 69 71 end; 70 MainForm.LoadItemList;72 //MainForm.LoadItemList; 71 73 Close; 72 74 end; … … 82 84 Report := TReport.Create; 83 85 Report.Base := Core.System; 86 SelectedObject := TChronisObject.Create; 87 SelectedObject.Base := Core.System; 84 88 end; 85 89 … … 87 91 begin 88 92 Report.Free; 93 SelectedObject.Free; 89 94 end; 90 95 … … 113 118 Panel1.Controls[I].Free; 114 119 115 Report.Load( MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' +116 IntToStr( MainForm.SelectedItem));120 Report.Load(SelectedObject, SelectedObject.PrimaryKey + ' = ' + 121 IntToStr(SelectedItemId)); 117 122 118 123 // Load column names -
trunk/Forms/UItemEdit.lfm
r30 r31 131 131 Width = 67 132 132 Caption = 'Delete' 133 Enabled = False 133 134 OnClick = ButtonDeleteClick 134 135 TabOrder = 1 … … 140 141 Width = 64 141 142 Caption = 'View' 143 Enabled = False 142 144 OnClick = ButtonViewClick 143 145 TabOrder = 2 … … 149 151 Width = 62 150 152 Caption = 'Edit' 153 Enabled = False 151 154 OnClick = ButtonEditClick 152 155 TabOrder = 3 -
trunk/Forms/UItemEdit.pas
r30 r31 46 46 procedure TabControl1Change(Sender: TObject); 47 47 private 48 SelectedItem: Integer;49 48 SubListObject: TChronisObject; 50 49 TabObjectList: TListInteger; … … 52 51 procedure LoadSubList; 53 52 public 53 SelectedObject: TChronisObject; 54 SelectedItemId: Integer; 54 55 Report: TReport; 55 56 procedure BuildControls; … … 88 89 procedure TItemEditForm.ButtonAddClick(Sender: TObject); 89 90 begin 90 if Assigned(ListView1.Selected) then 91 ItemAddForm.Show; 91 ItemAddForm.Show; 92 92 end; 93 93 … … 99 99 with TReportLine(Report[Item.Index]) do begin 100 100 Item.Caption := Items[0]; 101 Item.Data := Pointer(Id); 101 102 for I := 1 to Items.Count - 1 do 102 103 if not TReportColumn(Report.Columns[I]).VirtualItem then … … 127 128 for I := 0 to Report.Columns.Count - 1 do 128 129 if not (TReportColumn(Report.Columns[I]).CustomType is TDataTypeRelationMany) then 129 if TReportColumn(Report.Columns[I]).ColumnName <> MainForm.SelectedObject.PrimaryKey then begin130 if TReportColumn(Report.Columns[I]).ColumnName <> SelectedObject.PrimaryKey then begin 130 131 DataType := TReportColumn(Report.Columns[I]).CustomType; 131 132 Data.Add(TReportColumn(Report.Columns[I]).ColumnName, 132 133 DataType.GetControlValue(TWinControl(TReportColumn(Report.Columns[I]).Control))); 133 134 end; 134 Database.Update( MainForm.SelectedObject.Table, Data,135 '`' + MainForm.SelectedObject.PrimaryKey + '` = ' + IntToStr(MainForm.SelectedItem), MainForm.SelectedObject.Schema);135 Database.Update(SelectedObject.Table, Data, 136 '`' + SelectedObject.PrimaryKey + '` = ' + IntToStr(SelectedItemId), SelectedObject.Schema); 136 137 finally 137 138 Data.Free; 138 139 end; 139 if ( MainForm.SelectedObject.Table = ObjectGroupTable) or140 ( MainForm.SelectedObject.Table = ObjectTable) then140 if (SelectedObject.Table = ObjectGroupTable) or 141 (SelectedObject.Table = ObjectTable) then 141 142 MainForm.LoadTree; 142 MainForm.LoadItemList;143 //MainForm.LoadItemList; 143 144 Close; 144 145 end; … … 166 167 TabDataTypeList.OwnsObjects := False; 167 168 TabControl1.Tabs.Clear; 169 SelectedObject := TChronisObject.Create; 170 SelectedObject.Base := Core.System; 168 171 end; 169 172 … … 174 177 TabObjectList.Free; 175 178 TabDataTypeList.Free; 179 SelectedObject.Free; 176 180 end; 177 181 … … 197 201 LastTop := 8; 198 202 Column := 0; 199 Report.Load( MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' +200 IntToStr( MainForm.SelectedItem));203 Report.Load(SelectedObject, SelectedObject.PrimaryKey + ' = ' + 204 IntToStr(SelectedItemId)); 201 205 202 206 // Clear previous controls on panel … … 215 219 TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption); 216 220 TabDataTypeList.Add(DataType); 217 TabObjectList.Add( MainForm.SelectedItem);221 TabObjectList.Add(SelectedItemId); 218 222 end else begin 219 223 NewControl := TLabel.Create(Panel1); … … 270 274 Selected: Boolean); 271 275 begin 272 if Assigned(ListView1.Selected) then273 SelectedItem := TReportLine(Report[ListView1.Selected.Index]).Id274 else SelectedItem := 0;275 276 276 ButtonDelete.Enabled := Assigned(ListView1.Selected); 277 277 ButtonView.Enabled := Assigned(ListView1.Selected); -
trunk/Forms/UItemView.pas
r30 r31 40 40 { private declarations } 41 41 public 42 SelectedObject: TChronisObject; 43 SelectedItemId: Integer; 42 44 Report: TReport; 43 45 procedure BuildControls; … … 72 74 TabDataTypeList.OwnsObjects := False; 73 75 TabControl1.Tabs.Clear; 76 SelectedObject := TChronisObject.Create; 77 SelectedObject.Base := Core.System; 74 78 end; 75 79 … … 80 84 TabObjectList.Free; 81 85 TabDataTypeList.Free; 86 SelectedObject.Free; 82 87 end; 83 88 … … 98 103 99 104 procedure TItemViewForm.ButtonEditClick(Sender: TObject); 105 var 106 NewItemEditForm: TItemEditForm; 100 107 begin 101 108 Close; 102 ItemEditForm.Show; 109 NewItemEditForm := TItemEditForm.Create(nil); 110 NewItemEditForm.SelectedObject.Assign(SelectedObject); 111 NewItemEditForm.SelectedItemId := SelectedItemId; 112 MainForm.AddTabForm(NewItemEditForm); 103 113 end; 104 114 … … 135 145 LastTop := 8; 136 146 Column := 0; 137 Report.Load( MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' +138 IntToStr( MainForm.SelectedItem));147 Report.Load(SelectedObject, SelectedObject.PrimaryKey + ' = ' + 148 IntToStr(SelectedItemId)); 139 149 for I := PanelControls.ControlCount - 1 downto 0 do 140 150 PanelControls.Controls[I].Free; … … 152 162 TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption); 153 163 TabDataTypeList.Add(DataType); 154 TabObjectList.Add( MainForm.SelectedItem);164 TabObjectList.Add(SelectedItemId); 155 165 end else begin 156 166 NewControl := TLabel.Create(PanelControls); -
trunk/Forms/UMainForm.lfm
r30 r31 180 180 TabOrder = 0 181 181 OnChange = TreeView1Change 182 OnDblClick = TreeView1DblClick 182 183 Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] 183 184 end … … 193 194 ClientWidth = 451 194 195 TabOrder = 1 195 object Label2: TLabel 196 Left = 2 197 Height = 14 198 Top = 4 199 Width = 43 200 Caption = 'Reports:' 201 ParentColor = False 202 end 203 object ListView1: TListView 204 Left = 2 205 Height = 371 206 Top = 19 207 Width = 447 208 Anchors = [akTop, akLeft, akRight, akBottom] 209 Columns = <> 210 OwnerData = True 211 PopupMenu = PopupMenuItem 212 ReadOnly = True 213 RowSelect = True 196 object PageControl1: TPageControl 197 Left = 0 198 Height = 427 199 Top = 0 200 Width = 451 201 Align = alClient 214 202 TabOrder = 0 215 ViewStyle = vsReport216 OnData = ListView1Data217 OnDblClick = ListView1DblClick218 OnKeyPress = ListView1KeyPress219 OnResize = ListView1Resize220 OnSelectItem = ListView1SelectItem221 end222 object ButtonAdd: TButton223 Left = 3224 Height = 25225 Top = 398226 Width = 75227 Action = AItemAdd228 Anchors = [akLeft, akBottom]229 TabOrder = 1230 end231 object ButtonDelete: TButton232 Left = 83233 Height = 25234 Top = 398235 Width = 75236 Action = AItemDelete237 Anchors = [akLeft, akBottom]238 TabOrder = 2239 end240 object ButtonView: TButton241 Left = 163242 Height = 25243 Top = 398244 Width = 75245 Action = AItemView246 Anchors = [akLeft, akBottom]247 TabOrder = 3248 end249 object ButtonEdit: TButton250 Left = 243251 Height = 25252 Top = 398253 Width = 75254 Action = AItemEdit255 Anchors = [akLeft, akBottom]256 TabOrder = 4257 203 end 258 204 end … … 267 213 left = 360 268 214 top = 120 269 object AItemDelete: TAction270 Category = 'Item'271 Caption = 'Delete'272 OnExecute = AItemDeleteExecute273 ShortCut = 16452274 end275 object AItemAdd: TAction276 Category = 'Item'277 Caption = 'Add'278 OnExecute = AItemAddExecute279 ShortCut = 16449280 end281 object AItemEdit: TAction282 Category = 'Item'283 Caption = 'Edit'284 OnExecute = AItemEditExecute285 ShortCut = 16453286 end287 object AItemView: TAction288 Category = 'Item'289 Caption = 'View'290 OnExecute = AItemViewExecute291 ShortCut = 16470292 end293 215 object AObjectGroupDelete: TAction 294 216 Category = 'ObjectGroup' … … 356 278 top = 120 357 279 object MenuItem1: TMenuItem 358 Action = AItemView280 Caption = 'View' 359 281 Default = True 360 OnClick = AItemViewExecute282 ShortCut = 16470 361 283 end 362 284 object MenuItem4: TMenuItem 363 Action = AItemEdit364 OnClick = AItemEditExecute285 Caption = 'Edit' 286 ShortCut = 16453 365 287 end 366 288 object MenuItem3: TMenuItem 367 Action = AItemDelete 289 Caption = 'Delete' 290 ShortCut = 16452 368 291 end 369 292 object MenuItem2: TMenuItem 370 Action = AItemAdd371 OnClick = AItemAddExecute293 Caption = 'Add' 294 ShortCut = 16449 372 295 end 373 296 end -
trunk/Forms/UMainForm.lrt
r30 r31 1 1 TMAINFORM.CAPTION=ChronIS 2 2 TMAINFORM.LABEL1.CAPTION=Groups: 3 TMAINFORM.LABEL2.CAPTION=Reports:4 TMAINFORM.AITEMDELETE.CAPTION=Delete5 TMAINFORM.AITEMADD.CAPTION=Add6 TMAINFORM.AITEMEDIT.CAPTION=Edit7 TMAINFORM.AITEMVIEW.CAPTION=View8 3 TMAINFORM.AOBJECTGROUPDELETE.CAPTION=Delete 9 4 TMAINFORM.AOBJECTGROUPADDGROUP.CAPTION=Add group … … 21 16 TMAINFORM.AABOUT.CAPTION=About 22 17 TMAINFORM.ADISCONNECT.CAPTION=Disconnect 18 TMAINFORM.MENUITEM1.CAPTION=View 19 TMAINFORM.MENUITEM4.CAPTION=Edit 20 TMAINFORM.MENUITEM3.CAPTION=Delete 21 TMAINFORM.MENUITEM2.CAPTION=Add 23 22 TMAINFORM.MENUITEM13.CAPTION=Server 24 23 TMAINFORM.MENUITEM11.CAPTION=View -
trunk/Forms/UMainForm.pas
r30 r31 29 29 AObjectGroupAddGroup: TAction; 30 30 AObjectGroupDelete: TAction; 31 AItemView: TAction;32 AItemEdit: TAction;33 AItemAdd: TAction;34 AItemDelete: TAction;35 31 ActionListItem: TActionList; 36 ButtonEdit: TButton;37 ButtonView: TButton;38 ButtonAdd: TButton;39 ButtonDelete: TButton;40 32 ImageListActions: TImageList; 41 33 Label1: TLabel; 42 Label2: TLabel;43 ListView1: TListView;44 34 MainMenu1: TMainMenu; 45 35 MenuItem1: TMenuItem; … … 64 54 MenuItem8: TMenuItem; 65 55 MenuItem9: TMenuItem; 56 PageControl1: TPageControl; 66 57 Panel1: TPanel; 67 58 Panel2: TPanel; … … 76 67 procedure AExitExecute(Sender: TObject); 77 68 procedure AImportStructureExecute(Sender: TObject); 78 procedure AItemAddExecute(Sender: TObject);79 procedure AItemDeleteExecute(Sender: TObject);80 procedure AItemEditExecute(Sender: TObject);81 procedure AItemViewExecute(Sender: TObject);82 69 procedure AObjectEditExecute(Sender: TObject); 83 70 procedure AObjectGroupAddGroupExecute(Sender: TObject); … … 85 72 procedure ASettingsExecute(Sender: TObject); 86 73 procedure AToggleFullscreenExecute(Sender: TObject); 87 procedure ButtonAddClick(Sender: TObject);88 74 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 89 75 procedure FormCreate(Sender: TObject); 90 76 procedure FormDestroy(Sender: TObject); 91 77 procedure FormShow(Sender: TObject); 92 procedure ListView1Data(Sender: TObject; Item: TListItem);93 procedure ListView1DblClick(Sender: TObject);94 procedure ListView1KeyPress(Sender: TObject; var Key: char);95 procedure ListView1Resize(Sender: TObject);96 procedure ListView1SelectItem(Sender: TObject; Item: TListItem;97 Selected: Boolean);98 78 procedure MenuItem17Click(Sender: TObject); 99 79 procedure MenuItem19Click(Sender: TObject); 100 80 procedure TreeView1Change(Sender: TObject; Node: TTreeNode); 81 procedure TreeView1DblClick(Sender: TObject); 101 82 private 102 83 OriginalBounds: TRect; … … 106 87 procedure SaveToRegistry; 107 88 public 108 SelectedObjectId: Integer;109 SelectedObject: TChronisObject;110 SelectedItem: Integer;111 89 PersistentForm: TPersistentForm; 112 90 TreeState: TTreeState; 113 91 Report: TReport; 92 TabForms: TListObject; // TListObject<TForm> 114 93 procedure UpdateInterface; 115 94 procedure LoadTree; 116 procedure LoadItemList;117 end; 95 procedure AddTabForm(Form: TForm); 96 end; 118 97 119 98 var … … 132 111 uses 133 112 UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo, 134 UCore, UImportStructureForm, UAboutForm, ULoginProfileForm, UChronisClientDirect; 113 UCore, UImportStructureForm, UAboutForm, ULoginProfileForm, UChronisClientDirect, 114 UItemList; 135 115 136 116 {$R *.lfm} … … 175 155 procedure TMainForm.FormCreate(Sender: TObject); 176 156 begin 157 TabForms := TListObject.Create; 158 TabForms.OwnsObjects := False; 177 159 TreeState := TTreeState.Create; 178 160 Report := TReport.Create; 179 161 Report.Base := Core.System; 180 SelectedObject := TChronisObject.Create;181 SelectedObject.Base := Core.System;182 162 PersistentForm := TPersistentForm.Create; 183 163 PersistentForm.RegistryKey := Core.RegistryKey; … … 189 169 TreeState.Free; 190 170 PersistentForm.Free; 171 TabForms.Free; 191 172 end; 192 173 193 174 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 194 175 begin 176 ADisconnect.Execute; 195 177 PersistentForm.Save(Self); 196 178 SaveToRegistry; 197 179 end; 198 180 199 procedure TMainForm.ButtonAddClick(Sender: TObject);200 begin201 202 end;203 204 procedure TMainForm.AItemViewExecute(Sender: TObject);205 begin206 if Assigned(ListView1.Selected) then207 ItemViewForm.Show;208 end;209 210 181 procedure TMainForm.AObjectEditExecute(Sender: TObject); 211 182 begin 212 if Assigned(TreeView1.Selected) then begin183 (* if Assigned(TreeView1.Selected) then begin 213 184 SelectedObjectId := 9; 214 185 SelectedItem := Integer(TreeView1.Selected.Data); 215 186 ItemEditForm.Show; 216 end; 187 end;*) 217 188 end; 218 189 … … 224 195 procedure TMainForm.AObjectGroupEditExecute(Sender: TObject); 225 196 begin 226 if Assigned(TreeView1.Selected) then begin197 (* if Assigned(TreeView1.Selected) then begin 227 198 SelectedObjectId := 8; 228 199 SelectedItem := Integer(TreeView1.Selected.Data); 229 200 ItemEditForm.Show; 230 end; 201 end;*) 231 202 end; 232 203 … … 263 234 end; 264 235 265 procedure TMainForm.AItemEditExecute(Sender: TObject);266 begin267 ItemEditForm.Show;268 end;269 270 236 procedure TMainForm.AExitExecute(Sender: TObject); 271 237 begin … … 276 242 begin 277 243 ImportStructureForm.ShowModal; 278 end;279 280 procedure TMainForm.AItemAddExecute(Sender: TObject);281 begin282 ItemAddForm.ShowModal;283 end;284 285 procedure TMainForm.AItemDeleteExecute(Sender: TObject);286 begin287 if MessageDlg(SItemDeletion, SReallyWantToDelete, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin288 289 end;290 244 end; 291 245 … … 315 269 procedure TMainForm.ADisconnectExecute(Sender: TObject); 316 270 begin 317 Core.System.Database.Disconnect; 318 TreeView1.Items.Clear; 319 ListView1.Items.Clear; 320 Core.System.Types.Clear; 321 FreeAndNil(Core.Client); 271 if Core.System.Database.Connected then begin 272 Core.System.Database.Disconnect; 273 TreeView1.Items.Clear; 274 Core.System.Types.Clear; 275 FreeAndNil(Core.Client); 276 end; 322 277 end; 323 278 324 279 procedure TMainForm.AAboutExecute(Sender: TObject); 325 280 begin 326 AboutForm.ShowModal; 281 try 282 AboutForm := TAboutForm.Create(nil); 283 AboutForm.ShowModal; 284 finally 285 FreeAndNil(AboutForm); 286 end; 327 287 end; 328 288 … … 332 292 LoadFromRegistry; 333 293 AConnect.Execute; 334 end;335 336 procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem);337 var338 I: Integer;339 begin340 if Item.Index < Report.Count then341 with TReportLine(Report[Item.Index]) do begin342 Item.Caption := Items[0];343 for I := 1 to Report.Columns.Count - 1 do344 if not TReportColumn(Report.Columns[I]).VirtualItem then begin345 Item.SubItems.Add(Items[I]);346 end;347 end;348 end;349 350 procedure TMainForm.ListView1DblClick(Sender: TObject);351 begin352 AItemViewExecute(Self);353 end;354 355 procedure TMainForm.ListView1KeyPress(Sender: TObject; var Key: char);356 begin357 if Key = #13 then AItemViewExecute(Self);358 end;359 360 procedure TMainForm.ListView1Resize(Sender: TObject);361 var362 I: Integer;363 begin364 for I := 0 to ListView1.Columns.Count - 1 do365 ListView1.Columns[I].Width := ListView1.Width div ListView1.Columns.Count;366 end;367 368 procedure TMainForm.ListView1SelectItem(Sender: TObject; Item: TListItem;369 Selected: Boolean);370 begin371 if Assigned(ListView1.Selected) then372 SelectedItem := TReportLine(Report[ListView1.Selected.Index]).Id373 else SelectedItem := 0;374 375 ButtonDelete.Enabled := Assigned(ListView1.Selected);376 ButtonView.Enabled := Assigned(ListView1.Selected);377 ButtonEdit.Enabled := Assigned(ListView1.Selected);378 294 end; 379 295 … … 395 311 if TreeView1.Selected.ImageIndex = 0 then begin 396 312 TreeView1.PopupMenu := PopupMenuObjectGroup; 397 ListView1.Visible := False;313 PageControl1.Visible := False; 398 314 end; 399 315 if TreeView1.Selected.ImageIndex = 1 then begin 400 316 TreeView1.PopupMenu := PopupMenuObject; 401 LoadItemList; 402 end; 317 //LoadItemList; 318 end; 319 end; 320 end; 321 322 procedure TMainForm.TreeView1DblClick(Sender: TObject); 323 var 324 NewItemListForm: TItemListForm; 325 begin 326 if Assigned(TreeView1.Selected) then begin 327 NewItemListForm := TItemListForm.Create(Self); 328 NewItemListForm.SelectedObject.Id := Integer(TreeView1.Selected.Data); 329 AddTabForm(NewItemListForm); 403 330 end; 404 331 end; … … 448 375 end; 449 376 450 procedure TMainForm. LoadItemList;377 procedure TMainForm.AddTabForm(Form: TForm); 451 378 var 452 NewColumn: TListColumn; 453 I: Integer; 454 begin 455 SelectedObjectId := 0; 456 if Assigned(TreeView1.Selected) then 457 with ListView1 do begin 458 Visible := True; 459 SelectedObject.Load(Integer(TreeView1.Selected.Data)); 460 Report.Load(SelectedObject); 461 462 Report.FillListColumns(Columns); 463 Items.Count := Report.Count; 464 Refresh; 465 end; 466 ListView1Resize(Self); 467 ListView1SelectItem(Self, nil, False); 379 NewTabSheet: TTabSheet; 380 begin 381 TabForms.Add(Form); 382 NewTabSheet := PageControl1.AddTabSheet; 383 NewTabSheet.DockSite := True; 384 NewTabSheet.UseDockManager := True; 385 NewTabSheet.Caption := Form.Caption; 386 Form.DragKind := dkDock; 387 Form.DragMode := dmAutomatic; 388 Form.Show; 389 Form.ManualDock(NewTabSheet); 390 PageControl1.TabIndex := PageControl1.PageCount - 1; 468 391 end; 469 392
Note:
See TracChangeset
for help on using the changeset viewer.