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

📄 panelunit.pas

📁 一个报表控件TRepoEdit
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    EditCaption.Update;
    EditCaption.Items.Clear;

    if selected is TQRDBText then begin
      EditCaption.Style:=csDropDown;
      for i:=0 to selected.Owner.ComponentCount-1 do
        if (selected.Owner.components[i] is TDataSet) then begin
           ThDataSet:=TDataSet(selected.Owner.components[i]);
           for k:=0 to ThDataSet.FieldCount-1 do begin
             EditCaption.Items.Add(ThDataSet.Fields[k].FieldName);
           end;
        end;
      EditCaption.Text:=(Selected as TQRDBText).DataField;
    end
    else
    if selected is TQRDBImage then begin
      EditCaption.Style:=csDropDown;
      for i:=0 to selected.Owner.ComponentCount-1 do
        if (selected.Owner.components[i] is TDataSet) then begin
           ThDataSet:=TDataSet(selected.Owner.components[i]);
           for k:=0 to ThDataSet.FieldCount-1 do begin
             EditCaption.Items.Add(ThDataSet.Fields[k].FieldName);
           end;
        end;
      EditCaption.Text:=(selected as TQRDBImage).DataField;
    end
    else
    if selected is TQREXPR then EditCaption.Text:=(selected as TQREXPR).Expression
    else
    if selected is TQRSysData then EditCaption.Text:=(selected as TQRsysdata).Text
    else
    if selected is TQRCustomLabel then EditCaption.Text:=(selected as TQRCustomlabel).Caption
    else begin
       EditCaption.Enabled:=false;
       EditCaption.text:='';
    end;

    editLines.Enabled:=true;
  end
  else begin
    EditTop.enabled:=false;
    EditWidth.enabled:=false;
    EditLeft.enabled:=false;
    EditHeight.enabled:=false;
    LabTop.enabled:=false;
    LabWidth.enabled:=false;
    LabLeft.enabled:=false;
    LabHeight.enabled:=false;

    EditTop.OnChange:=nil;
    EditWidth.Onchange:=nil;
    EditLeft.OnChange:=nil;
    EditHeight.OnChange:=nil;
    EditTop.Value:=0;
    EditWidth.Value:=0;
    EditLeft.Value:=0;
    EditHeight.Value:=0;
    EditTop.OnChange:=EditLeftChange;
    EditWidth.Onchange:=EditwidthChange;
    EditLeft.OnChange:=EditLeftChange;
    EditHeight.OnChange:=EditLeftChange;
    EditEnabled.Enabled:=false;
    EditEnabled.Checked:=false;
    editCaption.Enabled:=false;
    EditCaption.Text:='';
    EditLines.Enabled:=false;
  end;

end;


procedure TPanelForm.SetEnabledBV(Value:boolean);
begin
end;

procedure TPanelForm.FormDestroy(Sender: TObject);
var i:integer;
begin
  if owner is TRepoEdit then (Owner as TRepoEdit).thPanel:=nil;
  for i:=0 to Self.ComponentCount-1 do begin
     if (Self.Components[i] is TToolBar)
     then
     with Self.Components[i] as tToolbar do begin
            RepoEdit.IniFile.WriteInteger(SElf.ClassName,Name+'_Left',Left);
            RepoEdit.IniFile.WriteInteger(SElf.ClassName,Name+'_Top',Top);
     end
  end;
end;

procedure TPanelForm.FormCreate(Sender: TObject);
var i:integer;
    thComp:TComponent;
begin
  FOldOnClose:=nil;
  CannotSave:=false;
  EditFont.items.Clear;
  EditFont.Items:=qrPrntr.GetFonts;
  EditFont.Sorted := True;
  EditFontSize.Items.clear;
  PopulateFontSizeCombo(EditFontSize);
  SetFontButtons;

  IniCheck;
  try
  for i:=0 to Self.ComponentCount-1 do begin
     THComp:=Self.Components[i];
     if (ThComp is TToolBar)
     then begin
//        if (ThComp as TToolBar).Wrapable then  (ThComp as TToolBar).Wrapable:=false;
//        if not (ThComp as TToolBar).AutoSize then  (ThComp as TToolBar).AutoSize:=true;

//        (ThComp as TToolBar).Visible:=MyIniFile.ReadBool(Self.ClassName,(ThComp as TToolBar).Name+'_Visible',(ThComp as TToolBar).Visible);
        (ThComp as TToolBar).Left:=REpoEdit.IniFile.ReadInteger(Self.ClassName,(ThComp as TToolBar).Name+'_Left',(ThComp as TToolBar).Left);
        (ThComp as TToolBar).Top:=REpoEdit.IniFile.readInteger(Self.ClassName,(ThComp as TToolBar).Name+'_Top',(ThComp as TToolBar).Top);
     end;
  end;
  except
  end;

end;

procedure TPanelForm.ThOnClose(Sender: TObject; var Action: TCloseAction);
var //i:integer;
//    ThComp:TComponent;
    Res:TModalResult;
begin
  if not CannotSave then Res:=GetConfirm('Save changes ?')
  else begin
    Res:=mrCancel;
    CannotSave:=false;
  end;
  if Res=mrOk then  BtnSave.Click
  else if Res=mrIgnore then begin
    Action:=caNone;
    exit;
  end;

  (Sender as TForm).OnClose:=OldOnClose;
