i'm trying to make price lable printer and i was able to print a single page
for a single id, but my problem is when i'm trying to print more that one id
i was not able to make it work, i'm still learning but i was hoping that someone can
give me idea how to make it work
Imports MySql.Data.MySqlClient
Public Module thisModule
'Info for the Price Lable
Public NameV As String
Public IdV As String
Public DiscV As String
Public ArDiscV As String
Public PriceV As String
Public SalesPriceV As String
End Module
Public Class Form1
Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=inven")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each s As String In Me.SearchB.Lines
Dim nextLineText As String = s
_lineCount = SearchB.Lines.Length
_endPages = _lineCount
'MsgBox(_endPages)
Dim command As New MySqlCommand("SELECT * FROM `items` WHERE `id` = @id", connection)
command.Parameters.Add("@id", MySqlDbType.String).Value = s
Dim reader As MySqlDataReader
If SearchB.Text IsNot "" Then 'If SeachBox is empty then do nothing
connection.Open()
reader = command.ExecuteReader()
If reader.Read() Then
thisModule.NameV = reader(1)
thisModule.IdV = reader(0)
thisModule.DiscV = reader(2)
thisModule.ArDiscV = reader(3)
thisModule.PriceV = reader(4)
thisModule.SalesPriceV = reader(5)
PrintPreviewControl1.Document = PrintDocument1
PrintPB.Visible = True
ElseIf SearchB.Text = "" Then
MsgBox("Please enter Model")
End If
connection.Close()
End If 'End SeachBox
Next
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim font As New Font("Arial", 30, FontStyle.Bold)
Dim WarrEng As New Font("Arial", 18, FontStyle.Bold)
Dim WarrArb As New Font("Arial", 28, FontStyle.Bold)
Dim SalesFont As New Font("Arial", 70, FontStyle.Strikeout Or FontStyle.Bold)
Dim PriceS As New Font("Arial", 70, FontStyle.Bold)
If A4C.Checked Then
Dim newImage As Image = Image.FromFile("C:\Users\GAMING PC\Desktop\ElecPrice\A4.png") 'A4 Image
e.Graphics.DrawImage(newImage, 0, 0) 'A4 Image Location
'e.Graphics.DrawString(thisModule.NameV, font, Brushes.Black, 65, 400)
e.Graphics.DrawString(thisModule.NameV + " " + thisModule.IdV, font, Brushes.Black, 65, 350)
e.Graphics.DrawString(thisModule.DiscV, font, Brushes.Black, 130, 450)
e.Graphics.DrawString(thisModule.ArDiscV, font, Brushes.Black, 600, 450)
e.Graphics.DrawString(thisModule.PriceV, PriceS, Brushes.White, 510, 110)
ElseIf A4P.Checked Then
Dim newImage As Image = Image.FromFile("C:\Users\GAMING PC\Desktop\ElecPrice\A4Promo.png") 'A4-Promo Image
e.Graphics.DrawImage(newImage, 0, 0) 'A4 Image Location
'e.Graphics.DrawString(thisModule.NameV, font, Brushes.Black, 65, 400)
e.Graphics.DrawString(thisModule.NameV + " " + thisModule.IdV, font, Brushes.Black, 65, 350)
e.Graphics.DrawString(thisModule.DiscV, font, Brushes.Black, 130, 450)
e.Graphics.DrawString(thisModule.ArDiscV, font, Brushes.Black, 600, 450)
e.Graphics.DrawString(thisModule.PriceV, SalesFont, Brushes.Black, 25, 650)
e.Graphics.DrawString(thisModule.SalesPriceV, PriceS, Brushes.White, 510, 110)
End If
If WRT.Checked = True Then
e.Graphics.DrawString("Extended warranty available on this item..Please refer to sales team", WarrEng, Brushes.Red, 10, 890)
Else
e.Graphics.DrawString("", font, Brushes.Black, 65, 500)
End If
End Sub
End Class