OtherMeasureFme.pas 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. unit OtherMeasureFme;
  2. interface
  3. uses
  4. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5. Dialogs, JimPages, XPMenu, ComCtrls, ToolWin, ExtCtrls, sdGridDBA, ZJGrid,
  6. ProjectData;
  7. type
  8. TOtherMeasureFrame = class(TFrame)
  9. pnlRelaXmjType: TPanel;
  10. tbToolsButton: TToolBar;
  11. tobtnPhase: TToolButton;
  12. tobtnOnce: TToolButton;
  13. xpm: TXPMenu;
  14. pnlOtherMeasure: TPanel;
  15. jpsOtherMeasure: TJimPages;
  16. jpsOtherMeasurePhase: TJimPage;
  17. jpsOtherMeasureOnce: TJimPage;
  18. zgPhase: TZJGrid;
  19. zgOnce: TZJGrid;
  20. saOnce: TsdGridDBA;
  21. saPhase: TsdGridDBA;
  22. procedure tobtnPhaseClick(Sender: TObject);
  23. procedure zgPhaseKeyDown(Sender: TObject; var Key: Word;
  24. Shift: TShiftState);
  25. procedure zgPhaseCellGetColor(Sender: TObject; ACoord: TPoint;
  26. var AColor: TColor);
  27. private
  28. FProjectData: TProjectData;
  29. { Private declarations }
  30. public
  31. constructor Create(AProjectData: TProjectData);
  32. destructor Destroy; override;
  33. procedure ResetViewControl;
  34. end;
  35. implementation
  36. uses
  37. OtherMeasurePhaseDm, sdDB, ConditionalDefines;
  38. {$R *.dfm}
  39. constructor TOtherMeasureFrame.Create(AProjectData: TProjectData);
  40. begin
  41. inherited Create(nil);
  42. FProjectData := AProjectData;
  43. saPhase.DataView := FProjectData.OtherMeasurePhaseData.sdvPhase;
  44. saOnce.DataView := FProjectData.OtherMeasureOnceData.sdvOnce;
  45. if not _IsDebugView then
  46. zgPhase.OnKeyDown := nil;
  47. end;
  48. destructor TOtherMeasureFrame.Destroy;
  49. begin
  50. inherited;
  51. end;
  52. procedure TOtherMeasureFrame.ResetViewControl;
  53. begin
  54. saPhase.Columns.ColumnByName('CurTotalPrice').ReadOnly := TProjectData(FProjectData).StageDataReadOnly;
  55. if TProjectData(FProjectData).AllowInsert then
  56. saPhase.Options := [aoAllowInsert, aoAllowEdit, aoAllowDelete, aoAutoInsert, aoAllowUpMove, aoAllowDownMove]
  57. else
  58. saPhase.Options := [];
  59. end;
  60. procedure TOtherMeasureFrame.tobtnPhaseClick(Sender: TObject);
  61. begin
  62. jpsOtherMeasure.ActivePageIndex := TToolButton(Sender).Tag;
  63. tobtnPhase.Down := tobtnPhase.Tag = TToolButton(Sender).Tag;
  64. tobtnOnce.Down := tobtnOnce.Tag = TToolButton(Sender).Tag;
  65. end;
  66. procedure TOtherMeasureFrame.zgPhaseKeyDown(Sender: TObject; var Key: Word;
  67. Shift: TShiftState);
  68. begin
  69. if (ssCtrl in Shift) and (ssShift in Shift) and (ssAlt in Shift)
  70. and (Key in [68, 100]) then // 'd', 'D'
  71. begin
  72. with FProjectData.OtherMeasurePhaseData do
  73. FilterDeletedRec := not FilterDeletedRec;
  74. end;
  75. end;
  76. procedure TOtherMeasureFrame.zgPhaseCellGetColor(Sender: TObject;
  77. ACoord: TPoint; var AColor: TColor);
  78. var
  79. Rec: TsdDataRecord;
  80. begin
  81. Rec := saPhase.DataView.Records[ACoord.Y-1];
  82. if Assigned(Rec) and Rec.ValueByName('Deleted').AsBoolean then
  83. AColor := $00D5D5D5
  84. else
  85. AColor := clWindow;
  86. end;
  87. end.