| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 | unit BGLFme;interfaceuses  BGLDm,  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, ZjGridDBA, StdCtrls, DBCtrls, ZJGrid, ExtCtrls, ComCtrls,  ToolWin, JimLabels, ActnList, DB, dxBar, ZJEdits;type  TBGLFrame = class(TFrame)    labTitle: TJimGradLabel;    ToolBar: TToolBar;    tobtnNew: TToolButton;    pnlBGLList: TPanel;    zgBGL: TZJGrid;    pnlBGLMemo: TPanel;    lblPosition: TLabel;    dbmPos_Reason: TDBMemo;    lblDirection: TLabel;    dbmDirection: TDBMemo;    pnlBGBills: TPanel;    zgBGBills: TZJGrid;    zaBGL: TZjGridDBA;    zaBGBills: TZjGridDBA;    alBGL: TActionList;    actnNew: TAction;    actnApply: TAction;    dxpmBGL: TdxBarPopupMenu;    dxpmBGBills: TdxBarPopupMenu;    actnBatchWritePos_Reason: TAction;    pnlBGL: TPanel;    sprBGL: TSplitter;    actnCopyBGLBlock: TAction;    cbbBGLType: TZjComboBox;    procedure actnNewExecute(Sender: TObject);    procedure dbmPos_ReasonExit(Sender: TObject);    procedure zgBGLMouseDown(Sender: TObject; Button: TMouseButton;      Shift: TShiftState; X, Y: Integer);    procedure zgBGBillsMouseDown(Sender: TObject; Button: TMouseButton;      Shift: TShiftState; X, Y: Integer);    procedure dxpmBGLPopup(Sender: TObject);    procedure actnBatchWritePos_ReasonExecute(Sender: TObject);    procedure zaBGBillsGridSetCellText(Sender: TObject;      const ACoord: TPoint; var Value: String);    procedure actnCopyBGLBlockExecute(Sender: TObject);    procedure zgBGLCopy(Sender: TObject; const ABounds: TRect;      var Allow: Boolean);    procedure zgBGLPaste(Sender: TObject; const ABounds: TRect;      var Allow: Boolean);    procedure actnCopyBGLBlockUpdate(Sender: TObject);    procedure zgBGLGetCellEditor(Sender: TObject; ACoord: TPoint;      var AControl: TWinControl);    procedure zgBGLEditorSaveCell(Sender: TObject; ACoord: TPoint;      AControl: TWinControl);    procedure zgBGLEditorLoadCell(Sender: TObject; ACoord: TPoint;      AControl: TWinControl);    procedure zgBGLCellTextChanged(Sender: TObject; Col, Row: Integer);    procedure zaBGLGridCellCanEdit(Sender: TObject; const ACoord: TPoint;      var Allow: Boolean);    procedure zaBGBillsGridCellCanEdit(Sender: TObject;      const ACoord: TPoint; var Allow: Boolean);    procedure zgBGLCurrentChanged;  private    FBGLData: TBGLData;    procedure CopyBGLBlock(ABounds: TRect);    procedure PasteBGLBlock;  public    constructor Create(AParent: TFrame; ABGLData: TBGLData);    procedure LoadBGLFromCloud;  end;implementationuses  UtilMethods, MergeTextFrm, ProjectData, MainFrm, mEncryptEditions,  BGLClipboard, ConditionalDefines, ZjCells, PHPWebDm;{$R *.dfm}{ TBGLFrame }constructor TBGLFrame.Create(AParent: TFrame; ABGLData: TBGLData);begin  inherited Create(AParent);  FBGLData := ABGLData;  zgBGL.CellClass.Cols[zaBGL.ColumnCol('BGLType')] := TZjComboCell;  zaBGL.DataSet := FBGLData.cdsBGLView;  zgBGL.OnGetCellEditor := zgBGLGetCellEditor;  zgBGL.OnEditorLoadCell := zgBGLEditorLoadCell;  zgBGL.OnEditorSaveCell := zgBGLEditorSaveCell;  dbmPos_Reason.DataSource := FBGLData.dsBGL;  dbmDirection.DataSource := FBGLData.dsBGL;  zaBGBills.DataSet := FBGLData.cdsBGBillsView;  SetDxBtnAction(actnNew, tobtnNew);  if _IsCloud then  begin    zaBGL.Options := [aoAllowEdit, aoAllowDelete, aoAllowUpMove, aoAllowDownMove];    zaBGL.ExtendRowCount := 0;    FBGLData.AfterCurrentBGLChanged := zgBGLCurrentChanged;  end  else    zaBGL.Options := [aoAllowInsert, aoAllowEdit, aoAllowDelete, aoAutoInsert, aoAllowUpMove, aoAllowDownMove];end;procedure TBGLFrame.actnNewExecute(Sender: TObject);var  sCode: string;begin  sCode := Format('%s-%d-%d', ['', TProjectData(FBGLData.ProjectData).PhaseIndex,      FBGLData.cdsBGL.RecordCount + 1]);  if GetMergeText('±ä¸üÁîºÅ', sCode) then    FBGLData.AddBGL(sCode);end;procedure TBGLFrame.dbmPos_ReasonExit(Sender: TObject);begin  if FBGLData.cdsBGLView.State in [dsEdit] then    FBGLData.cdsBGLView.Post;end;procedure TBGLFrame.zgBGLMouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  if Button = mbRight then    dxpmBGL.PopupFromCursorPos;end;procedure TBGLFrame.zgBGBillsMouseDown(Sender: TObject;  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin  if Button = mbRight then    dxpmBGBills.PopupFromCursorPos;end;procedure TBGLFrame.dxpmBGLPopup(Sender: TObject);begin  SetDxBtnAction(actnBatchWritePos_Reason, MainForm.dxbtnBatchWritePos_Reason);  SetDxBtnAction(actnCopyBGLBlock, MainForm.dxbtnCopyBillsBlock);end;procedure TBGLFrame.actnBatchWritePos_ReasonExecute(Sender: TObject);begin  FBGLData.BatchWritePos_Reason;end;procedure TBGLFrame.zaBGBillsGridSetCellText(Sender: TObject;  const ACoord: TPoint; var Value: String);begin  if SameText(Value, zgBGBills.Cells[ACoord.X, ACoord.Y].Text) then    Abort;end;procedure TBGLFrame.actnCopyBGLBlockExecute(Sender: TObject);var  iCount: Integer;begin  if CheckMeasureEdition then  begin    zgBGL.Tag := 1;    iCount := zgBGL.Selection.Bottom - zgBGL.Selection.Top;    zgBGL.CopyToClipboard(zgBGL.Selection.Bounds);    zgBGL.Selection.SelectRow(zgBGL.Selection.Top, zgBGL.Selection.Top + iCount - 1);  end;end;procedure TBGLFrame.zgBGLCopy(Sender: TObject; const ABounds: TRect;  var Allow: Boolean);begin  Allow := TZJGrid(Sender).Tag = 0;  if not Allow then  begin    CopyBGLBlock(ABounds);    TZJGrid(Sender).Tag := 0;  end;end;procedure TBGLFrame.CopyBGLBlock(ABounds: TRect);var  Clipboard: TBGLClipboard;begin  Clipboard := TBGLClipboard.Create(FBGLData);  try    Clipboard.Copy(ABounds.Bottom - ABounds.Top);  finally    Clipboard.Free;  end;end;procedure TBGLFrame.PasteBGLBlock;var  Clipboard: TBGLClipboard;begin  Clipboard := TBGLClipboard.Create(FBGLData);  try    Clipboard.Paste;  finally    Clipboard.Free;  end;end;procedure TBGLFrame.zgBGLPaste(Sender: TObject; const ABounds: TRect;  var Allow: Boolean);begin  if HasBGLBlockFormat then  begin    Allow := False;    PasteBGLBlock;  end;end;procedure TBGLFrame.actnCopyBGLBlockUpdate(Sender: TObject);begin  if _IsDebugView then    TAction(Sender).Visible := True  else    TAction(Sender).Visible := False;end;procedure TBGLFrame.zgBGLGetCellEditor(Sender: TObject; ACoord: TPoint;  var AControl: TWinControl);begin  if ACoord.X = zaBGL.ColumnCol('BGLType') then    AControl := cbbBGLType;end;procedure TBGLFrame.zgBGLEditorSaveCell(Sender: TObject; ACoord: TPoint;  AControl: TWinControl);begin  if AControl = cbbBGLType then  begin    zaBGL.DataSet.Edit;    if cbbBGLType.ItemIndex = -1 then      zaBGL.DataSet.FieldByName('BGLType').Clear    else      zaBGL.DataSet.FieldByName('BGLType').AsString := cbbBGLType.Text;    zaBGL.DataSet.Post;  end;end;procedure TBGLFrame.zgBGLEditorLoadCell(Sender: TObject; ACoord: TPoint;  AControl: TWinControl);begin  if AControl = cbbBGLType then    if zaBGL.DataSet.FieldByName('BGLType').AsString = '' then      cbbBGLType.ItemIndex := -1    else      cbbBGLType.Text := zaBGL.DataSet.FieldByName('BGLType').AsString;end;procedure TBGLFrame.zgBGLCellTextChanged(Sender: TObject; Col,  Row: Integer);begin  if Col = 6 then  begin    if (zgBGL.Cells[Col, Row].Text <> '') and (cbbBGLType.Items.IndexOf(zgBGL.Cells[Col, Row].Text) = -1) then      zgBGL.Cells[Col, Row].Text := '';  end;end;procedure TBGLFrame.LoadBGLFromCloud;var  sgs: TStrings;  sUrl, sInfo: string;begin  Screen.Cursor := crHourGlass;  sgs := TStringList.Create;  try    sgs.Add(Format('filter=%s', [FBGLData.AllCloudBGLWebID]));    sUrl := PHPWeb.MeasureURL + Format('change/get/%d/list', [TProjectData(FBGLData.ProjectData).WebID]);    if PHPWeb.UrlGet(sUrl, sgs, sInfo) = 1 then      FBGLData.LoadCloudBGL(sInfo)    else if sInfo <> '' then      WarningMessage(sInfo);  finally    sgs.Free;    Screen.Cursor := crDefault;  end;end;procedure TBGLFrame.zaBGLGridCellCanEdit(Sender: TObject;  const ACoord: TPoint; var Allow: Boolean);begin  if _IsCloud and Allow then    Allow := FBGLData.GetBGLCanEdit(ACoord.Y - zgBGL.FixedRowCount);end;procedure TBGLFrame.zaBGBillsGridCellCanEdit(Sender: TObject;  const ACoord: TPoint; var Allow: Boolean);begin  if _IsCloud and Allow then    Allow := not FBGLData.cdsBGLViewIsCloud.AsBoolean;end;procedure TBGLFrame.zgBGLCurrentChanged;begin  dbmPos_Reason.ReadOnly := _IsCloud and FBGLData.cdsBGLViewIsCloud.AsBoolean;  dbmDirection.ReadOnly := dbmPos_Reason.ReadOnly;end;end.
 |