⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rm_calceditor.pas

📁 进销存·完整的·有数据库的·非常完整·只得参考
💻 PAS
字号:

{*****************************************}
{                                         }
{          Report Machine v2.0            }
{          CalcMemoView Editor            }
{                                         }
{*****************************************}

unit RM_CalcEditor;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, RM_Class, Buttons;

type
  TRMCalcMemoEditorForm = class(TRMObjEditorForm)
    btnOK: TButton;
    btnCancel: TButton;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    rdgType: TRadioGroup;
    lstGroups: TListBox;
    chkResetAfterPrint: TCheckBox;
    Label2: TLabel;
    chkCalcNoVisible: TCheckBox;
    GroupBox2: TGroupBox;
    Label3: TLabel;
    edtFilter: TEdit;
    btnExpr: TSpeedButton;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    Label4: TLabel;
    Edit2: TEdit;
    SpeedButton2: TSpeedButton;
    procedure btnExprClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure rdgTypeClick(Sender: TObject);
  private
    { Private declarations }
    function GetGroupBand: string;
    procedure SetGroupBand(const Value: string);
    procedure Localize;
  public
    { Public declarations }
    function ShowEditor(View: TRMView): TModalResult; override;
    property GroupBand: string read GetGroupBand write SetGroupBand;
  end;

implementation

uses RM_Const, RM_Utils, RM_DlgExpr;

{$R *.DFM}

function TRMCalcMemoEditorForm.ShowEditor(View: TRMView): TModalResult;

  procedure FillGroups;
  var
    i, j: integer;
    t: TRMView;
    str: string;
  begin
    lstGroups.Items.Add(RMLoadStr(SNotAssigned));
    for i := 0 to CurReport.Pages.Count - 1 do
    begin
      for j := 0 to CurReport.Pages[i].Objects.Count - 1 do
      begin
        t := CurReport.Pages[i].Objects[j];
        if (t is TRMBandView) and (TRMBandView(t).BandType in [btMasterData, btDetailData, btSubDetailData]) then
        begin
          str := TRMBandView(t).Name;
          case TRMBandView(t).BandType of
            btMasterData: str := str + ' (Master Data)';
            btDetailData: str := str + ' (Detail Data)';
            btSubDetailData: str := str + ' (SubDetail Data)';
          end;
          lstGroups.Items.Add(str);
        end;
      end;
    end;
  end;

begin
  FillGroups;
  lstGroups.ItemIndex := 0;

  rdgType.ItemIndex := integer(TRMCalcMemoView(View).CalcType);
  GroupBand := TRMCalcMemoView(View).AggrBandName;
  chkResetAfterPrint.Checked := TRMCalcMemoView(View).ResetAfterPrint;
  chkCalcNoVisible.Checked := TRMCalcMemoView(View).PCalcNoVisible;
  edtFilter.Text := TRMCalcMemoView(View).Filter;
  Result := ShowModal;
  if Result = mrOK then
  begin
    RMDesigner.BeforeChange;
    TRMCalcMemoView(View).CalcType := TRMDBCalcType(rdgType.ItemIndex);
    TRMCalcMemoView(View).AggrBandName := GroupBand;
    TRMCalcMemoView(View).ResetAfterPrint := chkResetAfterPrint.Checked;
    TRMCalcMemoView(View).Filter := Trim(edtFilter.Text);
    TRMCalcMemoView(View).PCalcNoVisible := chkCalcNoVisible.Checked;
    RMDesigner.AfterChange;
  end;
end;

function TRMCalcMemoEditorForm.GetGroupBand: string;
var
  str: string;
begin
  Result := '';
  if lstGroups.ItemIndex > 0 then
  begin
    str := lstGroups.Items[lstGroups.ItemIndex];
    Result := Copy(str, 1, Pos(' ', str) - 1);
  end;
end;

procedure TRMCalcMemoEditorForm.SetGroupBand(const Value: string);
var
  i: integer;
  str: string;
begin
  for i := 0 to lstGroups.Items.Count - 1 do
  begin
    str := lstGroups.Items[i];
    str := Copy(str, 1, Pos(' ', str) - 1);
    if AnsiCompareText(Value, str) = 0 then
    begin
      lstGroups.ItemIndex := i;
      Break;
    end;
  end;
end;

procedure TRMCalcMemoEditorForm.btnExprClick(Sender: TObject);
var
  expr: string;
begin
  expr := '';
  if RM_DlgExpr.RMGetExpression('', expr, nil) then
  begin
    if expr <> '' then
    begin
      case TWinControl(Sender).Tag of
        0: edtFilter.Text := expr;
        1: Edit1.Text := expr;
        2: Edit2.Text := expr;
      end;
    end;
  end;
end;  

procedure TRMCalcMemoEditorForm.FormCreate(Sender: TObject);
begin
  Localize;
end;

procedure TRMCalcMemoEditorForm.Localize;
var
  i: Integer;
begin
  Font.Name := RMLoadStr(SRMDefaultFontName);
  Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
  Font.Charset := StrToInt(RMLoadStr(SCharset));

  RMSetStrProp(Self, 'Caption', rmRes + 770);
  RMSetStrProp(rdgType, 'Caption', rmRes + 771);
  rdgType.Items.Clear;
  for i := 0 to 4 do
    rdgType.Items.Add(RMLoadStr(rmRes + 772 + i));
  rdgType.Items.Add(RMLoadStr(rmRes + 768));
  RMSetStrProp(Label1, 'Caption', rmRes + 777);
  RMSetStrProp(Label2, 'Caption', rmRes + 778);
  RMSetStrProp(chkResetAfterPrint, 'Caption', rmRes + 779);
  RMSetStrProp(chkCalcNoVisible, 'Caption', rmRes + 769);
  RMSetStrProp(btnExpr, 'Hint', rmRes + 656);
  RMSetStrProp(Label3, 'Caption', rmRes + 767);
  RMSetStrProp(Label4, 'Caption', rmRes + 766);
  RMSetStrProp(GroupBox2, 'Caption', rmRes + 765);

  btnOK.Caption := RMLoadStr(SOK);
  btnCancel.Caption := RMLoadStr(SCancel);
end;

procedure TRMCalcMemoEditorForm.rdgTypeClick(Sender: TObject);
begin
  RMSetControlsEnable(GroupBox2, rdgType.ItemIndex = 5);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -