TechSapphire Saturday, 2024-12-21, 3:01 PM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • This reporting service allows you to develop reporting service which doesn't require any installation package to run over client system. It is just a way to create report using HTML document and Web browser control. This reporting has several advantages over crystal reports which are as follows:
    Advantages:
    • As crystal reports require an heavy setup to be installed.
    • They are not editable on runtime.You can not set their margins, header, footer, etc on run time.
    • Platform independent.
    • Provide great support for export in excel.
    • Easy to build.
    • Easy to export.

    Disadvantages:

    • Not well for large reporting.


        Note:
    • But can be improved using default HTML document support provided by .NET.

    Code:

    Imports System.Data.OleDb
    Public Class report
        Dim cmd As OleDbCommand
        Dim con As OleDbConnection
        Dim dr As OleDbDataReader
        Dim dr1 As OleDbDataReader
        Dim a As Integer
        Public Sub fillreport(ByVal id As Integer)
            Try
                Dim str As String, i As Integer = 1
                Dim pay As Double
                Dim datepay As Date
                Dim dated As Integer
                Dim interest As Double = 0
                Dim brokerinterest As Double = 0
                Dim paypayer As Double = 0
                Dim paybroker As Double = 0
                str = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "/payments.accdb"
                con = New OleDbConnection(str)
                con.Open()
                Me.Show()
                Dim d As Date
                str = "select dateto from daterange where id=" & id
                cmd = New OleDbCommand(str, con)
                dr = cmd.ExecuteReader
                If dr.Read Then
                    d = Format(dr(0), "dd/MMM/yyyy")
                End If
                RichTextBox1.Text = RichTextBox1.Text & "<html>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<center><head>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<TITLE> REPORT </title>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</head></center>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<body>" & vbCrLf
                str = "select broker_name from broker_list where id=(select userid from daterange where id=" & id & ")"
                cmd = New OleDbCommand(str, con)
                dr = cmd.ExecuteReader
                If dr.Read Then
                    RichTextBox1.Text = RichTextBox1.Text & "<b> Broker Name: " & dr(0).ToString & "</b>" & vbCrLf
                Else
                    RichTextBox1.Text = RichTextBox1.Text & "<b> Broker Name: All</b>" & vbCrLf
                End If


                RichTextBox1.Text = RichTextBox1.Text & "<table border=1> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Payer" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Broker" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf

                RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf

                Dim str1 As String
                str1 = "select payer_Payments.[ID], payer_Payments.[Amountpaid], payer_Payments.[date_pay], payer_Payments.[date_range_id], payer_Payments.[Remarks] from payer_payments where date_range_id=" & id

                RichTextBox1.Text = RichTextBox1.Text & "<table border=1> " & vbCrLf
                cmd = New OleDbCommand(str1, con)
                dr = cmd.ExecuteReader
                RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Payment" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Date" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Days" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Interest" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Remarks" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf

                If d.Month = 2 Then
                    While dr.Read
                        pay = dr(1)
                        datepay = Format(dr(2), "dd/MMM/yyyy")
                        dated = DateDiff(DateInterval.Day, datepay, d)
                        RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        paypayer = paypayer + pay
                        RichTextBox1.Text = RichTextBox1.Text & pay.ToString("#.00") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & Format(datepay, "dd/MMM/yyyy") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dated & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        interest = interest + ((pay * dated * 1.25) / 100) / 28
                        RichTextBox1.Text = RichTextBox1.Text & (((pay * dated * 1.25) / 100) / 28).ToString("#.00") & " " & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dr(4).ToString & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf
                    End While
                Else
                    While dr.Read
                        pay = dr(1)
                        datepay = Format(dr(2), "dd/MMM/yyyy")
                        dated = DateDiff(DateInterval.Day, datepay, d)
                        RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        paypayer = paypayer + pay
                        RichTextBox1.Text = RichTextBox1.Text & pay.ToString("#.00") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & Format(datepay, "dd/MMM/yyyy") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dated & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        interest = interest + ((pay * dated * 1.25) / 100) / 30
                        RichTextBox1.Text = RichTextBox1.Text & (((pay * dated * 1.25) / 100) / 30).ToString("#.00") & " " & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dr(4).ToString & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf
                    End While
                End If

                RichTextBox1.Text = RichTextBox1.Text & "</table>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf

                RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                str1 = "select Broker_Payments.[ID], Broker_Payments.[Amountpaid], Broker_Payments.[date_pay], Broker_Payments.[date_range_id], Broker_Payments.[Remarks] from broker_payments where date_range_id=" & id
                RichTextBox1.Text = RichTextBox1.Text & "<table border=1> " & vbCrLf
                cmd = New OleDbCommand(str1, con)
                dr = cmd.ExecuteReader
                RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Payment" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Date" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Days" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Interest" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Remarks" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</th>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf

                If d.Month = 2 Then
                    While dr.Read
                        pay = dr(1)
                        datepay = Format(dr(2), "dd/MMM/yyyy")
                        dated = DateDiff(DateInterval.Day, datepay, d)
                        RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        paybroker = paybroker + pay
                        RichTextBox1.Text = RichTextBox1.Text & pay.ToString("#.00") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & Format(datepay, "dd/MMM/yyyy") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dated & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        brokerinterest = brokerinterest + ((pay * dated * 1.25) / 100) / 28
                        RichTextBox1.Text = RichTextBox1.Text & (((pay * dated * 1.25) / 100) / 28).ToString("#.00") & " " & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dr(4).ToString & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf
                    End While
                Else
                    While dr.Read
                        pay = dr(1)
                        datepay = Format(dr(2), "dd/MMM/yyyy")
                        dated = DateDiff(DateInterval.Day, datepay, d)
                        RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        paybroker = paybroker + pay
                        RichTextBox1.Text = RichTextBox1.Text & pay.ToString("#.00") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & Format(datepay, "dd/MMM/yyyy") & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dated & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td align=right>" & vbCrLf
                        brokerinterest = brokerinterest + ((pay * dated * 1.25) / 100) / 30
                        RichTextBox1.Text = RichTextBox1.Text & (((pay * dated * 1.25) / 100) / 30).ToString("#.00") & " " & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & dr(4).ToString & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                        RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf
                    End While
                End If
                RichTextBox1.Text = RichTextBox1.Text & "</table>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf

                RichTextBox1.Text = RichTextBox1.Text & "<tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Total " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & paypayer.ToString("#.00") & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "&nbsp;&nbsp;" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Interest" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & interest.ToString("#.00") & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf

                RichTextBox1.Text = RichTextBox1.Text & "<td>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Total " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & paybroker.ToString("#.00") & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "&nbsp;&nbsp;" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Interest" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & brokerinterest.ToString("#.00") & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</td>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</table> " & vbCrLf

                RichTextBox1.Text = RichTextBox1.Text & "<table border=1> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<tr> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "<td align=right> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "Closing Balance&nbsp;&nbsp;&nbsp;&nbsp;" & (paybroker - paypayer).ToString("#.00") & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</td> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</tr> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</table> " & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</body>" & vbCrLf
                RichTextBox1.Text = RichTextBox1.Text & "</html>"

                'SaveFileDialog1.ShowDialog()
                RichTextBox1.SaveFile(id & ".htm", RichTextBoxStreamType.PlainText)

                WebBrowser1.Navigate(Application.StartupPath & "\" & id & ".htm")
                RichTextBox1.Visible = False
                a = id
            Catch ex As Exception
                MsgBox(ex.Message)
                Exit Sub
            End Try
        End Sub

        Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
            WebBrowser1.ShowPrintPreviewDialog()
        End Sub

        Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
            WebBrowser1.ShowPageSetupDialog()
        End Sub

        Private Sub report_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            Try
                My.Computer.FileSystem.DeleteFile(a & ".htm")
            Catch ex As Exception
                Exit Sub
            End Try
        End Sub

        Private Sub report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        End Sub
    End Class

    Download Example form code



    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2024