Logo 
Search:

VB.Net Forum

Ask Question   UnAnswered
Home » Forum » VB.Net       RSS Feeds

How to print Sales Bill receipt on paper

  Asked By: Dopen    Date: Apr 26    Category: VB.Net    Views: 10573
  

Sir, I want print Sales Bill receipt on paper. I am using visual basic 2012, MySQL and MySQL-Connetor to make simple application that print and make invoice i am all most done but I cannot print on paper. How to print this Invoice on Dot Matrix Printer. I want print "txt file format"....plz help.......thanks.......

I was using 4 Tables:

tbl_Setting (Server, Database, User, Password)
Registration(Shop, Address2, Contact, Email, Licence2, CST)
r-Sales(Bill_No, Bill_Date, Cus_Name, Cus_Address, Pay_Mode, Total_Amt, Discount, Net_Amt)
r_Sales1(Bill_no, Particulars, Category, Batch_No, Mfg_Dt, Exp_Dt, Qty,Rate,Amt)

Click to Print Button Show error :

Crystal Report Windows Forms viewer Failed to open the connection. Temp_72993a0f-lef6-4acf-8299-14c930d5aab7 {18713798-1D37-4909-86FD-687B063C9D3F}.rpt


Imports MySql.Data.MySqlClient
Module Module1
Public sqlconn, sqldb, sqluser, sqlpass, connectionString As String
Public Con As MySqlConnection
Public Str, gen, uname, attr, server, database, user, password, utype As String
Public Cmd As MySqlCommand
Public Dr As MySqlDataReader
Public Ds As New DataSet
Public Da As New MySqlDataAdapter
Public Int, i, m_id, g_id As Integer
Public Sub dbconf() 'database configuration
sqlconn = "localhost" 'server name
sqldb = "Pharmacy" 'database name
sqluser = "root" 'server login
sqlpass = "root" 'server password
End Sub
Public Sub Cons() 'connects to server
dbconf()
connectionString = "Data Source=" & sqlconn & ";Initial Catalog=" & sqldb & ";User ID=" & sqluser & ";Password=" & sqlpass & ""
Con = New MySqlConnection(connectionString)
Try
Con.Open()
Catch ex As Exception
MsgBox("Can not open connection ! ", MsgBoxStyle.Critical)
End Try
End Sub
Public Sub connection_close() 'closing the connection
cmd.Dispose()
Con.Close()
End Sub
End Module

############################
###Form Class frmSalesDis###
############################

Private Sub cmdPrint_Click(sender As Object, e As EventArgs) Handles cmdPrint.Click
Try
Cursor = Cursors.WaitCursor
Timer1.Enabled = True
Dim rpt As New frmSalesrep 'The report you created.
Dim Ds As New DataSet
Cons()
Cmd.Connection = Con
Str = "SELECT registration.Shop, registration.Address2, registration.Contact, registration.Licence2, registration.CST,"
Str = Str & " r_sales.Cus_Name, r_sales.Cus_Address, r_sales.Mode_Pay, r_sales.Bill_No, r_sales.Bill_Date, r_sales1.M_Name,"
Str = Str & " r_sales1.M_Cat, r_sales1.Batch_No, r_sales1.Mfg_Dt, r_sales1.Exp_Dt, r_sales1.Qty, r_sales1.Rate, r_sales1.Dis, "
Str = Str & "r_sales1.Vat, r_sales1.Amt, r_sales.Net_Amt, r_sales.Discount, r_sales.Vat AS Expr1, r_sales.G_Total"
Str = Str & " FROM r_sales INNER JOIN r_sales1 ON r_sales.Bill_No = r_sales1.Bill_No, registration, r_sales where r_sales.Bill_No = '" & lblBill.Text & "'"
Cmd.CommandText = Str
Cmd.CommandType = CommandType.Text
Da.SelectCommand = Cmd
Da.Fill(Ds, "Registration")
Da.Fill(Ds, "r_sales")
Da.Fill(Ds, "r_sales1")
frmSalesrep.CrystalReportViewer2.ReportSource = rpt
frmSalesrep.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on How to print Sales Bill receipt on paper Or get search suggestion and latest updates.




Tagged: