Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim strDeptCode As String = "-1"
Dim strAcTypeID As String = "-1"
Dim ds As New DsCOAInfoByDeptCode
Dim strSql As String
Dim strCon As String
'自行填充数据集ds()
strCon = System.Configuration.ConfigurationSettings.AppSettings.Get("CMPSDBConnection")
Dim CN As New Data.OracleClient.OracleConnection(strCon)
CN.Open()
If strDeptCode = "-1" And strAcTypeID = "-1" Then
strSql = "SELECT rownum Row_Num,c.TECH_AUTH_NAME,c.TECH_AUTH_ID,d.C_NAME as P_NUMBER,d.COMP_AUTH_ID,e.DEPT_NAME,e.DEPT_CODE" & _
" FROM CM_T5004 c," & _
" (SELECT a.COMP_AUTH_ID,b.C_NAME,b.DEPT_CODE" & _
" FROM CM_T5001 a,CM_T1002 b" & _
" WHERE b.DEPT_CODE IS NOT NULL AND a.AC_TYPE_ID IS NOT NULL AND a.P_CODE = b.P_CODE) d," & _
" (SELECT * FROM CM_T1001) e" & _
" WHERE c.TECH_AUTH_ID=d.COMP_AUTH_ID AND c.IN_EX='I' AND e.DEPT_CODE=d.DEPT_CODE" & _
" ORDER BY c.TECH_LEVEL,c.TECH_AUTH_NAME"
Else
strSql = "SELECT rownum Row_Num,c.TECH_AUTH_NAME,c.TECH_AUTH_ID,d.C_NAME as P_NUMBER,d.COMP_AUTH_ID,e.DEPT_NAME,e.DEPT_CODE" & _
" FROM CM_T5004 c," & _
" (SELECT a.COMP_AUTH_ID,b.C_NAME,b.DEPT_CODE" & _
" FROM CM_T5001 a,CM_T1002 b" & _
" WHERE b.DEPT_CODE='" & strDeptCode & "' AND a.AC_TYPE_ID='" & strAcTypeID & "' AND a.P_CODE = b.P_CODE) d," & _
" (SELECT * FROM CM_T1001) e" & _
" WHERE c.TECH_AUTH_ID=d.COMP_AUTH_ID AND c.IN_EX='I' AND e.DEPT_CODE=d.DEPT_CODE" & _
" ORDER BY c.TECH_LEVEL,c.TECH_AUTH_NAME"
End If
Dim da As New Data.OracleClient.OracleDataAdapter(strSql, CN)
da.Fill(ds, "CM_T5001")
CrystalReportViewer1.ReportSource = oRptd
'把水晶报表文件生成打印文件
SavetoDoc(3, "RptFlyerTechnicAnalyse")
End Sub
Public Sub SavetoDoc(ByVal Format As Integer, _
ByVal strRptFN As String)
Dim Fname As String
Dim r As New Random
Dim iflag As Integer = r.Next(10000)
Fname = strRptFN
Fname += iflag.ToString()
Dim ExportPath As String
ExportPath = Request.PhysicalApplicationPath + "Exported\"
If (Not Directory.Exists(ExportPath)) Then
System.IO.Directory.CreateDirectory(Request.PhysicalApplicationPath + "Exported\")
End If
Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim crExportOptions As ExportOptions = oRptd.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
Select Case Format
Case 0
.ExportFormatType = ExportFormatType.Excel
Dim excelFormatOpts As New ExcelFormatOptions
excelFormatOpts.ExcelTabHasColumnHeadings = False
excelFormatOpts.ExcelAreaType = AreaSectionKind.Detail
excelFormatOpts.ExcelUseConstantColumnWidth = True
excelFormatOpts.ExcelConstantColumnWidth = 2500.0
.FormatOptions = excelFormatOpts
Fname = Fname + ".xls"
Case 1
.ExportFormatType = ExportFormatType.WordForWindows
Fname = Fname + ".doc"
Case 2
.ExportFormatType = ExportFormatType.HTML40
Dim HTML40Formatopts As New HTMLFormatOptions
With HTML40Formatopts
.HTMLBaseFolderName = ExportPath
.HTMLEnableSeparatedPages = True
.HTMLHasPageNavigator = True
End With
crExportOptions.FormatOptions = HTML40Formatopts
'Dim rptFileFolder As String = strStoreProcedure + "/"
Dim rptFileFolder As String = Fname + "/"
Fname = rptFileFolder + ".htm"
Case 3
.ExportFormatType = ExportFormatType.PortableDocFormat
Fname = Fname + ".pdf"
End Select
End With