۱۶-شهریور-۱۳۸۷, ۰۷:۱۰:۲۸
Salam,
Bache ha man 2 ta moshkel peyda karadam to barname nevisi goftam shayad shoma ha balad bashid betounid komakam koni.
avali baraye parameter pass kardan be Crystal reporte to vb.net.Albate man az crystal viewer khode .net estefade kardam vali nemitounam parameteramo be reportam pass konam.
In codame va un khaty ke *** dare kar nemikoneh shayad ham man balad nistam va bayad chiz digey bashe.
Lotfan age rahi baladin behem begin.Alabate bayad begam hamon joor ke mibinid man ba SQL Query reportam ro ejra mikonam.
Domin moshkelam male Subreporte. Man az yek reporte dige be unvane subreport to yek reprt estefade kardam. Data sub report hich rabty be reporte esli nadare.Vaghty run mikonam subreport khali miad.vali hamon subreport ro ke joda run mikonam dorost kar mikoneh.
in code moshkele subreportame:
Man kheili vaghte ba crystal report kar nakarde boodam shayad yek chizi bashe ke man yadam rafte.I
midounam ke taghazay ziady hast vali age mishe komakam konid.
Bache ha man 2 ta moshkel peyda karadam to barname nevisi goftam shayad shoma ha balad bashid betounid komakam koni.
avali baraye parameter pass kardan be Crystal reporte to vb.net.Albate man az crystal viewer khode .net estefade kardam vali nemitounam parameteramo be reportam pass konam.
کد:
Dim rpt As New rptIntervals()
Dim con As SqlConnection
Dim sql As String
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim dc As CrystalDecisions.Shared.DiscreteOrRangeKind
con = New SqlConnection(strCon)
con.Open()
Sql = " SELECT WorDescription, isnull(d14,'') as d14 ,"
Sql &= " isnull(d29,'') as d29, isnull(d44,'') as d44,"
Sql &= " isnull(d59,'') as d59, isnull(d74,'') as d74,"
Sql &= " isnull(d89,'') as d89, isnull(d90,'') as d90"
Sql &= " FROM dbo.vIntervals "
da = New SqlDataAdapter(Sql, con)
da.Fill(ds)
rpt.Refresh()
rpt.SetDataSource(ds.Tables(0))
rpt.SetParameterValue("@Test", txtStartdate.Text) ***
rpt.Refresh()
CrystalReportViewer1.ReportSource = rpt
rpt.Refresh()
CrystalReportViewer1.Zoom(75)
Publicds = ds.Copy()
Lotfan age rahi baladin behem begin.Alabate bayad begam hamon joor ke mibinid man ba SQL Query reportam ro ejra mikonam.
Domin moshkelam male Subreporte. Man az yek reporte dige be unvane subreport to yek reprt estefade kardam. Data sub report hich rabty be reporte esli nadare.Vaghty run mikonam subreport khali miad.vali hamon subreport ro ke joda run mikonam dorost kar mikoneh.
in code moshkele subreportame:
کد:
Private Sub btnNewSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewSearch.Click
Dim rpt As New rptActiveCase()
Dim rptSub As New rptActiveCaseIssue()
Dim subReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim con As SqlConnection
Dim sql As String
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim sqlSub As String
Dim daSub As New SqlDataAdapter
Dim dsSub As New DataSet
con = New SqlConnection(strCon)
con.Open()
sql = " SELECT [Case ID], [Open Date], Name, Worker, Service, [Issue Type], Fee,OD"
Sql &= " FROM dbo.vOpenCase "
If txtStartdate.Text <> "" And txtEndDate.Text <> "" Then sql &= " WHERE (OD BETWEEN '" & txtStartdate.Text & "' AND '" & txtEndDate.Text & "')"
da = New SqlDataAdapter(Sql, con)
da.Fill(ds)
rpt.Refresh()
rpt.SetDataSource(ds.Tables(0))
sqlSub = "SELECT [Issue Type], COUNT([Issue Type]) AS Iss"
sqlSub &= " FROM dbo.vOpenCase "
If txtStartdate.Text <> "" And txtEndDate.Text <> "" Then sqlSub &= " WHERE (OD BETWEEN '" & txtStartdate.Text & "' AND '" & txtEndDate.Text & "') AND ([Issue Type] IS NOT NULL)"
sqlSub &= " GROUP BY [Issue Type]"
sqlSub &= " UNION ALL "
sqlSub &= " SELECT 'ServiceDecsription' AS Expr1, '99999' AS counting"
sqlSub &= " UNION ALL "
sqlSub &= " SELECT Service AS Description, COUNT(Service) AS counting"
sqlSub &= " FROM dbo.vOpenCase AS vOpenCase_1"
If txtStartdate.Text <> "" And txtEndDate.Text <> "" Then sqlSub &= " WHERE (OD BETWEEN '" & txtStartdate.Text & "' AND '" & txtEndDate.Text & "') AND ([Service] IS NOT NULL)"
sqlSub &= " GROUP BY Service"
sqlSub &= " UNION ALL "
sqlSub &= " SELECT 'Fee' AS Expr1, '99999' AS counting"
sqlSub &= " UNION ALL "
sqlSub &= " SELECT Fee AS Description, COUNT(Fee) AS counting"
sqlSub &= " FROM dbo.vOpenCase AS vOpenCase_1"
If txtStartdate.Text <> "" And txtEndDate.Text <> "" Then sqlSub &= " WHERE (OD BETWEEN '" & txtStartdate.Text & "' AND '" & txtEndDate.Text & "') AND ([Fee] IS NOT NULL)"
sqlSub &= " GROUP BY Fee"
daSub = New SqlDataAdapter(sqlSub, con)
daSub.Fill(dsSub)
rptSub.Refresh()
rptSub.SetDataSource(dsSub.Tables(0))
rptSub.Refresh()
subReport = rpt.OpenSubreport("rptActiveCaseIssue")
subReport.SetDataSource(dsSub)
rpt.Refresh()
CrystalReportViewer1.Zoom(75)
Publicds = ds.Copy()
CrystalReportViewer1.ReportSource = rpt
rpt.OpenSubreport("rptActiveCaseIssue")
CrystalReportViewer1.RefreshReport()
End Sub
Man kheili vaghte ba crystal report kar nakarde boodam shayad yek chizi bashe ke man yadam rafte.I
midounam ke taghazay ziady hast vali age mishe komakam konid.