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

📄 unmakereportdetail.pas

📁 本产品是开发LISTVIEW相关功能的可定制产品
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>2))then
    begin
        vShape2.Left:=vShape1.Left+ColumnWidth[1];
        vShape2.Width:=ColumnWidth[2];
        vLabel2.Left:=vShape2.Left+6;
        vLabel2.Width:=ColumnWidth[2]-9;
        vLabel2.Caption:= sgNormal.Cells[2,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>3))then
    begin
        vShape3.Left:=vShape2.Left+ColumnWidth[2];
        vShape3.Width:=ColumnWidth[3];
        vLabel3.Left:=vShape3.Left+6;
        vLabel3.Width:=ColumnWidth[3]-9;
        vLabel3.Caption:= sgNormal.Cells[3,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>4))then
    begin
        vShape4.Left:=vShape3.Left+ColumnWidth[3];
        vShape4.Width:=ColumnWidth[4];
        vLabel4.Left:=vShape4.Left+6;
        vLabel4.Width:=ColumnWidth[4]-9;
        vLabel4.Caption:= sgNormal.Cells[4,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>5))then
    begin
        vShape5.Left:=vShape4.Left+ColumnWidth[4];
        vShape5.Width:=ColumnWidth[5];
        vLabel5.Left:=vShape5.Left+6;
        vLabel5.Width:=ColumnWidth[5]-9;
        vLabel5.Caption:= sgNormal.Cells[5,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>6))then
    begin
        vShape6.Left:=vShape5.Left+ColumnWidth[5];
        vShape6.Width:=ColumnWidth[6];
        vLabel6.Left:=vShape6.Left+6;
        vLabel6.Width:=ColumnWidth[6]-9;
        vLabel6.Caption:= sgNormal.Cells[6,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>7))then
    begin
        vShape7.Left:=vShape6.Left+ColumnWidth[6];
        vShape7.Width:=ColumnWidth[7];
        vLabel7.Left:=vShape6.Left+6;
        vLabel7.Width:=ColumnWidth[7]-9;
        vLabel7.Caption:= sgNormal.Cells[7,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>8))then
    begin
        vShape8.Left:=vShape7.Left+ColumnWidth[7];
        vShape8.Width:=ColumnWidth[8];
        vLabel8.Left:=vShape8.Left+6;
        vLabel8.Width:=ColumnWidth[8]-9;
        vLabel8.Caption:= sgNormal.Cells[8,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>9))then//如果打印行数大于6,且打印列数大于9
    begin
        vShape9.Left:=vShape8.Left+ColumnWidth[8];
        vShape9.Width:=ColumnWidth[9];
        vLabel9.Left:=vShape9.Left+6;
        vLabel9.Width:=ColumnWidth[9]-9;
        vLabel9.Caption:= sgNormal.Cells[9,6];
    end;
    if((sgNormal.RowCount>6) and (sgNormal.ColCount>10))then//如果打印行数大于6,且打印列数大于10
    begin
        vShape10.Left:=vShape9.Left+ColumnWidth[9];
        vShape10.Width:=ColumnWidth[10];
        vLabel10.Left:=vShape10.Left+6;
        vLabel10.Width:=ColumnWidth[10]-9;
        vLabel10.Caption:= sgNormal.Cells[10,6];
    end;
// 位置--eighth行
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>0))then
    begin
        QRLabel0.Left:=fShape0.Left+6;
        zShape0.Left:=0;
        zShape0.Width:=ColumnWidth[0];
        zLabel0.Left:=zShape0.Left+6;
        zLabel0.Width:=ColumnWidth[0]-9;
        zLabel0.Caption:= sgNormal.Cells[0,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>1))then
    begin
        zShape1.Left:=zShape0.Left+ColumnWidth[0];
        zShape1.Width:=ColumnWidth[1];
        zLabel1.Left:=zShape1.Left+6;
        zLabel1.Width:=ColumnWidth[1]-9;
        zLabel1.Caption:= sgNormal.Cells[1,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>2))then
    begin
        zShape2.Left:=zShape1.Left+ColumnWidth[1];
        zShape2.Width:=ColumnWidth[2];
        zLabel2.Left:=zShape2.Left+6;
        zLabel2.Width:=ColumnWidth[2]-9;
        zLabel2.Caption:= sgNormal.Cells[2,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>3))then
    begin
        zShape3.Left:=zShape2.Left+ColumnWidth[2];
        zShape3.Width:=ColumnWidth[3];
        zLabel3.Left:=zShape3.Left+6;
        zLabel3.Width:=ColumnWidth[3]-9;
        zLabel3.Caption:= sgNormal.Cells[3,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>4))then
    begin
        zShape4.Left:=zShape3.Left+ColumnWidth[3];
        zShape4.Width:=ColumnWidth[4];
        zLabel4.Left:=zShape4.Left+6;
        zLabel4.Width:=ColumnWidth[4]-9;
        zLabel4.Caption:= sgNormal.Cells[4,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>5))then
    begin
        zShape5.Left:=zShape4.Left+ColumnWidth[4];
        zShape5.Width:=ColumnWidth[5];
        zLabel5.Left:=zShape5.Left+6;
        zLabel5.Width:=ColumnWidth[5]-9;
        zLabel5.Caption:= sgNormal.Cells[5,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>6))then
    begin
        zShape6.Left:=zShape5.Left+ColumnWidth[5];
        zShape6.Width:=ColumnWidth[6];
        zLabel6.Left:=zShape6.Left+6;
        zLabel6.Width:=ColumnWidth[6]-9;
        zLabel6.Caption:= sgNormal.Cells[6,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>7))then
    begin
        zShape7.Left:=zShape6.Left+ColumnWidth[6];
        zShape7.Width:=ColumnWidth[7];
        zLabel7.Left:=zShape6.Left+6;
        zLabel7.Width:=ColumnWidth[7]-9;
        zLabel7.Caption:= sgNormal.Cells[7,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>8))then
    begin
        zShape8.Left:=zShape7.Left+ColumnWidth[7];
        zShape8.Width:=ColumnWidth[8];
        zLabel8.Left:=zShape8.Left+6;
        zLabel8.Width:=ColumnWidth[8]-9;
        zLabel8.Caption:= sgNormal.Cells[8,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>9))then//如果打印行数大于7,且打印列数大于9
    begin
        zShape9.Left:=zShape8.Left+ColumnWidth[8];
        zShape9.Width:=ColumnWidth[9];
        zLabel9.Left:=zShape9.Left+6;
        zLabel9.Width:=ColumnWidth[9]-9;
        zLabel9.Caption:= sgNormal.Cells[9,7];
    end;
    if((sgNormal.RowCount>7) and (sgNormal.ColCount>10))then//如果打印行数大于7,且打印列数大于10
    begin
        zShape10.Left:=zShape9.Left+ColumnWidth[9];
        zShape10.Width:=ColumnWidth[10];
        zLabel10.Left:=zShape10.Left+6;
        zLabel10.Width:=ColumnWidth[10]-9;
        zLabel10.Caption:= sgNormal.Cells[10,7];
    end;

  end;
end;

function TMakeReportDetail.DoOnlyDetailPreviewNew(fReportFormName: TForm;
  Rlist: TList; sReportName, sDataBaseName, sSessionName, ReportFormTitle,
  UnitCaption, ReportCaption, sStaffName: string; PrintDate: TDate;
  PaperSize: TQRPaperSize; MemoData: TMemo): Integer;
begin
//将传递过来的参数初始化
  result:=0;
  PrintColumnNum:=0;
  ReportForm:=fReportFormName;
  ReportFormName:=ReportForm.Name;
  ReportName:=sReportName;
  DataBaseName:=sDataBaseName;
  SessionName:=sSessionName;
  GetColumnDefineFromTable;        //按照打印列定义从LISTVIEW中取出打印数据
  if(PrintColumnNum=0)then exit;   //打印列数=0,表示不用打印
  if Rlist.Count <= 0 then exit;  //LISTVIEW中无数据,表示不用打印
  ReportDataSet :=GetDataSetFromList(Rlist); //从SOURCELISTVIEW中取各行数据到ReportDataSet中
  try
     FrmUniversalReport := TFrmReport.Create(nil);
  except//创建打印窗体异常后的处理
      ReportDataSet.Close;
      ReportDataSet.Free;
      ReportDataSet:=nil;
      Showmessage('请检查打印机是否有效且可用!');
      Exit;
  end;
  with FrmUniversalReport do
  begin
      Caption:=ReportFormTitle;
      FrmUnitName1.Caption:=UnitCaption;
      FrmUnitName2.Caption:=UnitCaption;
      FrmReportCaption.Caption:=ReportCaption;
      FrmPrintDate1.Caption:=Datetostr(PrintDate);
      FrmPrintDate2.Caption:=FrmPrintDate1.Caption;
      QRLabel11.Caption:='制表人:'+sStaffName;
      PrintReport.Page.PaperSize:=PaperSize;/////////////确定打印方式
      If PrintModal=0 then
         PrintReport.Page.Orientation:=poPortrait///////////
      else
         PrintReport.Page.Orientation:=poLandscape;///////////
      FrmReportCaption.Left:=((ChildBand1.Width-FrmReportCaption.Width) div 2);//确定标题显示位置
      FrmPrintDate1.Left:=ChildBand1.Width+ChildBand1.Left-160;       //确定日期显示位置
      FrmPrintDate2.Left:=ChildBand1.Width+ChildBand1.Left-150;       //确定日期显示位置
      FrmMemo.Left:=ChildBand1.Width+ChildBand1.Left-500;             //确定备注信息显示位置
      QRSysData2.Left:=(ChildBand1.Width div 2)+ChildBand1.Left-70;
      QRLabel11.Left:=ChildBand1.Width+ChildBand1.Left-250;
      if MemoData<>nil then
         FrmMemo.lines:=MemoData.lines;                               //显示备注信息
      PrintReport.Bands.HasSummary := False;
      MakeDetailBand;           //调用创建明细信息
      if printer.Printers.Count <> 0 then
      begin
          FrmUniversalReport.PrintReport.PreviewModal;
      end
      else
          Application.MessageBox('没有缺省打印机!,请添加打印机后重试。','系统提示',MB_ok);
      ReportDataSet.Close;
      ReportDataSet.Free;
      ReportDataSet:=nil;
  end;
  FrmUniversalReport.Close;
  FrmUniversalReport.Free;
  FrmUniversalReport:=nil;
  result:=999;
end;

function TMakeReportDetail.DoAllPreviewNew(fReportFormName: TForm;
  Rlist: TList; sReportName, sDataBaseName, sSessionName,
  ReportFormTitle, UnitCaption, ReportCaption, sStaffName: string;
  PrintDate: TDate; PaperSize: TQRPaperSize; MemoData: TMemo;
  sStringGrid: TStringGrid): Integer;
begin
//参数初始化及赋值
  result:=0;
  PrintColumnNum:=0;
  ReportForm:=fReportFormName;
  ReportFormName:=ReportForm.Name;
  ReportName:=sReportName;
  DataBaseName:=sDataBaseName;
  SessionName:=sSessionName;
  GetColumnDefineFromTable;//取得打印数据
  if(PrintColumnNum=0)then exit;//无打印列退出
  ReportDataSet :=GetDataSetFromList(Rlist); //从SOURCELISTVIEW中取各行数据到ReportDataSet中
  try
     FrmUniversalReport := TFrmReport.Create(nil);
  except//创建打印窗体异常处理
      ReportDataSet.Close;
      ReportDataSet.Free;
      ReportDataSet:=nil;
      Showmessage('请检查打印机是否有效且可用!');
      Exit;
  end;
  with FrmUniversalReport do
  begin
      Caption:=ReportFormTitle;
      FrmUnitName1.Caption:=UnitCaption;
      FrmUnitName2.Caption:=UnitCaption;
      FrmReportCaption.Caption:=ReportCaption;
      FrmPrintDate1.Caption:=Datetostr(PrintDate);
      FrmPrintDate2.Caption:=FrmPrintDate1.Caption;
      QRLabel11.Caption:='制表人:'+sStaffName;
      PrintReport.Page.PaperSize:=PaperSize;//////////打印纸张选择
      If PrintModal=0 then
         PrintReport.Page.Orientation:=poPortrait///////////打印模式选择
      else
         PrintReport.Page.Orientation:=poLandscape;///////////
//各元素打印位置确定
      FrmReportCaption.Left:=((ChildBand1.Width-FrmReportCaption.Width) div 2);
      FrmPrintDate1.Left:=ChildBand1.Width+ChildBand1.Left-160;
      FrmPrintDate2.Left:=ChildBand1.Width+ChildBand1.Left-150;
      FrmMemo.Left:=ChildBand1.Width+ChildBand1.Left-500;
      QRSysData2.Left:=(ChildBand1.Width div 2)+ChildBand1.Left-70;
      QRLabel11.Left:=ChildBand1.Width+ChildBand1.Left-250;
      QRShape1.Width:=arbStatics.Width-24;
      if MemoData<>nil then//备注信息显示
         FrmMemo.lines:=MemoData.lines;
      PrintReport.Bands.HasColumnHeader := True;//需要打印明细域
      PrintReport.Bands.HasDetail := True;
      MakeDetailBand;                   //创建明细数据打印
      MakeTotalBand(sStringGrid);       //创建汇总数据打印
      if printer.Printers.Count <> 0 then
          PrintReport.PreviewModal   //打印域览
      else
          Application.MessageBox('没有缺省打印机!,请添加打印机后重试。','系统提示',MB_ok);
      ReportDataSet.Close;//内存释放
      ReportDataSet.Free;
      ReportDataSet:=nil;
  end;
  FrmUniversalReport.Close;//内存释放
  FrmUniversalReport.Free;
  FrmUniversalReport:=nil;
  result:=999;
end;


function TMakeReportDetail.GetDataSetFromList(Rlist: TList): TClientDataSet;
var q:PMListData;
    I,j,k :Integer;
begin
  Result := TClientDataSet.Create(nil);
  Result.ReadOnly := False;
  Result.Close;
  with Result.FieldDefs do
  begin
//为定制报表,需要用户在窗体初始化时创建一个TListViewColumn型数组并填充如下内容
    i:=0;
    while i<PrintColumnNu

⌨️ 快捷键说明

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