<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>打印控件示例</title>

<script language="javascript">
  function PreviewDeposit()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositPreview"
    document.FrmWebPrint.submit();
  }

  function DesignDeposit()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositDesign"
    document.FrmWebPrint.submit();
  }

  function DesignDepositPost()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositDesignPost"
    document.FrmWebPrint.submit();
  }
  function PrintDeposit()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositPrint"
    document.FrmWebPrint.submit();
  }

  function PreviewMaster()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=MasterPreview"
    document.FrmWebPrint.submit();
  }

  function DesignMaster()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=MasterDesign"
    document.FrmWebPrint.submit();
  }

  function PreviewPicture()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=PicturePreview"
    document.FrmWebPrint.submit();
  }
  
  function DesignPicture()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=PictureDesign"
    document.FrmWebPrint.submit();
  }

  function PreviewDepositD()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositPreviewD"
    document.FrmWebPrint.submit();
  }


  function PrintDepositD()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=DepositPrintD"
    document.FrmWebPrint.submit();
  }

  function PreviewMasterD()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=MasterPreviewD"
    document.FrmWebPrint.submit();
  }

  function PreviewPictureD()
  {
    document.FrmWebPrint.action = "Default.asp?PrintType=PicturePreviewD"
    document.FrmWebPrint.submit();
  }
  

</script>

</head>

<body>
  <%
    PrintType = Request.QueryString("PrintType")


    if PrintType = "DepositPreview" then
        '票据预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.PrintURL='http://www.xinyuerj.com/ASPPost/PrintNum.asp?FileName=DepsitAmt.fr3';" _
          & " ObjPrintMange.PageSetURL='http://www.xinyuerj.com/ASPPost/PageSet.asp?FileName=DepsitAmt.fr3';" _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "DepositDesign" then
        '票据编辑
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.ReportFileName='DepositAmt.fr3'; "_
          & " ObjPrintMange.DesignReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "DepositDesignPost" then
        '票据编辑，Post方式保存
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.ReportFileName='DepositAmt.fr3'; "_
          & " ObjPrintMange.PostURL='http://www.xinyuerj.com/ASPPost/Show.asp?FileName=DepsitAmt.fr3'; "_
          & " ObjPrintMange.DesignReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "DepositPrint" then
        '票据打印
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.PrintReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; " _
          & " window.location='./Default.asp'; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "MasterPreview" then
        '主从报表预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select * from InInfo "
        rs.Open(strSql)
        PrintValue1 = TableToStr(rs)
        rs.close()

        strSql = "select * from InMaterial "
        rs.Open(strSql)
        PrintValue2 = TableToStr(rs)
        rs.close()

        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\InInfo.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        'ObjPrintMange.MasterOptions 主从关系，参数：主数据集序号，关联字段名，字段是否为数值型
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.MasterOptions(1, 'InNo', 0 );" _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue1 & "', '" _
          & PrintValue2 & "', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "MasterDesign" then
        '主从报表编辑
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select * from InInfo "
        rs.Open(strSql)
        PrintValue1 = TableToStr(rs)
        rs.close()

        strSql = "select * from InMaterial "
        rs.Open(strSql)
        PrintValue2 = TableToStr(rs)
        rs.close()

        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\InInfo.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        'ObjPrintMange.MasterOptions 主从关系，参数：主数据集序号，关联字段名，字段是否为数值型
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.MasterOptions(1, 'InNo', 0 );" _
          & " ObjPrintMange.ReportFileName='InInfo.fr3'; "_
          & " ObjPrintMange.DesignReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue1 & "', '" _
          & PrintValue2 & "', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "PicturePreview" then
        '含图片报表预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "Select * From MaterialInfo "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        PictureStr = TablePictureToStr(rs, "PictureFile")
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\Material.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        '单个图片
        PictureFile = "Title.bmp"
        PictureValue = FileToStr(".\Image\" + PictureFile)
        PictureStr = PictureStr & "ObjPrintMange.SavePictureFile('" & PictureFile & "' , '" & PictureValue & "' );"

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        '增加单个图片打印，参数：报表中图片对象名，数据表的字段（为0），图片文件名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        '增加数据表中的图片打印，参数：报表中图片对象名，数据表的字段（为1），图片文件名所对应的字段名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & PictureStr _
          & "ObjPrintMange.AddPicturePrint('PicTitle', 0, 'Title.bmp','1', 1 );" _
          & "ObjPrintMange.AddPicturePrint('PicMaterial', 1, 'PictureFile','1', 0 );" _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "PictureDesign" then
        '含图片报表编辑
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "Select * From MaterialInfo "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        PictureStr = TablePictureToStr(rs, "PictureFile")
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\Material.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        '单个图片
        PictureFile = "Title.bmp"
        PictureValue = FileToStr(".\Image\" + PictureFile)
        PictureStr = PictureStr & "ObjPrintMange.SavePictureFile('" & PictureFile & "' , '" & PictureValue & "' );"

        'ObjPrintMange.CheckReg 为注册函数，参数：公司名称，注册码
        '增加单个图片打印，参数：报表中图片对象名，数据表的字段（为0），图片文件名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        '增加数据表中的图片打印，参数：报表中图片对象名，数据表的字段（为1），图片文件名所对应的字段名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckReg('公司名称', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & PictureStr _
          & "ObjPrintMange.AddPicturePrint('PicTitle', 0, 'Title.bmp','1', 1 );" _
          & "ObjPrintMange.AddPicturePrint('PicMaterial', 1, 'PictureFile','1', 0 );" _
          & " ObjPrintMange.ReportFileName='Material.fr3'; "_
          & " ObjPrintMange.DesignReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "DepositPreviewD" then
        '票据预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckDomainName 为按服务器域名注册的函数，参数：域名，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckDomainName('192.168.1.83', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "DepositPrintD" then
        '票据打印
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select top 1 * from CashLog "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\DepositAmt.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName`~PrintDepositAdd`~PrintPaperNo`~Title"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店" _
                  & "`~说明：本单据为贵客押金收取凭证，盖章有效。退房时请出示，遗失者自负，请妥善保存。退房时间为12:00时，延时退房18:00时以前按半天房费收取，18:00时以后算全天房价。押金单有效期为一个月，过期作废。       贵重物品请交前台寄存，未寄存丢失自负。      谢谢！" _
                  & "`~身份证：4325011980639512" _
                  & "`~押金单"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckDomainName 为按服务器域名注册的函数，参数：域名，注册码
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckDomainName('192.168.1.83', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.PrintReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; " _
          & " window.location='./Default.asp'; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "MasterPreviewD" then
        '主从报表预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "select * from InInfo "
        rs.Open(strSql)
        PrintValue1 = TableToStr(rs)
        rs.close()

        strSql = "select * from InMaterial "
        rs.Open(strSql)
        PrintValue2 = TableToStr(rs)
        rs.close()

        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\InInfo.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        'ObjPrintMange.CheckDomainName 为按服务器域名注册的函数，参数：域名，注册码
        'ObjPrintMange.MasterOptions 主从关系，参数：主数据集序号，关联字段名，字段是否为数值型
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckDomainName('192.168.1.83', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & " ObjPrintMange.MasterOptions(1, 'InNo', 0 );" _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue1 & "', '" _
          & PrintValue2 & "', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    elseif PrintType = "PicturePreviewD" then
        '含图片报表预览
        Set dataConnect= Server.CreateObject("ADODB.Connection")
        dataConnect.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("db1.mdb")
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = dataConnect
        strSql = "Select * From MaterialInfo "
        rs.Open(strSql)
        PrintValue = TableToStr(rs)
        PictureStr = TablePictureToStr(rs, "PictureFile")
        rs.close()
        dataConnect.Close()

        FileValue = FileToStr( ".\Frp\Material.fr3")
		'各参数的分隔符为`~
        ParaName = "ShopName"
        ParaName = Replace(ParaName, chr(39), chr(92)&chr(39) )
        ParaValue = "测试酒店"
        ParaValue = Replace(ParaValue, chr(39), chr(92)&chr(39) )

        '单个图片
        PictureFile = "Title.bmp"
        PictureValue = FileToStr(".\Image\" + PictureFile)
        PictureStr = PictureStr & "ObjPrintMange.SavePictureFile('" & PictureFile & "' , '" & PictureValue & "' );"

        'ObjPrintMange.CheckDomainName 为按服务器域名注册的函数，参数：域名，注册码
        '增加单个图片打印，参数：报表中图片对象名，数据表的字段（为0），图片文件名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        '增加数据表中的图片打印，参数：报表中图片对象名，数据表的字段（为1），图片文件名所对应的字段名，数据集序号，是否清除旧数据（第1次调用时为1，其它时候则为0）
        ScriptStr = "<script language='javascript'>window.onload = function() { try { var ObjPrintMange =  new ActiveXObject('WebPrint.WebPrintUnit'); } catch(e) { if( confirm('打印控件未安装，现在下载吗?') ) { window.location='./PrintActivex.exe'; } return; } var OldVersion=ObjPrintMange.Version; NewVerion='5.0(2011-08-01)'; if(OldVersion < NewVerion) { ObjPrintMange = null; alert('打印控件需升级。请先进行下载，下载后关闭IE，然后安装升级版。'); window.location='./PrintActivex.exe'; return;  } " _
          & " ObjPrintMange.CheckDomainName('192.168.1.83', '3B8E5B998A3125EE89983EA940BB2AEE'); " _
          & PictureStr _
          & "ObjPrintMange.AddPicturePrint('PicTitle', 0, 'Title.bmp','1', 1 );" _
          & "ObjPrintMange.AddPicturePrint('PicMaterial', 1, 'PictureFile','1', 0 );" _
          & " ObjPrintMange.ShowReport('"_
          & FileValue  & "' , '"_
          & ParaName & "', '"_
          & ParaValue & "', '"_
          & PrintValue & "', '', '', '', '', ''); " _
          & "ObjPrintMange = null; } </script>"
        Response.Write(ScriptStr)
    end if

    Function TableToStr(ADORs)
        Set xmldoc = server.CreateObject("MSXML2.DOMDocument.3.0")
        ADORs.MoveFirst()
        ADORs.save xmldoc, 1
        FileStr = xmldoc.documentElement.XML
        FileStr = Replace(FileStr, chr(13)&chr(10), " ")
        FileStr = Replace(FileStr, chr(39), chr(92)&chr(39) )
        Set xmldoc= Nothing

        TableToStr = FileStr
    End Function

    Function TablePictureToStr(ADORs, PictureFieldName )
        ScriptPicture = ""

        ADORs.MoveFirst()
        Do while Not ADORs.Eof
           FieldValue = ADORs(PictureFieldName)
           if FieldValue <> "" then
              PictureName = ".\Image\" + FieldValue
              Set Fs = CreateObject("Scripting.FileSystemObject")
              If Fs.FileExists( server.mappath(PictureName) ) Then
                 PictureValue = FileToStr(PictureName)
                 '读取图片文件至打印控件，参数：文件名，该文件内容
                 ScriptPicture = ScriptPicture & "ObjPrintMange.SavePictureFile('" & FieldValue &  "' , '" & PictureValue & "' );"
              end if
           end if

           ADORs.MoveNext()
        Loop

        TablePictureToStr =  ScriptPicture
    End Function

    Function FileToStr(FileName)
        url=server.mappath(FileName)
        Set   objStream = Server.CreateObject("ADODB.Stream")
        objStream.Open
        objStream.Type   =   1
        objStream.LoadFromFile url
        bin = objStream.Read
        FileString = ""

        for StrRecn = 1 to  objStream.Size
            sByt=midB(bin, StrRecn, 1)
            iByt=ascB(sByt)
            i1 = iByt mod 16
            if i1 > 9 then
               A1 = chr(i1 + 55)
            else
               A1 = chr(i1 + 48)
            end if

            i2 = int(iByt/16)
            if i2 > 9 then
               A2 = chr(i2 + 55)
            else
               A2 = chr(i2 + 48)
            end if

            FileString = FileString&A2&A1
        Next
        objStream.Close
        Set objStream = Nothing

        FileToStr = FileString
    End Function

  %>

<form id="FrmWebPrint" name="FrmWebPrint" method="post" action="">
  <table width="473" height="245" border="0">
    <tr>
      <td width="121"><input name="DepositPreview" type="submit" id="DepositPreview" value="票据预览" onclick="PreviewDeposit();"  /></td>
      <td width="135"><input name="DepositDesign" type="submit" id="DepositDesign" value="票据报表编辑" onclick="DesignDeposit();"></td>
      <td width="203"><label>
        <input name="DepositPreviewD" type="submit" id="DepositPreviewD" value="票据预览（按域名注册）" onclick="PreviewDepositD();" />
      </label></td>
    </tr>
    <tr>
      <td><input name="DepositPrint" type="submit" id="DepositPrint" value="票据直接打印" onclick="PrintDeposit();" /></td>
      <td><input name="DepositDesignPost" type="submit" id="DepositDesignPost" value="票据报表编辑(Post方式保存)" onclick="DesignDepositPost();" /></td>
      <td><input name="DepositPrintD" type="submit" id="DepositPrintD" value="票据直接打印（按域名注册）" onclick="PrintDepositD();" /></td>
    </tr>
    <tr>
      <td><input name="MasterPreview" type="submit" id="MasterPreview" value="主从报表预览" onclick="PreviewMaster();" /></td>
      <td><input name="MasterDesign" type="submit" id="MasterDesign" value="主从报表编辑" onclick="DesignMaster();" /></td>
      <td><input name="MasterPreviewD" type="submit" id="MasterPreviewD" value="主从报表预览（按域名注册）" onclick="PreviewMasterD();" /></td>
    </tr>
    <tr>
      <td><input name="PicturePreview" type="submit" id="PicturePreview" value="含图片报表预览" onclick="PreviewPicture();" /></td>
      <td><input name="PictureDesign" type="submit" id="PictureDesign" value="含图片报表编辑" onclick="DesignPicture();" /></td>
      <td><input name="PicturePreviewD" type="submit" id="PicturePreviewD" value="含图片报表预览（按域名注册）" onclick="PreviewPictureD();" /></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>
