Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click ปุ่มสั่งพิมพ์คับ
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim newImage As Image = My.Resources.businessman
Dim row As Integer = 530
Dim col As Integer = 160
Dim row1 As Integer = 416
Dim row2 As Integer = 477
Dim col1 As Integer = 43
Dim printFont As New Font("Century Gothic", 14)
Dim printFont3 As New Font("Century Gothic", 11)
Dim printFont2 As New Font("Century Gothic", 18, FontStyle.Bold)
Dim printposition As New PointF
Dim printposition2 As New PointF
Dim printcolor As New SolidBrush(Color.Black)
Dim i As Integer
Dim width As Integer = 100
Dim heigth As Integer = 100
Try
Statement =
" SELECT * " &
" From Service LEFT OUTER JOIN employer ON Service.noemployer = employer.noemployer " &
" WHERE " &
" IdService = " & "" & txtIdservice.Text & "" &
" ORDER BY idservice "
cmd = New OleDbCommand(Statement, Conn)
dr = cmd.ExecuteReader
While dr.Read()
e.Graphics.DrawImage(newImage, 50, 50, width, heigth)
e.Graphics.DrawString("" & My.Settings.nameemployer & "", printFont2, printcolor, 310, 80)
e.Graphics.DrawString("" & My.Settings.addressemployer & " ", printFont, printcolor, 180, 110)
e.Graphics.DrawString("โทร : " & My.Settings.tell & "", printFont, printcolor, 260, 140)
e.Graphics.DrawString("ใบรับงาน", printFont2, printcolor, 400, 200)
e.Graphics.DrawString("เล่มที่ " & TextBox1.Text & "", printFont, printcolor, 50, 200)
e.Graphics.DrawString("เลขที่ " & TextBox2.Text & "", printFont, printcolor, 700, 200)
e.Graphics.DrawString("วันที่ " & TextBox10.Text & "", printFont, printcolor, 550, 250)
e.Graphics.DrawString("รหัสบริการ " & dr.Item("Idservice").ToString & "", printFont, printcolor, 50, 280)
e.Graphics.DrawString("ชื่อนายจ้าง " & dr.Item("nameemployer").ToString & "", printFont, printcolor, 50, 320)
e.Graphics.DrawString("เบอร์โทรติดต่อ " & dr.Item("tel").ToString & "", printFont, printcolor, 500, 320)
e.Graphics.DrawString("ผู้ยื่นเอกสาร " & dr.Item("contact").ToString & "", printFont, printcolor, 50, 360)
printposition = New PointF(col, row)
e.Graphics.DrawString("" & dr.Item("passport").ToString & "", printFont, printcolor, printposition)
e.Graphics.DrawString("" & dr.Item("namealien").ToString & "", printFont, printcolor, 280, row)
'e.Graphics.DrawString(DataGridView2.Rows(x).Cells(2).Value.ToString, printFont, printcolor, printposition)
row = row + 30
' Next
End While
dr.Close()
cmd.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message, "ข้อผิดพลาด กรุณาทำรายการใหม่", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub