BillsGatherFme.pas 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. unit BillsGatherFme;
  2. interface
  3. uses
  4. BillsGatherDm, Globals, sdDB,
  5. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  6. Dialogs, ZJGrid, ExtCtrls, ZjGridDBA, ZjGridTreeDBA, ComCtrls, ToolWin,
  7. XPMenu, sdGridDBA, JimPages;
  8. type
  9. TBillsGatherFrame = class(TFrame)
  10. pnlBillsGather: TPanel;
  11. zgGclBills: TZJGrid;
  12. pnlRelaXmj: TPanel;
  13. pnlRelaXmjType: TPanel;
  14. tbToolsButton: TToolBar;
  15. tobtnDetailGcl: TToolButton;
  16. sprBillsGather: TSplitter;
  17. xpm: TXPMenu;
  18. tobtnDetailDeal: TToolButton;
  19. tobtnDetailBGL: TToolButton;
  20. jpsRela: TJimPages;
  21. jpsRelaDetailGcl: TJimPage;
  22. jpsRelaDetailDeal: TJimPage;
  23. jpsRelaDetailBGL: TJimPage;
  24. zgDetailGcl: TZJGrid;
  25. saDetailGcl: TsdGridDBA;
  26. saDetailDeal: TsdGridDBA;
  27. saDetailBGL: TsdGridDBA;
  28. zgDetailBGL: TZJGrid;
  29. zgDetailDeal: TZJGrid;
  30. saGclBills: TsdGridDBA;
  31. procedure zgGclBillsCellGetColor(Sender: TObject; ACoord: TPoint;
  32. var AColor: TColor);
  33. procedure tobtnDetailGclClick(Sender: TObject);
  34. private
  35. FBillsGatherData: TBillsGatherData;
  36. FShowPhaseData: Boolean;
  37. FShowPriceChange: Boolean;
  38. procedure SetColumnVisible(const AColumn: string; AVisible: Boolean);
  39. procedure SetShowPhaseData(const Value: Boolean);
  40. procedure SetShowPriceChange(const Value: Boolean);
  41. public
  42. constructor Create(AProjectFrame: TFrame; ABillsGatherData: TBillsGatherData);
  43. destructor Destroy; override;
  44. procedure RefreshBills;
  45. property ShowPriceChange: Boolean read FShowPriceChange write SetShowPriceChange;
  46. property ShowPhaseData: Boolean read FShowPhaseData write SetShowPhaseData;
  47. end;
  48. implementation
  49. {$R *.dfm}
  50. { TBillsGatherFrame }
  51. constructor TBillsGatherFrame.Create(AProjectFrame: TFrame;
  52. ABillsGatherData: TBillsGatherData);
  53. begin
  54. inherited Create(AProjectFrame);
  55. FBillsGatherData := ABillsGatherData;
  56. saGclBills.DataView := FBillsGatherData.sdvGclBills;
  57. saDetailGcl.DataView := FBillsGatherData.sdvDetailGclBills;
  58. saDetailDeal.DataView := FBillsGatherData.sdvDetailDealBills;
  59. saDetailBGL.DataView := FBillsGatherData.sdvDetailBGLBills;
  60. end;
  61. destructor TBillsGatherFrame.Destroy;
  62. begin
  63. inherited;
  64. end;
  65. procedure TBillsGatherFrame.RefreshBills;
  66. begin
  67. FBillsGatherData.RefreshBills;
  68. end;
  69. procedure TBillsGatherFrame.SetColumnVisible(const AColumn: string;
  70. AVisible: Boolean);
  71. begin
  72. if AVisible then
  73. saGclBills.Columns.ColumnByName(AColumn).Width := 60
  74. else
  75. saGclBills.Columns.ColumnByName(AColumn).Width := 0;
  76. end;
  77. procedure TBillsGatherFrame.SetShowPhaseData(const Value: Boolean);
  78. begin
  79. FShowPhaseData := Value;
  80. SetColumnVisible('CurDealQuantity', FShowPhaseData);
  81. SetColumnVisible('CurDealTotalPrice', FShowPhaseData);
  82. SetColumnVisible('CurQcQuantity', FShowPhaseData);
  83. SetColumnVisible('CurQcTotalPrice', FShowPhaseData);
  84. SetColumnVisible('CurPcQuantity', FShowPhaseData and FShowPriceChange);
  85. SetColumnVisible('CurPcTotalPrice', FShowPhaseData and FShowPriceChange);
  86. SetColumnVisible('CurGatherQuantity', FShowPhaseData);
  87. SetColumnVisible('CurGatherTotalPrice', FShowPhaseData);
  88. SetColumnVisible('EndDealQuantity', FShowPhaseData);
  89. SetColumnVisible('EndDealTotalPrice', FShowPhaseData);
  90. SetColumnVisible('EndQcQuantity', FShowPhaseData);
  91. SetColumnVisible('EndQcTotalPrice', FShowPhaseData);
  92. SetColumnVisible('EndPcQuantity', FShowPhaseData and FShowPriceChange);
  93. SetColumnVisible('EndPcTotalPrice', FShowPhaseData and FShowPriceChange);
  94. SetColumnVisible('EndGatherQuantity', FShowPhaseData);
  95. SetColumnVisible('EndGatherTotalPrice', FShowPhaseData);
  96. end;
  97. procedure TBillsGatherFrame.SetShowPriceChange(const Value: Boolean);
  98. begin
  99. FShowPriceChange := Value;
  100. SetColumnVisible('NewPrice', FShowPriceChange);
  101. SetColumnVisible('CurPcQuantity', FShowPriceChange and FShowPhaseData);
  102. SetColumnVisible('CurPcTotalPrice', FShowPriceChange and FShowPhaseData);
  103. SetColumnVisible('EndPcQuantity', FShowPriceChange and FShowPhaseData);
  104. SetColumnVisible('EndPcTotalPrice', FShowPriceChange and FShowPhaseData);
  105. end;
  106. procedure TBillsGatherFrame.zgGclBillsCellGetColor(Sender: TObject;
  107. ACoord: TPoint; var AColor: TColor);
  108. function CheckSimilarBills(ARow1, ARow2: Integer): Boolean;
  109. var
  110. bHasSame, bHasDiffer: Boolean;
  111. begin
  112. bHasSame := SameText(zgGclBills.Cells[1, ARow1].Text, zgGclBills.Cells[1, ARow2].Text);
  113. bHasDiffer := (not SameText(zgGclBills.Cells[2, ARow1].Text, zgGclBills.Cells[2, ARow2].Text))
  114. or (not SameText(zgGclBills.Cells[3, ARow1].Text, zgGclBills.Cells[3, ARow2].Text))
  115. or (not SameText(zgGclBills.Cells[4, ARow1].Text, zgGclBills.Cells[4, ARow2].Text));
  116. Result := bHasSame and bHasDiffer;
  117. end;
  118. function CheckOverRange(ARecIndex: Integer): Boolean;
  119. var
  120. Rec: TsdDataRecord;
  121. fQuantity, fDealQuantity, fEndDealQuantity: Double;
  122. begin
  123. Rec := saGclBills.DataView.Records[ARecIndex];
  124. Result := False;
  125. if not Assigned(Rec) then Exit;
  126. fDealQuantity := Rec.ValueByName('DealQuantity').AsFloat;
  127. fQuantity := Rec.ValueByName('Quantity').AsFloat;
  128. fEndDealQuantity := Rec.ValueByName('EndDealQuantity').AsFloat;
  129. case SupportManager.ConfigInfo.OverRangeType of
  130. 0: Result := fEndDealQuantity > fQuantity;
  131. 1: Result := fEndDealQuantity > fDealQuantity;
  132. 2: Result := (fEndDealQuantity > fQuantity) or (fEndDealQuantity > fDealQuantity);
  133. end;
  134. end;
  135. var
  136. bSimilarBills: Boolean;
  137. begin
  138. if (ACoord.Y >= zgGclBills.FixedRowCount) then
  139. begin
  140. if ACoord.Y = zgGclBills.FixedRowCount then
  141. bSimilarBills := CheckSimilarBills(ACoord.Y, ACoord.Y + 1)
  142. else if ACoord.Y < zgGclBills.RowCount - zgGclBills.FixedRowCount then
  143. bSimilarBills := CheckSimilarBills(ACoord.Y, ACoord.Y - 1) or
  144. CheckSimilarBills(ACoord.Y, ACoord.Y + 1)
  145. else
  146. bSimilarBills := CheckSimilarBills(ACoord.Y, ACoord.Y - 1);
  147. {if bSimilarBills then
  148. AColor := $00646AFE;}
  149. if bSimilarBills then
  150. AColor := $0000FFFF; // »ÆÉ«
  151. if CheckOverRange(ACoord.Y - zgGclBills.FixedRowCount) then
  152. AColor := $00505AFF; // ºìÉ«
  153. end;
  154. end;
  155. procedure TBillsGatherFrame.tobtnDetailGclClick(Sender: TObject);
  156. begin
  157. jpsRela.ActivePageIndex := TToolButton(Sender).Tag;
  158. tobtnDetailGcl.Down := tobtnDetailGcl.Tag = TToolButton(Sender).Tag;
  159. tobtnDetailDeal.Down := tobtnDetailDeal.Tag = TToolButton(Sender).Tag;
  160. tobtnDetailBGL.Down := tobtnDetailBGL.Tag = TToolButton(Sender).Tag;
  161. end;
  162. end.