unit BillsProjectFrame; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ZjGridTreeDBA, ZjGridDBA, ZJGrid, ExtCtrls, ComCtrls, ToolWin, DataBase, StdCtrls, ZJEdits, ZjCells, ConstMethodUnit, ZjLists, XPMenu, ZjPopupPanel, JimPages, fraBillsItemsFrame, ImgList, dxBar, GridsEh, DBGridEh,Buttons {$IFDEF _beEncrypt} , ScEncryptUnit {$ENDIF}; type TColWidth = record ColIndex: Integer; ColWidth: Integer; end; PColWidth = ^TColWidth; type TBillsProjectView = class(TFrame) zaDrawingQuantity: TZjGridDBA; zaBills: TZjGridTreeDBA; xppBillsView: TdxBarPopupMenu; xppDrawQuantity: TdxBarPopupMenu; XPMenu: TXPMenu; zaCustomStep: TZjGridDBA; zaDQCalcExprs: TZjGridDBA; dxpmLocateBills: TdxBarPopupMenu; dxpmShowLevel: TdxBarPopupMenu; zaQtyItems: TZjGridDBA; JimPages: TJimPages; JimPagesPage1: TJimPage; JimPagesPage2: TJimPage; jpDetails: TJimPages; jpDetailsPage1: TJimPage; Panel1: TPanel; Splitter3: TSplitter; zgDrawingQuantity: TZJGrid; cbDQUnit: TZjComboBox; zgCustomStep: TZJGrid; jpDetailsPage2: TJimPage; pnlFXQD_Btm: TPanel; tbViewdQ: TToolBar; tbDrawingQuantity: TToolButton; tbItems: TToolButton; Splitter1: TSplitter; zgBills: TZJGrid; cbUnits: TZjComboBox; pnlFXQD_Top: TPanel; tbView1: TToolBar; tbBillsLocate: TToolButton; tbBillsShowLevel: TToolButton; QtyItemsFrame: TBillsItemsFrame; zgQtyItems: TZJGrid; ToolBar1: TToolBar; tbtnRefreshBills: TToolButton; Splitter2: TSplitter; JimPagesPage3: TJimPage; zgProjectBills: TZJGrid; PPItemsFrame: TBillsItemsFrame; ztaProjectBills: TZjGridTreeDBA; Panel2: TPanel; cbAutoSelectItems: TCheckBox; cbSpanLevelSelItems: TCheckBox; Splitter4: TSplitter; zcbBidLot: TZjComboBox; ToolBar2: TToolBar; tbAutoSelectNode: TToolButton; dpmGather: TdxBarPopupMenu; tbCancelSelectNode: TToolButton; dpmQtyBills: TdxBarPopupMenu; jpDetailsPage3: TJimPage; gStat: TDBGridEh; btnStat: TToolButton; btnOneKeyGatherNode: TSpeedButton; procedure zaBillsGridGetCellEditor(Sender: TObject; ACoord: TPoint; var AControl: TWinControl); procedure zaDrawingQuantityGridGetCellEditor(Sender: TObject; ACoord: TPoint; var AControl: TWinControl); procedure zgBillsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure tbDrawingQuantityClick(Sender: TObject); procedure zgBillsCopy(Sender: TObject; const ABounds: TRect; var Allow: Boolean); procedure zgBillsPaste(Sender: TObject; const ABounds: TRect; var Allow: Boolean); procedure zgDrawingQuantityMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure zgCustomStepCellTextChanging(Sender: TObject; const ACoord: TPoint; var NewValue: String; var Accept: Boolean); procedure zgBillsCellTextChanging(Sender: TObject; const ACoord: TPoint; var NewValue: String; var Accept: Boolean); procedure zgBillsColWidthChange(Sender: TObject; AIndex: Integer; const AValue: Integer); procedure tbBillsShowLevelClick(Sender: TObject); procedure tbBillsLocateClick(Sender: TObject); procedure cbSpanLevelSelItemsClick(Sender: TObject); procedure cbAutoSelectItemsClick(Sender: TObject); procedure tbtnRefreshBillsClick(Sender: TObject); procedure PPItemsFramezgItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ztaProjectBillsGridGetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); procedure ztaProjectBillsGridSetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); procedure zgProjectBillsCellGetColor(Sender: TObject; ACoord: TPoint; var AColor: TColor); procedure zgBillsCellGetColor(Sender: TObject; ACoord: TPoint; var AColor: TColor); procedure zgBillsBeforePaste(Sender: TObject; const ABounds: TRect; var Allow: Boolean); procedure zgBillsCustomPaste(Sender: TObject; ABounds: TRect; ASourSheet: TZjSheet); procedure zgProjectBillsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure tbAutoSelectNodeClick(Sender: TObject); procedure tbCancelSelectNodeClick(Sender: TObject); procedure QtyItemsFramezgItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure zgDrawingQuantityShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint); procedure zaBillsGridSetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); procedure zgBillsShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint); procedure btnOneKeyGatherNodeClick(Sender: TObject); private FShowOwnerName: Boolean; FProject: TObject; FCreating: Boolean; FStdBillsCtrl: TObject; PList: TList; FIsGradeView: Boolean; procedure SetUnitsList(AStrings: TStrings); function GetAutoSelectItems: Boolean; function GetSpanLevelSelectItems: Boolean; property IsAutoSelectItems: Boolean read GetAutoSelectItems; property IsSpanLevelSelectItems: Boolean read GetSpanLevelSelectItems; procedure SetStdBillsCtrl(const Value: TObject); {inner delete} function GetSelectionInfo(aStrList: TStringList): Integer; procedure RepairTreeStructure(var aPreID, aLastID, aParentID: Integer); procedure InitView; procedure SyncSelected(aID: Integer; aValue: Boolean); function GetPastePosition(var aNode: TZjIDTreeNode; var ABillsQty, ADQQty: Boolean): Integer; function GetActivePage: Integer; procedure SetActivePage(const Value: Integer); function GetActiveDetailPage: Integer; procedure SetActiveDetailpage(const Value: Integer); function GetBidLotList: TStrings; procedure SetBidLotList(const Value: TStrings); procedure SetProject(const Value: TObject); function GetRBNodeName(AIndex: Integer): string; procedure SetShowDesignQuantity(const Value: Boolean); procedure SetShowDrawingCode(const Value: Boolean); procedure SetShowEconomicMark(const Value: Boolean); public procedure AdjustControlsSize; constructor Create(aProject: TObject); destructor Destroy; override; procedure DoOnStat(AFJF: Currency; AYsCount, AQdCount: Integer); procedure CopyBills; // Modified by GiLi 2012-6-11 10:14:15 function IsCanCopyBills: Boolean; function IsCanGridPaste: Boolean; procedure CopyBillsToRecycleBin; { delete } function GetSelection(aStrList: TStringList; var aPreID, aLastID, aParentID: Integer): Integer; { control grid repaint } procedure ControlBillsTreeRT(AEnabled: Boolean; AETree: Boolean = True); procedure ControlDrawQtyRT(AEnabled: Boolean; AETree: Boolean = True); procedure ControlDesignCode(AEnabled: Boolean; AETree: Boolean = True); procedure SetGridFocus(aPageIdx: Integer); { beginupdate } procedure BeginUpdate; procedure EndUpdate; procedure BeginSelect; procedure EndSelect; { xmjBills } procedure EnterXMJBills; procedure LeaveXMJBills; procedure ControlXMJTreeView(aEnabled: Boolean; aXMJTree: Boolean = True); { Refresh } function CanRefreshQtyItem: Boolean; { Control OwnerName visible } procedure ControlOwnerBid(aFlag: Integer); // 切换到清单评分视图 procedure SwitchBillsGradeView(AGradeView: Boolean); procedure LoadBillsViewOption; property UnitsList: TStrings write SetUnitsList; property BidLotList: TStrings read GetBidLotList write SetBidLotList; property ActivePage: Integer read GetActivePage write SetActivePage; property ActiveDetailPage: Integer read GetActiveDetailPage write SetActiveDetailpage; property Project: TObject read FProject write SetProject; property StdBillsCtrl: TObject read FStdBillsCtrl write SetStdBillsCtrl; property IsGradeView: Boolean read FIsGradeView write FIsGradeView; property ShowDesignQuantity: Boolean write SetShowDesignQuantity; property ShowEconomicMark: Boolean write SetShowEconomicMark; property ShowDrawingCode: Boolean write SetShowDrawingCode; end; implementation {$R *.dfm} uses ScCopyBills, ClipBrd, ZjClipBrd, ConstVarUnit, ScStdBillsCtrl, ScConfig, ZjIDTree, DB, DBClient, ScBillsTree, DetailItemsDM, CheckPosForm, MainForm, NewProjectFrm, ScProjectManager; { TBillsProjectView } constructor TBillsProjectView.Create(aProject: TObject); begin FCreating := True; inherited Create(nil); Project := aProject; // zgBills.CellClass.Cols[1] := TZjCheckBoxCell; zgProjectBills.CellClass.Cols[1] := TZjCheckBoxCell; zgBills.CellClass.Cols[4] := TZjComboCell; // zgBills.CellClass.Cols[5] := TZjComboCell; zgDrawingQuantity.CellClass.Cols[3] := TZjComboCell; { init } InitView; FCreating := False; end; destructor TBillsProjectView.Destroy; begin // FIntegerList.Free; inherited; end; procedure TBillsProjectView.zaBillsGridGetCellEditor(Sender: TObject; ACoord: TPoint; var AControl: TWinControl); begin if ACoord.X = 4 then AControl := cbUnits else if FShowOwnerName and (ACoord.X = 5) then AControl := zcbBidLot; end; procedure TBillsProjectView.zaDrawingQuantityGridGetCellEditor( Sender: TObject; ACoord: TPoint; var AControl: TWinControl); begin if ACoord.X = 3 then AControl := cbDQUnit; end; procedure TBillsProjectView.zgBillsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbRight then begin xppBillsView.PopupFromCursorPos; end; end; procedure TBillsProjectView.tbDrawingQuantityClick(Sender: TObject); begin jpDetails.ActivePageIndex := TToolButton(Sender).Tag; end; procedure TBillsProjectView.SetUnitsList(AStrings: TStrings); begin cbUnits.Items.Assign(AStrings); cbDQUnit.Items.Assign(AStrings); end; procedure TBillsProjectView.zgBillsCopy(Sender: TObject; const ABounds: TRect; var Allow: Boolean); var rOldSel: TRect; begin if zgBills.Tag > 0 then begin LockWindowUpdate(zgBills.Handle); // 保存表格的选中状态 rOldSel.TopLeft := TZjGrid(Sender).Selection.Current; rOldSel.BottomRight := TZJGrid(Sender).Selection.EndSel; // 阻止Grid对象近一步执行默认的复制操作 Allow := False; // 打开剪贴板,因为我们要多次向剪贴板复制不同格式的内容 Clipboard.Open; try Screen.Cursor := crHourGlass; // 调用表格默认的剪贴板,保存文本内容到剪贴板 ZjClipboard.CopyToClipboard(TZjGrid(Sender), ABounds); // 调用TScXMLClipboard将选中的清单按照一定的格式保存到剪贴板,保存的格式名称为CF_Bills with TScXMLClipboard.Create(TProject(FProject).BillsData) do try with TZjGrid(Sender) do begin if zgBills.Tag = 1 then CopyBillsToClipboard(Selection.Bounds.Top - FixedRowCount, Selection.Bounds.Bottom - FixedRowCount - 1) else if zgBills.Tag = 2 then begin TProject(FProject).RecycleBinData.InsertNode(TProject(FProject).ProjectName, GetRBNodeName(Selection.Bounds.Top - FixedRowCount)); CopyBillsToFile(TProject(FProject).RecycleBinData.GetCurrentFileName, Selection.Bounds.Top - FixedRowCount, Selection.Bounds.Bottom - FixedRowCount - 1); end; end; finally Free; Screen.Cursor := crDefault; end; // 恢复表格的选中状态 TZJGrid(Sender).Selection.SelectRow(rOldSel.Top, rOldSel.Bottom); finally zgBills.Tag := 0; Clipboard.Close; LockWindowUpdate(0); end; end; end; procedure TBillsProjectView.zgBillsPaste(Sender: TObject; const ABounds: TRect; var Allow: Boolean); begin if Clipboard.HasFormat(CF_Bills) then begin Allow := False; // 建立TScXMLClipboard对象,执行粘贴过程 with TScXMLClipboard.Create(TProject(FProject).BillsData) do try PasteBillsFromClipboard(ABounds.Top - TZjGrid(Sender).FixedRowCount); finally Free; end; end; end; procedure TBillsProjectView.CopyBills; var iSelTop: Integer; iSelBottom: Integer; begin with zgBills do begin Tag := 1; // 首先将表格的选中状态转变为整行选择 iSelTop := Selection.Current.Y; iSelBottom := Selection.EndSel.Y; Selection.SelectRow(iSelTop, iSelBottom); // 复制到剪贴板 CopyToClipboard(Selection.Bounds); end; end; procedure TBillsProjectView.zgDrawingQuantityMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbRight then xppDrawQuantity.PopupFromCursorPos; end; function TBillsProjectView.GetAutoSelectItems: Boolean; begin Result := cbAutoSelectItems.Checked; end; procedure TBillsProjectView.ControlBillsTreeRT(AEnabled, AETree: Boolean); begin if AEnabled then begin zgBills.EndUpdate; zaBills.EnableControl; if AETree then if Assigned(zaBills.IDTree) then zaBills.IDTree.EndUpdate(False); end else begin zgBills.BeginUpdate; if AETree then begin if Assigned(zaBills.IDTree) then zaBills.IDTree.BeginUpdate(AETree); zaBills.DisableControl(True); end else zaBills.DisableControl; end; end; procedure TBillsProjectView.SetStdBillsCtrl(const Value: TObject); begin FStdBillsCtrl := Value; if Assigned(Value) then begin with TStdBillsCtrl(FStdBillsCtrl) do zaCustomStep.DataSet := DMStdBillsLib.cdsCustomStepView; end else zaCustomStep.DataSet := nil; end; procedure TBillsProjectView.zgCustomStepCellTextChanging(Sender: TObject; const ACoord: TPoint; var NewValue: String; var Accept: Boolean); begin if zaCustomStep.DataSet.RecordCount = 0 then Accept := False; end; procedure TBillsProjectView.zgBillsCellTextChanging(Sender: TObject; const ACoord: TPoint; var NewValue: String; var Accept: Boolean); begin if (zaCustomStep.DataSet.RecordCount > 0) and not ScConfigInfo.AllowMfyCode then begin if ACoord.X in [1, 2, 4] then Accept := False; end; if ACoord.X = 6 then begin if TProject(FProject).BillsData.HasGatherQ then begin Accept := False; MessageHint(0, '设计细目被勾选,不允许修改清单工程量。'); end; end; end; procedure TBillsProjectView.zgBillsColWidthChange(Sender: TObject; AIndex: Integer; const AValue: Integer); var I, iIdx: Integer; begin if FCreating then Exit; iIdx := 0; for I := 0 to zaBills.Columns.Count - 1 do begin if zaBills.Columns[I].Visible and (iIdx = AIndex - zgBills.FixedColCount) then begin zaBills.Columns[I].Width := AValue; Break; end; if zaBills.Columns[I].Visible then Inc(iIdx); end; end; procedure TBillsProjectView.tbBillsShowLevelClick(Sender: TObject); var P: TPoint; begin P := tbView1.ClientToScreen( Point(tbBillsShowLevel.Left, tbBillsShowLevel.Top + tbBillsShowLevel.Height)); dxpmShowLevel.Popup(P.X, P.Y); end; procedure TBillsProjectView.tbBillsLocateClick(Sender: TObject); var P: TPoint; sBillsChapters: TStrings; begin P := tbView1.ClientToScreen( Point(tbBillsLocate.Left, tbBillsLocate.Top + tbBillsLocate.Height)); sBillsChapters := TStrings(GetLocateBillsStrings); TProject(FProject).BillsData.GetChapterNames(sBillsChapters); dxpmLocateBills.Popup(P.X, P.Y); end; procedure TBillsProjectView.BeginUpdate; begin zgBills.BeginUpdate; zgProjectBills.BeginUpdate; end; procedure TBillsProjectView.EndUpdate; begin zgBills.EndUpdate; zgProjectBills.EndUpdate; end; function TBillsProjectView.GetSelectionInfo(aStrList: TStringList): Integer; var iPosition, iRange, iStart: Integer; vNode: TZjIDTreeNode; sIDString: string; iRefCount: Integer; begin Result := 0; iRefCount := 0; sIDString := ''; with zaBills.IDTree do begin iRange := zgBills.Selection.Bottom - zgBills.Selection.Top; if Selected.MajorIndex >= zgBills.Selection.Top - zgBills.FixedRowCount + 1 then vNode := Items[zgBills.Selection.Top - zgBills.FixedRowCount] else vNode := Selected; if not Assigned(vNode) then Exit; aStrList.Add(IntToStr(vNode.ID)); iStart := vNode.MajorIndex; iPosition := iStart; while Assigned(vNode) and (vNode.MajorIndex < iStart + iRange) do begin if not Assigned(vNode.LastPosterity) then begin if TScBillsItem(vNode).IsPreDefine then begin Result := 0; Break; end; if sIDString <> '' then begin sIDString := Format('%s or ID=%d', [sIDString, vNode.ID]); Inc(iRefCount); if iRefCount = 500 then begin aStrList.Add(sIDString); iRefCount := 0; sIDString := ''; end; end else begin sIDString := Format('ID=%d', [vNode.ID]); Inc(iRefCount); end; vNode := vNode.NextNode; Inc(Result); end else begin iPosition := vNode.LastPosterity.MajorIndex; while Assigned(vNode) and (vNode.MajorIndex <= iPosition) do begin if TScBillsItem(vNode).IsPreDefine then begin Result := 0; vNode := nil; Break; end; if sIDString <> '' then begin sIDString := Format('%s or ID=%d', [sIDString, vNode.ID]); Inc(iRefCount); if iRefCount = 500 then begin aStrList.Add(sIDString); iRefCount := 0; sIDString := ''; end; end else begin sIDString := Format('ID=%d', [vNode.ID]); Inc(iRefCount); end; vNode := vNode.NextNode; Inc(Result); end; end; end; if sIDString <> '' then aStrList.Add(sIDString); end; end; procedure TBillsProjectView.RepairTreeStructure(var aPreID, aLastID, aParentID: Integer); var iRange, iLast: Integer; nParent, nPreSibling, nCurNode, nLastNode: TZjIDTreeNode; begin with zaBills.IDTree do begin aPreID := -1; aLastID := -1; aParentID := -1; iRange := zgBills.Selection.Bottom - zgBills.Selection.Top; if Selected.MajorIndex >= zgBills.Selection.Top - zgBills.FixedRowCount + 1 then begin nCurNode := Items[zgBills.Selection.Top - zgBills.FixedRowCount]; nCurNode.LocateDBRecord; end else nCurNode := Selected; iLast := nCurNode.MajorIndex + iRange - 1; nParent := nCurNode.Parent; nPreSibling := nCurNode.PrevSibling; while Assigned(nCurNode) and (nCurNode.MajorIndex <= iLast) do begin if Assigned(nParent) then begin if nParent.LastPosterity.MajorIndex < iLast then begin nCurNode := nParent; nParent := nCurNode.Parent; nPreSibling := nCurNode; end else begin if Assigned(nPreSibling) then aPreID := nPreSibling.ID else aPreID := -1; aLastID := -1; aParentID := nParent.ID; nCurNode := nParent.LastChild; while Assigned(nCurNode) and (nCurNode.MajorIndex > iLast) do begin aLastID := nCurNode.ID; nCurNode := nCurNode.PrevSibling; end; Break; end; end else begin // 删除预定义项,不作处理 aParentID := -1; aPreID := nCurNode.PrevSiblingID; aLastID := nCurNode.NextSiblingID; Break; end; end; end; end; function TBillsProjectView.GetSelection(aStrList: TStringList; var aPreID, aLastID, aParentID: Integer): Integer; begin Result := GetSelectionInfo(aStrList); if Result > 0 then RepairTreeStructure(aPreID, aLastID, aParentID); end; procedure TBillsProjectView.ControlDrawQtyRT(AEnabled, AETree: Boolean); begin if AEnabled then zaDrawingQuantity.EnableControl else zaDrawingQuantity.DisableControl; end; procedure TBillsProjectView.cbSpanLevelSelItemsClick(Sender: TObject); begin if cbSpanLevelSelItems.Checked and cbAutoSelectItems.Checked then cbAutoSelectItems.Checked := False; end; procedure TBillsProjectView.cbAutoSelectItemsClick(Sender: TObject); begin if cbAutoSelectItems.Checked and cbSpanLevelSelItems.Checked then cbSpanLevelSelItems.Checked := False; end; function TBillsProjectView.GetSpanLevelSelectItems: Boolean; begin Result := cbSpanLevelSelItems.Checked; end; procedure TBillsProjectView.InitView; var i: integer; begin FIsGradeView := False; jpDetails.ActivePageIndex := 0; JimPages.ActivePageIndex := 0; {_zgBills.Height := Round(0.68 * Height); zgQtyItems.Height := Round(0.60 * Height); zgProjectBills.Height := Round(0.60 * Height); } for i := 0 to gStat.Columns.Count -1 do gStat.Columns[i].Footers[1].Color := $0086C2FF; TProject(FProject).BillsData.OnStat := DoOnStat; TProject(FProject).BillsData.Stat; // Modified by GiLi 2012-3-18 12:23:29 // 界面的修改 // 屏蔽评分功能 // 屏蔽按钮 btnStat.Visible := False; // 屏蔽分项清单表格评分列 zaBills.Column('IsIgNore').Visible := False; zaBills.Column('ErrorHint').Visible := False; zaBills.Column('IsSuperscale').Visible := False; zaBills.Column('StandardGrade').Visible := False; zaBills.Column('DeductGrade').Visible := False; zaBills.Column('UserModified').Visible := False; LoadBillsViewOption; end; function TBillsProjectView.GetActivePage: Integer; begin Result := JimPages.ActivePageIndex; end; procedure TBillsProjectView.SetActivePage(const Value: Integer); begin JimPages.ActivePageIndex := Value; case Value of 0: zgBills.SetFocus; 1: zgQtyItems.SetFocus; 2: zgProjectBills.SetFocus; end; end; procedure TBillsProjectView.tbtnRefreshBillsClick(Sender: TObject); begin Screen.Cursor := crHourGlass; try TProject(FProject).DetailItemsDM.RefreshPQItems; finally Screen.Cursor := crDefault; end; end; function TBillsProjectView.GetActiveDetailPage: Integer; begin Result := jpDetails.ActivePageIndex; end; procedure TBillsProjectView.SetActiveDetailpage(const Value: Integer); begin jpDetails.ActivePageIndex := Value; end; procedure TBillsProjectView.PPItemsFramezgItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin PPItemsFrame.zgDetailItemsMouseDown(Sender, Button, Shift, X, Y); end; procedure TBillsProjectView.ztaProjectBillsGridGetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); var OldActiveRec: Integer; begin if (ACoord.X = 1) and ztaProjectBills.ChangeActiveRecord(ACoord.Y - zgProjectBills.FixedRowCount, OldActiveRec) then begin try Value := ZjBooleanStr(TScBillsItem(ztaProjectBills.IDTree.Items[ACoord.Y - zgProjectBills.FixedRowCount]).Selected); finally ztaProjectBills.ChangeActiveRecord(OldActiveRec, OldActiveRec); end; end; end; procedure TBillsProjectView.ztaProjectBillsGridSetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); procedure SelectNextSibling(ANode: TZjIDTreeNode; ASelected: Boolean); var xNode: TZjIDTreeNode; begin xNode := ANode; while Assigned(xNode.PrevSibling) do begin TScBillsItem(xNode.PrevSibling).Selected := ASelected; SyncSelected(xNode.PrevSiblingID, ASelected); //FIntegerList[xNode.PrevSibling.MajorIndex] := Ord(ASelected); xNode := xNode.PrevSibling; end; TScBillsItem(ANode).Selected := ASelected; SyncSelected(ANode.ID, ASelected); //FIntegerList[ANode.MajorIndex] := Ord(ASelected); while Assigned(ANode.NextSibling) do begin TScBillsItem(ANode.NextSibling).Selected := ASelected; SyncSelected(ANode.NextSiblingID, ASelected); //FIntegerList[ANode.NextSibling.MajorIndex] := Ord(ASelected); ANode := ANode.NextSibling; end; end; procedure SelectChildren(ANode: TZjIDTreeNode; iLevel: Integer; ASelected: Boolean); begin if ANode = nil then Exit; if ANode.Level = iLevel then begin SelectNextSibling(ANode, ASelected); Exit; end; if ANode.FirstChild <> nil then SelectChildren(ANode.FirstChild, iLevel, ASelected); if ANode.NextSibling <> nil then SelectChildren(ANode.NextSibling, iLevel, ASelected); end; procedure SelectItems(ANode: TZjIDTreeNode; ASelected: Boolean); var iLevel: Integer; blFlag: Boolean; xNode, zNode: TZjIDTreeNode; begin blFlag := False; iLevel := ANode.Level; xNode := ANode.Parent; while Assigned(xNode) do begin if TScBillsItem(xNode).Selected then begin blFlag := True; Break; end; xNode := xNode.Parent; end; if not blFlag then SelectNextSibling(ANode, ASelected) else if Assigned(xNode) then begin zNode := xNode.PrevSibling; while Assigned(zNode) do begin if TScBillsItem(zNode).Selected then SelectChildren(zNode.FirstChild, iLevel, ASelected); zNode := zNode.PrevSibling; end; SelectChildren(xNode.FirstChild, iLevel, ASelected); zNode := xNode; while Assigned(zNode) do begin if TScBillsItem(zNode).Selected then SelectChildren(zNode.FirstChild, iLevel, ASelected); zNode := zNode.NextSibling; end; end; end; var Node: TZjIDTreeNode; begin Node := ztaProjectBills.IDTree.Selected; if Assigned(Node) and (ACoord.X = 1) then begin BeginSelect; try TScBillsItem(Node).Selected := ZjStrToBoolean(Value); SyncSelected(Node.ID, ZjStrToBoolean(Value)); if IsAutoSelectItems then SelectNextSibling(Node, ZjStrToBoolean(Value)) else if IsSpanLevelSelectItems then SelectItems(Node, ZjStrToBoolean(Value)); finally EndSelect; end; zgProjectBills.InvalidateCol(1); end; end; procedure TBillsProjectView.BeginSelect; begin zgProjectBills.BeginUpdate; ztaProjectBills.IDTree.BeginUpdate(True); ztaProjectBills.DisableControl(True); ControlBillsTreeRT(False); end; procedure TBillsProjectView.EndSelect; begin zgProjectBills.EndUpdate; ztaProjectBills.EnableControl; ztaProjectBills.IDTree.EndUpdate(False); ControlBillsTreeRT(True); end; procedure TBillsProjectView.EnterXMJBills; begin ztaProjectBills.IDTree := TProject(FProject).BillsData.XMJBillsTree; end; procedure TBillsProjectView.LeaveXMJBills; begin ztaProjectBills.IDTree := nil; end; procedure TBillsProjectView.SyncSelected(aID: Integer; aValue: Boolean); var sbiNode: TScBillsItem; begin sbiNode := TScBillsItem(TProject(FProject).BillsData.BillsTree.FindNode(aID)); if Assigned(sbiNode) then sbiNode.SyncSelected(aValue); end; function TBillsProjectView.GetBidLotList: TStrings; begin Result := zcbBidLot.Items; end; procedure TBillsProjectView.SetBidLotList(const Value: TStrings); begin zcbBidLot.Items.Assign(Value); end; function TBillsProjectView.CanRefreshQtyItem: Boolean; begin Result := zaQtyItems.DataSet.RecordCount = 0; end; procedure TBillsProjectView.SetProject(const Value: TObject); begin FProject := Value; if Assigned(FProject) then begin with TProject(FProject) do begin zaBills.IDTree := BillsData.BillsTree; zaDrawingQuantity.DataSet := BillsData.cdsOrgDrawingQuantity; PPItemsFrame.ItemsDS := DetailItemsDM.cdsPPItems; PPItemsFrame.DetailItemsDS := DetailItemsDM.cdsPPDetailItems; PPItemsFrame.DrawQtyDS := DetailItemsDM.cdsPPDrawQty; QtyItemsFrame.ItemsDS := DetailItemsDM.cdsQIItems; QtyItemsFrame.DetailItemsDS := DetailItemsDM.cdsQIDetailItems; QtyItemsFrame.DrawQtyDS := DetailItemsDM.cdsQIDrawQty; zaQtyItems.DataSet := DetailItemsDM.cdsPQBills; PPItemsFrame.DetailItemsDM := DetailItemsDM; QtyItemsFrame.DetailItemsDM := DetailItemsDM; gStat.DataSource := BillsData.dsStat; end; end else begin zaBills.IDTree := nil; zaDrawingQuantity.DataSet := nil; PPItemsFrame.ItemsDS := nil; PPItemsFrame.DetailItemsDS := nil; PPItemsFrame.DrawQtyDS := nil; PPItemsFrame.DetailItemsDM := nil; QtyItemsFrame.ItemsDS := nil; QtyItemsFrame.DetailItemsDS := nil; QtyItemsFrame.DrawQtyDS := nil; QtyItemsFrame.DetailItemsDM := nil; gStat.DataSource := nil; end; end; procedure TBillsProjectView.ControlOwnerBid(aFlag: Integer); begin if aFlag = 1 then begin zgBills.CellClass.Cols[5] := TZjComboCell; FShowOwnerName := True; end else begin // chenshilong, 2011-01-26 10:39:42 Visible会影响后面的Boolean字段列的显示 // zaBills.Columns[5].Visible := False; zaBills.Columns[5].Width := 0; FShowOwnerName := False; end; end; procedure TBillsProjectView.SetGridFocus(aPageIdx: Integer); begin case aPageIdx of 0: zgBills.SetFocus; 1: zgProjectBills.SetFocus; 2: zgQtyItems.SetFocus; end; end; procedure TBillsProjectView.zgProjectBillsCellGetColor(Sender: TObject; ACoord: TPoint; var AColor: TColor); var ztnNode: TZjIDTreeNode; begin if ztaProjectBills.IDTree = nil then Exit; ztnNode := ztaProjectBills.IDTree[ACoord.Y - zgProjectBills.FixedRowCount]; if Assigned(ztnNode) then begin if ztnNode.ParentID = 1 then AColor := $00FBCAC4; end; end; procedure TBillsProjectView.zgBillsCellGetColor(Sender: TObject; ACoord: TPoint; var AColor: TColor); var ztnNode: TZjIDTreeNode; begin if zaBills.IDTree = nil then Exit; ztnNode := zaBills.IDTree[ACoord.Y - zgBills.FixedRowCount]; if Assigned(ztnNode) then begin if Assigned(ztnNode.Parent) then begin if ztnNode.ParentID = 1 then AColor := $00FBCAC4 // 预算项目节用颜色标识出来 else if Trim(TScBillsItem(ztnNode).Code) <> '' then AColor := TColor($00F9E8DF); end; end; end; procedure TBillsProjectView.ControlXMJTreeView(aEnabled, aXMJTree: Boolean); begin if aEnabled then begin zgProjectBills.EndUpdate; //if Assigned(ztaProjectBills.IDTree) and Assigned(ztaProjectBills.IDTree.DataSet) then ztaProjectBills.EnableControl; if aXMJTree then begin if Assigned(ztaProjectBills.IDTree) and Assigned(ztaProjectBills.IDTree.DataSet) then ztaProjectBills.IDTree.EndUpdate(False); end; end else begin zgProjectBills.BeginUpdate; if aXMJTree then begin if Assigned(ztaProjectBills.IDTree) and Assigned(ztaProjectBills.IDTree.DataSet) then begin ztaProjectBills.IDTree.BeginUpdate(True); ztaProjectBills.DisableControl(True); end; end else ztaProjectBills.DisableControl; end; end; procedure TBillsProjectView.zgBillsBeforePaste(Sender: TObject; const ABounds: TRect; var Allow: Boolean); var iIndex: Integer; begin with TProject(FProject).BillsData.BillsTree do begin iIndex := ABounds.Top - zgBills.FixedRowCount; if (ABounds.Left < 3) and ((Items[iIndex] = nil) or (Items[iIndex].IsPreDefine)) then begin if Items[iIndex] = nil then MessageError(Handle, '不能在此插入记录 ') else MessageError(Handle, '不能覆盖预定义项, 如果要粘贴清单项,可以先在清单部分插入一条空记录,然后再粘贴. '); Allow := False; end else Allow := True; end; end; procedure TBillsProjectView.zgBillsCustomPaste(Sender: TObject; ABounds: TRect; ASourSheet: TZjSheet); var iRow : Integer; iCol : Integer; iSavePoint: Integer; iPosition : Integer; bBillsQty : Boolean; bDQQty : Boolean; bIsCode : Boolean; ztnNode : TZjIDTreeNode; sCode : string; sName : string; sBCode : string; gField : TField; begin if ABounds.Left >= 3 then begin for iRow := ABounds.Top to ABounds.Bottom - 1 do begin // Not Expanded Node, Cannot Down Paste if not TZJGrid(Sender).RowVisible[iRow] then Continue; for iCol := ABounds.Left to ABounds.Right - 1 do with TZJGrid(Sender).Cells[iCol, iRow] do if CanEdit then Text := ASourSheet.Values[iCol - ABounds.Left, iRow - ABounds.Top]; end; end else begin if zaBills.DataSet is TClientDataSet then iSavePoint := TClientDataSet(zaBills.DataSet).SavePoint; ztnNode := TProject(FProject).BillsData.BillsTree.Selected; if ztnNode = nil then Exit; iPosition := GetPastePosition(ztnNode, bBillsQty, bDQQty); if iPosition = -1 then Exit; if iPosition = 3 then begin Screen.Cursor := crHourGlass; try for iRow := 0 to ASourSheet.RowCount - 1 do for iCol := 0 to ASourSheet.ColCount - 1 do begin with TZJGrid(Sender).Cells[iCol + ABounds.Left , iRow + ABounds.Top] do if CanEdit then Text := ASourSheet.Values[iCol, iRow]; end; finally Screen.Cursor := crDefault; end; Exit; end; bIsCode := ABounds.Left = 1; Screen.Cursor := crHourGlass; TProject(FProject).BillsData.BeginHandler(True); zgBills.BeginUpdate; zaBills.DisableControl; try try if ASourSheet.RowCount > 0 then begin if bIsCode then begin if ASourSheet.ColCount - 1 >= 0 then sCode := ASourSheet.Values[0, iRow]; if ASourSheet.ColCount - 1 >= 1 then sBCode := ASourSheet.Values[1, iRow]; if (sCode <> '') and (sBCode <> '') then Abort; end; for iCol := 0 to ASourSheet.ColCount - 1 do begin if zaBills.FindField(iCol + ABounds.Left, gField) then begin zaBills.DataSet.Edit; if bBillsQty and ((gField.FieldName = 'Quantity') or (gField.FieldName = 'UnitPrice') or (gField.FieldName = 'TotalPrice') or (gField.FieldName = 'DesignQuantity') or (gField.FieldName = 'DesignQuantity2') or (gField.FieldName = 'DesignPrice')) then gField.AsString := '' else gField.AsString := ASourSheet.Values[iCol, 0]; // gField.Tag := 0; end; end; end; if zaBills.DataSet.State in [dsEdit, dsInsert] then zaBills.DataSet.Post; for iRow := 1 to ASourSheet.RowCount - 1 do for iCol := 0 to ASourSheet.ColCount - 1 do begin if bIsCode then begin if iCol = 0 then begin sCode := ASourSheet.Values[0, iRow]; if ASourSheet.ColCount - 1 >= 1 then sBCode := ASourSheet.Values[1, iRow]; if ASourSheet.ColCount - 1 >= 2 then sName := ASourSheet.Values[2, iRow]; if (sCode <> '') and (sBCode <> '') then Abort else if sCode <> '' then ztnNode := TProject(FProject).BillsData.InsertItem(ztnNode, sCode, sName, True) else ztnNode := TProject(FProject).BillsData.InsertItem(ztnNode, sBCode, sName, False); end; // assign value .... if zaBills.FindField(iCol + ABounds.Left, gField) then begin zaBills.DataSet.Edit; if bBillsQty and ((gField.FieldName = 'Quantity') or (gField.FieldName = 'UnitPrice') or (gField.FieldName = 'TotalPrice') or (gField.FieldName = 'DesignQuantity') or (gField.FieldName = 'DesignQuantity2') or (gField.FieldName = 'DesignPrice')) then gField.AsString := '' else gField.AsString := ASourSheet.Values[iCol, iRow]; gField.Tag := 0; end; end else // bcode begin if iCol = 0 then begin sCode := ASourSheet.Values[0, iRow]; if ASourSheet.ColCount - 1 >= 1 then sName := ASourSheet.Values[1, iRow]; ztnNode := TProject(FProject).BillsData.InsertItem(ztnNode, sCode, sName, False); end; if zaBills.FindField(iCol + ABounds.Left, gField) then begin zaBills.DataSet.Edit; if bBillsQty and ((gField.FieldName = 'Quantity') or (gField.FieldName = 'UnitPrice') or (gField.FieldName = 'TotalPrice') or (gField.FieldName = 'DesignQuantity') or (gField.FieldName = 'DesignQuantity2') or (gField.FieldName = 'DesignPrice')) then gField.AsString := '' else gField.AsString := ASourSheet.Values[iCol, iRow]; gField.Tag := 0; end; end; if zaBills.DataSet.State in [dsEdit, dsInsert] then zaBills.DataSet.Post; end; except if zaBills.DataSet is TClientDataSet then TClientDataSet(zaBills.DataSet).SavePoint := iSavePoint; if Screen.Cursor <> crHourGlass then Screen.Cursor := crHourGlass; try TProject(FProject).BillsData.DisconnectBillsTree; TProject(FProject).BillsData.ConnectionBillsTree; finally Screen.Cursor := crDefault; end; raise Exception.Create(' 您输入的数据类型不正确!粘贴操作失败! '); end; finally zgBills.EndUpdate; zaBills.EnableControl; TProject(FProject).BillsData.EndHandler; Screen.Cursor := crDefault; end; end; end; function TBillsProjectView.GetPastePosition(var aNode: TZjIDTreeNode; var ABillsQty, ADQQty: Boolean): Integer; var iPos: Integer; begin Result := CheckBillsPastePosition(ABillsQty, ADQQty, True); case Result of cp_Next : aNode := TProject(FProject).BillsData.BillsTree.AddBillsItem(aNode.ParentID, aNode.NextSiblingID); cp_Font : aNode := TProject(FProject).BillsData.BillsTree.AddBillsItem(aNode.ParentID, aNode.ID); cp_Child : aNode := TProject(FProject).BillsData.BillsTree.AddBillsItem(aNode.ID, -1); end; end; procedure TBillsProjectView.zgProjectBillsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbRight then begin dpmGather.PopupFromCursorPos; end; end; procedure TBillsProjectView.tbAutoSelectNodeClick(Sender: TObject); begin ControlBillsTreeRT(False); ControlXMJTreeView(False); try TProject(FProject).BillsData.SelectGatherNode(TProject(FProject).BillsData.XMJBillsTree.FirstNode, True); finally ControlXMJTreeView(True); ControlBillsTreeRT(True); end; end; procedure TBillsProjectView.tbCancelSelectNodeClick(Sender: TObject); begin ControlBillsTreeRT(False); ControlXMJTreeView(False); try TProject(FProject).BillsData.SelectGatherNode(TProject(FProject).BillsData.XMJBillsTree.FirstNode, False); finally ControlBillsTreeRT(True); ControlXMJTreeView(True); end; end; procedure TBillsProjectView.QtyItemsFramezgItemsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Button = mbRight then dpmQtyBills.PopupFromCursorPos; end; procedure TBillsProjectView.ControlDesignCode(AEnabled, AETree: Boolean); begin zgDrawingQuantity.BeginUpdate; try if AEnabled then begin zaDrawingQuantity.Columns[0].width := 33; if Assigned(zaDrawingQuantity.DataSet) then zaDrawingQuantity.DataSet.FieldByName('IsGatherQ').ReadOnly := False; zaDrawingQuantity.Columns[1].Width := 150; zaDrawingQuantity.Columns[2].Visible := True; zaDrawingQuantity.Columns[3].Visible := True; zaDrawingQuantity.Columns[4].Visible := True; zaDrawingQuantity.Columns[5].Visible := True; end else begin zaDrawingQuantity.Columns[0].Width := 0; if Assigned(zaDrawingQuantity.DataSet) then zaDrawingQuantity.DataSet.FieldByName('IsGatherQ').ReadOnly := True; zaDrawingQuantity.Columns[1].Width := 320; zaDrawingQuantity.Columns[2].Visible := False; zaDrawingQuantity.Columns[3].Visible := False; zaDrawingQuantity.Columns[4].Visible := False; zaDrawingQuantity.Columns[5].Visible := False; end; finally zgDrawingQuantity.EndUpdate; end; end; procedure TBillsProjectView.zgDrawingQuantityShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint); begin if not zaDrawingQuantity.Columns[2].Visible then begin HintStr := '填写示例 —— ' + #10#13 + #10#13 + '设计位置:K5+127.6 '+ #10#13 + '设计位置:K9+576.3' + #10#13 + '图号:S22-6' + #10#13 + '图号:S23-8' + #10#13 + #10#13 + '注意:请保留“设计位置:”、“图号:”字样'; CanShow := True; end; end; procedure TBillsProjectView.SwitchBillsGradeView(AGradeView: Boolean); var iFrom, iTo, i, idx, wth: Integer; P: PColWidth; begin iFrom := zaBills.Columns.IndexByName('UnitPrice'); iTo := zaBills.Columns.IndexByName('MemoStr'); if AGradeView then begin FIsGradeView := True; if Assigned(PList) then Exit; PList := TList.Create; // 用记录指针记下列和列宽,便于以后恢复。 for i := iFrom to iTo do begin New(P); P.ColIndex := i; P.ColWidth := zgBills.ColWidths[i]; PList.Add(P); zgBills.ColWidths[i] := 0; end; if not btnStat.Down then begin btnStat.Down := True; btnStat.Click; end; end else // 恢复正常视图 begin FIsGradeView := False; if not Assigned(PList) then Exit; // 恢复隐藏列的列宽 for I := 0 to PList.Count - 1 do begin idx := PColWidth(PList[I]).ColIndex; wth := PColWidth(PList[I]).ColWidth; zgBills.ColWidths[idx] := wth; end; // 先释放指针,再释放TList for I := 0 to PList.Count - 1 do begin if Assigned(PList[I]) then Dispose(PList[I]); end; PList.Free; // 虽然PList被释放了,但Assigned(PList)值仍为True PList := nil; if not tbDrawingQuantity.Down then begin tbDrawingQuantity.Down := True; tbDrawingQuantity.Click; end; end; end; procedure TBillsProjectView.zaBillsGridSetCellText(Sender: TObject; const ACoord: TPoint; var Value: String); begin if ACoord.X in [15, 17, 18] then TProject(FProject).BillsData.SetUserModifiedGrade; end; procedure TBillsProjectView.zgBillsShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo; const ACoord: TPoint); var s: string; OldActiveRecd: Integer; begin if ACoord.X = 14 then HintInfo.HintStr := '忽略:勾选后,自动评分时该清单不参与评分和统计。' else if ACoord.X = 19 then HintInfo.HintStr := '锁定:勾选后,自动评分时用户修改信息不会被覆盖。' else if ACoord.X = 15 then begin s := ''; { if zaBills.ChangeActiveRecord(ACoord.Y - zgBills.FixedRowCount, OldActiveRecd)then begin try if zaBills.DataSet.FieldByName('NameErrorFlag').AsInteger = 1 then begin s := '当前名称:' + zaBills.DataSet.FieldByName('Name').AsString + #10; s := s + '标准名称:' + zaBills.DataSet.FieldByName('RightName').AsString + #10#13#13; end; if zaBills.DataSet.FieldByName('UnitsErrorFlag').AsInteger = 1 then begin s := s + '当前单位:' + zaBills.DataSet.FieldByName('Units').AsString + #10; s := s + '标准单位:' + zaBills.DataSet.FieldByName('RightUnits').AsString; end; if Trim(s) = '' then Exit; HintInfo.HintStr := s; finally zaBills.ChangeActiveRecord(OldActiveRecd, OldActiveRecd); end; end; } if zaBills.DataSet.FieldByName('NameErrorFlag').AsInteger = 1 then begin s := '当前名称:“' + zaBills.DataSet.FieldByName('Name').AsString + '”' + #10; s := s + '标准名称:“' + zaBills.DataSet.FieldByName('RightName').AsString + '”' + #10#13#13; end; if zaBills.DataSet.FieldByName('UnitsErrorFlag').AsInteger = 1 then begin s := s + '当前单位:“' + zaBills.DataSet.FieldByName('Units').AsString + '”' + #10; s := s + '标准单位:“' + zaBills.DataSet.FieldByName('RightUnits').AsString + '”' + #10#13#13;; end; if Trim(s) = '' then Exit; s := s + '参考文件(预算项目节):' + ExtractFileName(TProject(FProject).BillsData.PBStdTreeFile) + #10; s := s + '参考文件(清单子目号):' + ExtractFileName(TProject(FProject).BillsData.BQStdTreeFile); HintInfo.HintStr := s; end else Exit; CanShow := True; HintInfo.HintMaxWidth := 600; HintInfo.HideTimeout := 30000; end; procedure TBillsProjectView.DoOnStat(AFJF: Currency; AYsCount, AQdCount: Integer); // 最终得分,质量分 var cZZDF, cZLF: Currency; vDS: TDataSource; begin gStat.Columns[1].Footers[1].ValueType := fvtStaticText; gStat.Columns[1].Footers[1].Value := IntToStr(AYsCount + AQdCount) + '行(预' + IntToStr(AYsCount) + ',清' + IntToStr(AQdCount) + ')'; gStat.Columns[5].Footers[1].ValueType := fvtStaticText; gStat.Columns[5].Footers[1].Value := CurrToStr(AFJF); gStat.Columns[7].Footers[1].ValueType := fvtStaticText; cZZDF := StrToCurr(gStat.GetFooterValue(0, gStat.Columns[7])); cZLF := AFJF + cZZDF; if cZLF > 100 then cZLF := 100; gStat.Columns[7].Footers[1].Value := CurrToStr(cZLF); // 以下用于刷新显示 vDS := gStat.DataSource; gStat.DataSource := nil; gStat.DataSource := vDS; end; procedure TBillsProjectView.AdjustControlsSize; begin pnlFXQD_Btm.Height := Round(pnlFXQD_Btm.Parent.Height / 3); zgQtyItems.Height := Round(zgQtyItems.Parent.Height / 2) - ToolBar1.Height - Splitter2.Height; zgProjectBills.Height := Round(zgProjectBills.Parent.Height / 2) - Panel2.Height - Splitter4.Height; end; procedure TBillsProjectView.CopyBillsToRecycleBin; begin zgBills.Tag := 2; zgBills.CopyToClipboard(zgBills.Selection.Bounds); end; function TBillsProjectView.GetRBNodeName(AIndex: Integer): string; var Item: TScBillsItem; begin Result := ''; Item := TProject(FProject).BillsData.BillsTree.Items[AIndex]; if Item <> nil then Result := Item.SBillCode + Item.SBillBCode + Item.SBillName; end; procedure TBillsProjectView.btnOneKeyGatherNodeClick(Sender: TObject); var iID: Integer; sGatherName: string; strFilePath: string; iProjectType, iProjKind, iGatherID: Integer; aProject, nProject: TProject; bIsExist: Boolean; begin ControlBillsTreeRT(False); ControlXMJTreeView(False); try TProject(FProject).BillsData.SelectGatherNode(TProject(FProject).BillsData.XMJBillsTree.FirstNode, True); finally ControlXMJTreeView(True); ControlBillsTreeRT(True); end; {$IFDEF _beEncrypt} DelayCheckDog; CheckDogErrorCountAndHint; {$ENDIF} if not TProject(FProject).BillsData.HasSelected then TProject(FProject).BillsData.SelectGatherNode(TProject(FProject).BillsData.XMJBillsTree.FirstNode, True); // 检查是否是建设项目 TProject(FProject).CheckBeforeGather; // 获得名称 sGatherName := Format('%s[项目清单]', [MainFrm.jtsBillsProjects.Tabs[MainFrm.jtsBillsProjects.TabIndex]]); // 获得项目类型 iProjectType := TProject(FProject).ProjectType; // 判断文件是否存在,如存在则然后在询问是否覆盖 if not MainFrm.ProjectFileManager.ProjectMgrDM.ChackSameProjectForOneKey(TProject(FProject).GetGatherID, sGatherName, bIsExist) then begin Exit; end; strFilePath := MainFrm.ProjectFileManager.CreateNewProjectForOneKey(sGatherName, iID, TProject(FProject).GetGatherID); Application.ProcessMessages; Screen.Cursor := crHourGlass; // 界面上加提示 MainFrm.BeginUserOperation(sGatherWord); aProject := MainFrm.ProjectManager.ActiveProject; nProject := MainFrm.ProjectManager.CreateNewProject(strFilePath, sGatherName, MainFrm.StdBillsCtrl, iProjectType, iID); nProject.ProjectView.Project{.BillsData} := nil; IncProgressUI(15); try if not aProject.GatherProject(nProject) then begin IncProgressUI(80); MessageHint(0, sGatherError); DeleteFile(Format('%s%s.smb', [MainFrm.DirPath, sGatherName])); end; finally MainFrm.ProjectManager.RemoveProject(nProject, aProject, False); MainFrm.EndUserOperation; Screen.Cursor := crDefault; IncProgressUI(100); end; end; function TBillsProjectView.IsCanCopyBills: Boolean; begin if not Assigned(zaBills.IDTree) then begin Result := False; Exit; end; if not Assigned(zaBills.IDTree.Selected) then begin Result := False; Exit; end; // 第二部分黑体 不允许复制整块 if zaBills.IDTree.Selected.ID = 2 then begin Result := False; Exit; end; Result := True; end; function TBillsProjectView.IsCanGridPaste: Boolean; begin if not zgBills.Focused then begin Result := True; Exit; end; // 第二部分黑体 不允许粘贴整块 if Assigned(zaBills.IDTree.Selected) and (zaBills.IDTree.Selected.ID = 2) then begin Result := False; Exit; end; Result := True; end; procedure TBillsProjectView.SetShowDesignQuantity(const Value: Boolean); begin zaBills.Column('DesignQuantity').Visible := Value; zaBills.Column('DesignQuantity2').Visible := Value; end; procedure TBillsProjectView.SetShowDrawingCode(const Value: Boolean); begin zaBills.Column('DrawingCode').Visible := Value; end; procedure TBillsProjectView.SetShowEconomicMark(const Value: Boolean); begin zaBills.Column('DesignPrice').Visible := Value; end; procedure TBillsProjectView.LoadBillsViewOption; begin ShowDesignQuantity := ScConfigInfo.ShowDesignQuantity; ShowEconomicMark := ScConfigInfo.ShowEconomicMark; ShowDrawingCode := ScConfigInfo.ShowDrawingCode; end; end.