123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- unit StandardBillsFme;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, XPMenu, ZjGridDBA, ZjGridTreeDBA, ZJGrid, StdCtrls, Buttons,
- ExtCtrls, StandardLibs, StandardLib, ActnList, dxBar, sdGridDBA,
- sdGridTreeDBA;
- type
- TBillsType = (btXm, btGcl);
- TStandardBillsFrame = class(TFrame)
- pnlTop: TPanel;
- spbtnLibs: TSpeedButton;
- edtLibName: TEdit;
- zgBills: TZJGrid;
- xpm: TXPMenu;
- ActionList1: TActionList;
- dxpmStandardBills: TdxBarPopupMenu;
- actnInsertBillsFromLib: TAction;
- stdBills: TsdGridTreeDBA;
- procedure actnInsertBillsFromLibExecute(Sender: TObject);
- procedure zgBillsMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- private
- FStandardLibs: TStandardLibs;
- FBillsType: TBillsType;
- procedure SetBillsType(const Value: TBillsType);
- function GetStandardLib: TStandardLib;
- procedure AdjustColumnType;
- public
- constructor Create(AStandardLibs: TStandardLibs);
- procedure ConnectStandardLib;
- property BillsType: TBillsType read FBillsType write SetBillsType;
- property StandardLib: TStandardLib read GetStandardLib;
- end;
- implementation
- uses
- SupportUnit, Globals;
- {$R *.dfm}
- { TStandBillsFrame }
- procedure TStandardBillsFrame.AdjustColumnType;
- procedure AdjustXmColumnType;
- begin
- stdBills.Columns.Delete(stdBills.ColumnIndex('B_Code'));
- end;
- procedure AdjustGclColumnType;
- begin
- stdBills.Columns.Delete(stdBills.ColumnIndex('Code'));
- end;
- begin
- if FBillsType = btXm then
- AdjustXmColumnType
- else if FBillsType = btGcl then
- AdjustGclColumnType;
- end;
- procedure TStandardBillsFrame.ConnectStandardLib;
- begin
- stdBills.IDTree := StandardLib.StandardBillsData.BillsTree;
- edtLibName.Text := StandardLib.LibName;
- end;
- constructor TStandardBillsFrame.Create(AStandardLibs: TStandardLibs);
- begin
- inherited Create(nil);
- FStandardLibs := AStandardLibs;
- stdBills.TopLevelBold := False;
- end;
- function TStandardBillsFrame.GetStandardLib: TStandardLib;
- begin
- case FBillsType of
- btXm: Result := FStandardLibs.StandardXmLib;
- btGcl: Result := FStandardLibs.StandardGclLib;
- end;
- end;
- procedure TStandardBillsFrame.SetBillsType(const Value: TBillsType);
- begin
- FBillsType := Value;
- AdjustColumnType;
- end;
- procedure TStandardBillsFrame.zgBillsMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Button = mbRight then
- dxpmStandardBills.PopupFromCursorPos
- else if (Button = mbLeft) and (ssDouble in Shift) then
- actnInsertBillsFromLib.Execute;
- end;
- procedure TStandardBillsFrame.actnInsertBillsFromLibExecute(
- Sender: TObject);
- begin
- with OpenProjectManager.CurProjectData.BillsCompileData do
- if Assigned(stdBills.IDTree.Selected) then
- AddBillsFromLib(stdBills.IDTree.Selected, BillsType);
- end;
- end.
|