//  Self.Free;
end;


procedure TPanelForm.EditHideDisabledClick(Sender: TObject);
var i:integer;
begin
 with (Owner as TrepoEdit).mainwin do
 for i:=0 to ComponentCount-1 do
 if not (Components[i] is Tquickrep)
    and
    (Components[i] is TControl)
    and
    not (Components[i] as TControl).enabled
 then begin
   (Components[i] as TControl).Visible:=EditHideDisabled.Down
 end;
 (Owner as TRepoEdit).thForm.Repaint;
end;

procedure TPanelForm.SpButtonPlusClick(Sender: TObject);
begin
  with TGetNewTypeForm.create(Owner) do
  try
    Parent:=Self.Parent;
    ShowModal;
  finally
    free;
  end
end;


procedure TPanelForm.RichText1Click(Sender: TObject);
var ThName:string;
    i:integer;
begin
 (Owner as TRepoEdit).AppendObj:=TQRRichText.Create((Owner as TRepoEdit).MainWin);
 i:=1;
 repeat
   ThName:='New_RichText'+inttostr(i);
   if ((Owner as TRepoEdit).MainWin.FindComponent(ThName)<>nil)
      then ThName:='';
   if ThName<>'' then   (Owner as TRepoEdit).AppendObj.Name:=ThName;
   inc(i);
 until ThName<>'';
end;

procedure TPanelForm.N9Click(Sender: TObject);
var ThName:string;
    i:integer;
    ThBand:TQRBand;
begin
   ThBand:=TQRBand.Create((Owner as TRepoEdit).Mainwin);
   ThBand.BandType:=rbsummary;
   thBand.ParentReport:=(Owner as TRepoEdit).ThReport;
   ThBand.Parent:=(Owner as TRepoEdit).ThReport;
   (Owner as trepoEdit).SetEvents;
   i:=1;
   repeat
     ThName:='New_Band'+inttostr(i);
     if ((Owner as TRepoEdit).mainWin.FindComponent(ThName)<>nil)
        then ThName:='';
     if ThName<>'' then   ThBand.Name:=ThName;
     inc(i);
   until ThName<>'';

end;

procedure TPanelForm.SpeedButton1Click(Sender: TObject);
begin
  with TEditFileForm.Create(Application) do
  try
    if RepoEdit.TaReport.databaseName<>'' then Table.TableName:=RepoEdit.taReport.databaseName;
    Table.Tablename:=RepoEdit.taReport.tableName;
    Table.Open;
    Showmodal;
    if table.State in [dsEdit,dsInsert] then Table.Post;
    Table.FlushBuffers;
  finally
    Free;
  end;
end;

procedure TPanelForm.BtnDeleteClick(Sender: TObject);
begin
  if (GetConfirmSmall('Delete current variant?')=mrOk)
  then begin
    (Owner as TRepoEdit).DeleteSavedReport(True);
    bvMess('Current variant is successfully deleted!');
    CAnnotSave:=true;
    self.Close;
    exit;
  end;

end;


procedure TPanelForm.SpeedButtonClearClick(Sender: TObject);
begin
  if (GetConfirmSmall('You need clear current variant, without deleting?')=mrOk)
  then begin
    (Owner as TRepoEdit).DeleteSavedReport(false);
    bvMess('All changes in current variant are deleted!');
    CAnnotSave:=true;
    self.Close;
    exit;
  end;

end;

procedure TPanelForm.BtnFontClick(Sender: TObject);
var Selected:TWinControl;
begin
  if owner is TRepoEdit then Selected:=(Owner as TRepoEdit).Selected
  else Selected:=nil;

  if FontDialog.Execute
     and Assigned(selected)
     and ((Selected is TQRCustomLabel)
          or (Selected is TQRCustomRichText)
          or (Selected is TQRCustomBand)
          or (Selected is TQuickRep)
         )
  then begin
    if Selected is TQuickRep then (Selected as TQuickRep).Font:=FontDialog.Font
    else if Selected is TqrCustomLabel then (Selected as TqrCustomLabel).Font:=FontDialog.Font
    else if Selected is TqrCustomRichText then (Selected as TqrCustomRichText).Font:=FontDialog.Font
    else (Selected as TqrCustomBand).Font:=FontDialog.Font;
  end;

  SEtFontButtons;
  SetFontValues;
end;

procedure TPanelForm.EditFontChange(Sender: TObject);
begin
  SetFontValues;
end;

procedure TPanelForm.BtnFontBoldClick(Sender: TObject);
begin
  SetFontValues;
end;

procedure TPanelForm.BtnMinusClick(Sender: TObject);
var Selected:TWinControl;
begin
   if owner is TRepoEdit then Selected:=(Owner as TRepoEdit).Selected
   else Selected:=nil;

   if assigned(Selected) and (pos('New_',SElected.Name)=1)
   then
   try
     selected.free;
     Selected:=nil;
     (Owner as TRepoEdit).ThForm.Repaint;
   except
     on e:exception do bvMessError('湾 祛泱 箐嚯栩

⌨️ 快捷键说明

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