Click here to Skip to main content
15,908,661 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i build a software for school and a fee voucher printing fine one by one .i want to Print all fee voucher of selected class in One Click which student is loaded in Datagridview table.

What I have tried:

I dont know how to do it i search alot on google but failed
Posted
Updated 17-May-19 19:40pm

Start by reading up on the PrintDocument Class (System.Drawing.Printing) | Microsoft Docs[^] - that does the actual printing. What you print is up to you - we can't be specific because you don't give us any detail and we have no access to your data at all!
 
Share this answer
 
Comments
Naqash Younis 18-May-19 1:39am    
this is code which i am using for print single fee voucher but i want Multiple fee voucher in single click




Public Function itemQillareport() As DataSet
Dim dsData As DataSet
Try

'dsData = DalHelper.ExecuteDataset(m_ConString, CommandType.Text, "select * from PrintChallan where Reg_num='" & StidentFee.TextBox14.Text & "' and fee_Month='" & StidentFee.ComboBox1.Text & "' and Fea_year='" & StidentFee.TextBox4.Text & "'")
dsData = DalHelper.ExecuteDataset(m_ConString, CommandType.Text, "SELECT dbo.PrintChallan.*, dbo.School_Info.* FROM dbo.PrintChallan CROSS JOIN dbo.School_Info where PrintChallan.Reg_num='" & StidentFee.TextBox14.Text & "' and PrintChallan.fee_Month='" & StidentFee.ComboBox1.Text & "' and PrintChallan.Fea_year='" & StidentFee.TextBox4.Text & "' and School_Info.Id='1'")
Catch ex As Exception
Return Nothing
End Try
Return dsData

End Function

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


ReportViewer1.LocalReport.ReportEmbeddedResource = "KTC.Report36.rdlc"
Dim rdsNumberofReferrals As New Microsoft.Reporting.WinForms.ReportDataSource()

rdsNumberofReferrals.Name = "DataSet1"
Dim dsBrands As DataSet = itemQillareport()
rdsNumberofReferrals.Value = dsBrands.Tables(0)
ReportViewer1.LocalReport.DataSources.Add(rdsNumberofReferrals)
ReportViewer1.Update()
Dim newPageSettings As New System.Drawing.Printing.PageSettings
newPageSettings.PaperSize = New Printing.PaperSize("Custom", 820, 1150)

newPageSettings.Landscape = True
newPageSettings.Margins = New System.Drawing.Printing.Margins(10, 10, 10, 10)
ReportViewer1.SetPageSettings(newPageSettings)
Me.ReportViewer1.RefreshReport()



End Sub
OriginalGriff 18-May-19 2:15am    
First off ... stop what you are doing, and urgently fix your whole app.
Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.

When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;--'
Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
DROP TABLE MyTable;
A perfectly valid "delete the table" command
--'
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.

So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?

When you have fixed that, you can start thinking about "improvements" but at teh moment, your whole app is a disaster waiting to happen...
Naqash Younis 18-May-19 8:21am    
thanks for telling me such a thing.
but my problem is same .could you tell me how can i print all Callahan FROM dbo.PrintChallan Table dbo.PrintChallan store monthly base fee vouchers for many students class wise i want to print all fee voucher in single click i mentioned my source code also.
OriginalGriff 18-May-19 8:34am    
The problem you have noticed is one thing. The problem you have is far greater and far more dangerous. When you have fixed that, you can move on to the one you have noticed - but it's pointless before that!
VB
<pre>
    Public Function itemQillareport() As DataSet
        Dim dsData As DataSet
        Try

            'dsData = DalHelper.ExecuteDataset(m_ConString, CommandType.Text, "select * from PrintChallan where Reg_num='" & StidentFee.TextBox14.Text & "' and fee_Month='" & StidentFee.ComboBox1.Text & "' and Fea_year='" & StidentFee.TextBox4.Text & "'")
            dsData = DalHelper.ExecuteDataset(m_ConString, CommandType.Text, "SELECT dbo.PrintChallan.*, dbo.School_Info.* FROM dbo.PrintChallan CROSS JOIN dbo.School_Info where PrintChallan.Reg_num='" & StidentFee.TextBox14.Text & "' and PrintChallan.fee_Month='" & StidentFee.ComboBox1.Text & "' and PrintChallan.Fea_year='" & StidentFee.TextBox4.Text & "' and School_Info.Id='1'")
        Catch ex As Exception
            Return Nothing
        End Try
        Return dsData

    End Function
    
    Private Sub Employe_Led_report_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
       

        ReportViewer1.LocalReport.ReportEmbeddedResource = "KTC.Report36.rdlc"
            Dim rdsNumberofReferrals As New Microsoft.Reporting.WinForms.ReportDataSource()

            rdsNumberofReferrals.Name = "DataSet1"
            Dim dsBrands As DataSet = itemQillareport()
            rdsNumberofReferrals.Value = dsBrands.Tables(0)
            ReportViewer1.LocalReport.DataSources.Add(rdsNumberofReferrals)
            ReportViewer1.Update()
        Dim newPageSettings As New System.Drawing.Printing.PageSettings
        newPageSettings.PaperSize = New Printing.PaperSize("Custom", 820, 1150)

        newPageSettings.Landscape = True
        newPageSettings.Margins = New System.Drawing.Printing.Margins(10, 10, 10, 10)
        ReportViewer1.SetPageSettings(newPageSettings)
            Me.ReportViewer1.RefreshReport()



    End Sub
 
Share this answer
 
Comments
phil.o 18-May-19 11:57am    
You were told that the way you are building your SQL queries by string concatenation is very dangerous and, by essence, a bad practice. And yet you keep doing it. You can expect some serious issues if you do not change your ways.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900