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

📄 ap_qry_balance.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Ap_Qry_Balance;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Panel, ActnList, Db, AdODB, ExtCtrls, ComCtrls, ToolWin, Grids,
  DBGridEh, ExtPrintReport, StdCtrls, jpeg;

Type
  TFrm_Ap_Qry_Balance = Class(TFrm_Base_Panel)
    ToolButton2: TToolButton;
    ToolButton4: TToolButton;
    DataSource1: TDataSource;
    DBGridEh1: TDBGridEh;
    ToolButton1: TToolButton;
    ToolButton3: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ExtPrintReport1: TExtPrintReport;
    AdoQry_Main: TAdoQuery;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Act_ExcelExecute(Sender: TObject);
    procedure Act_PreviewExecute(Sender: TObject);
    procedure Act_PrintExecute(Sender: TObject);
  private
    { Private declarations }
    procedure SetReport;
  public
    { Public declarations }
  procedure InitForm(AdoConnection:TAdoConnection);
  end;

var
  Frm_Ap_Qry_Balance: TFrm_Ap_Qry_Balance;

implementation

uses Sys_Global;

{$R *.DFM}

{ TFrm_Ap_Qry_Balance }

procedure TFrm_Ap_Qry_Balance.InitForm(AdoConnection: TAdoConnection);
begin
  SetDBConnect(AdoConnection);
  AdoQry_Main.Connection :=AdoConnection ;
  AdoQry_Tmp.Connection := AdoConnection ;
  with AdoQry_Main do
  begin
    Close;
    sql.clear;
    sql.Add('select ApBalance.ApBalanceMonth, '+
                    '  ApBalance.VendorCode +'' ''+Vendor.VendorName as VendorCodeName,'+
                    '  Vendor.CurrencyCode+'' ''+Currency.CurrencyName  as CurrencyCodeName,'+
                    '  ApBalance.InvoiceBalance,'+
                    '  ApBalance.NoInviceBalance  '+
                    '  from Vendor left join Currency '+
                    '    on Vendor.CurrencyCode=Currency.CurrencyCode'+
                    '  left join ApBalance '+
                    '    on ApBalance.VendorCode=Vendor.VendorCode '+
                    '  where ApBalanceMonth is not null ' );
   open;
   if AdoQry_Main.recordCount= 0 then
    begin
      DispInfo('没有资料!',3);
      abort;
    end;
    Pnl_Hint.Caption:='提示:共有'+Inttostr(AdoQry_Main.recordCount)+'资料';

  end;
end;

procedure TFrm_Ap_Qry_Balance.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action:=CaFree;
end;

procedure TFrm_Ap_Qry_Balance.Act_ExcelExecute(Sender: TObject);
begin
  inherited;
  DBGridEhToExcel(Dbgrideh1);
end;

procedure TFrm_Ap_Qry_Balance.SetReport;
var
  i,j:integer;
begin
  inherited;
  ExtPrintReport1.DataSet :=nil;
  ExtPrintReport1.Headers.clear;
  i:=0;
  with ExtPrintReport1 do
  begin
    for j:=0 to DBGridEH1.Columns.Count-1 do
      if DBGridEH1.Columns[j].Visible then
      begin
        Headers.Add;
        Headers.Items[i].Caption :=DBGridEH1.Columns[j].Title.Caption;
        Headers.Items[i].FieldName :=DBGridEH1.Columns[j].FieldName;
        Headers.Items[i].DisplayWidth:=DBGridEH1.Columns[j].Width div (DBGridEH1.Columns[j].Font.Size-2);
        Headers.Items[i].Alignment :=DBGridEH1.Columns[j].Alignment;
        inc(i);
      end;
    DataSet:=AdoQry_Main;

    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:='Select SysParamValueC '+
                         'From SysParam '+
                         'where SysParamCode=''Name0''';//Name0是使用本系统的客户的名称
    AdoQry_Tmp.Open;
    ExtPrintReport1.Title1:=AdoQry_Tmp.fieldbyname('SysParamValueC').AsString;
    ExtPrintReport1.Title2:=Pnl_Title.Caption;
    //ExtPrintReport1.Subtitle3:=Lbl_include1.Caption+Lbl_include.Caption;//排序字段中文名;
   // ExtPrintReport1.Subtitle3:=label1.Caption//排序字段中文名;
  end;
end;

procedure TFrm_Ap_Qry_Balance.Act_PreviewExecute(Sender: TObject);
begin
  inherited;
  SetReport;
  ExtPrintReport1.preview;

end;

procedure TFrm_Ap_Qry_Balance.Act_PrintExecute(Sender: TObject);
begin
  inherited;
  SetReport;
  ExtPrintReport1.print(self);
end;

end.

⌨️ 快捷键说明

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