|
 |
|
VB.Net สั่งปริ้นแล้วไม่ขึ้นบรรทัดใหม่คับมันจะอยู่ซ้ำที่บรรทัดเดิมตลอด VB 2008 |
|
 |
|
|
 |
 |
|
ผมสั่งปริ้นแล้วมันไม่เว้นไปบรรทัดอื่นคับ

Code (VB.NET)
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim lv As ListView = ListView2
If lv.Items.Count = 0 Then Exit Sub
Call Contodbase()
Dim idbill As Integer = sIDBill("tbsell")
For i As Integer = 0 To lv.Items.Count - 1
Dim priceraw As String = CStr(CDbl(getPriceRawAll(lv.Items(i).SubItems(0).Text)) * CDbl(lv.Items(i).SubItems(2).Text))
sqltext = "INSERT INTO tbsell (idbill, idmenu, amount, price, priceraw, d, m, y, tadd)"
sqltext &= "VALUES (" & idbill & ","
sqltext &= "'" & lv.Items(i).SubItems(0).Text & "',"
sqltext &= "" & lv.Items(i).SubItems(2).Text & ","
sqltext &= "" & lv.Items(i).SubItems(3).Text & ","
sqltext &= "'" & priceraw & "',"
sqltext &= "'" & Date.Today.Day & "',"
sqltext &= "'" & Date.Today.Month & "',"
sqltext &= "'" & Date.Today.Year & "',"
sqltext &= "'" & DateTime.Now.ToShortTimeString & "')"
Dim rsInserta As OleDbCommand = Conn.CreateCommand()
With rsInserta
.CommandText = sqltext
.ExecuteNonQuery()
End With
'update amount
setExportAmountRaw(lv.Items(i).SubItems(0).Text, CInt(lv.Items(i).SubItems(2).Text), idbill)
Next
savelog(idLogin, "จำหน่ายสินค้าเลขที่บิล: " & idbill)
Conn.Close()
Dim font1 As New Font("Angsana New", 16, FontStyle.Bold)
Dim font2 As New Font("Angsana New", 16, FontStyle.Regular)
Dim comp As String = "ร้าน CoffeeToday Shop"
Dim dot As String = "-------------------------------------------------------------------------------"
Dim bill As String = "เลขที่บิล-เวลา :"
Dim daytime As Date = Date.Now
Dim allnum As String = "จำนวนรวม :"
Dim allprice As String = "ราคารวม :"
e.Graphics.DrawString(comp.ToString, font1, Brushes.Black, 199, 100)
e.Graphics.DrawString(dot.ToString, font2, Brushes.Black, 199, 116)
e.Graphics.DrawString(bill.ToString, font2, Brushes.Black, 200, 130)
e.Graphics.DrawString(idbill.ToString, font2, Brushes.Black, 300, 130)
e.Graphics.DrawString(daytime.ToString, font2, Brushes.Black, 400, 130)
Call AddTolist()
Dim lv1 As ListView = ListView2
Dim net As Integer = 0
'Dim idmenu As String = ""
'Dim menuname As String = ""
'Dim am1 As String = ""
'Dim price1 As String = ""
For i As Integer = 0 To lv1.Items.Count - 1
'Dim am As Integer = 0
'Dim price As Integer = 0
'idmenu = lv1.Items(i).SubItems(0).Text
'menuname = lv1.Items(i).SubItems(1).Text
'am = CInt(lv1.Items(i).SubItems(2).Text)
'am1 = CStr(am)
'price = CInt(lv1.Items(i).SubItems(3).Text)
'price1 = CStr(price)
'net = am * price
'lv1.Items(i).SubItems(4).Text = Format(net, "#,##0")
e.Graphics.DrawString(lv1.Items(i).SubItems(0).Text, font2, Brushes.Black, 200, 150)
e.Graphics.DrawString(lv1.Items(i).SubItems(1).Text, font2, Brushes.Black, 300, 150)
e.Graphics.DrawString(lv1.Items(i).SubItems(2).Text, font2, Brushes.Black, 450, 150)
e.Graphics.DrawString(lv1.Items(i).SubItems(3).Text, font2, Brushes.Black, 500, 150)
net = CInt(lv1.Items(i).SubItems(2).Text) * CInt(lv1.Items(i).SubItems(3).Text)
lv1.Items(i).SubItems(4).Text = Format(net, "#,##0")
e.Graphics.DrawString(lv1.Items(i).SubItems(4).Text, font2, Brushes.Black, 550, 150)
'e.Graphics.DrawString(lv.Items(i).SubItems(3).Text, font2, Brushes.Black, 220, 150)
Next
e.Graphics.DrawString(allnum.ToString, font2, Brushes.Black, 200, 170)
e.Graphics.DrawString(lblsumamount.Text, font2, Brushes.Black, 300, 170)
e.Graphics.DrawString(allprice.ToString, font2, Brushes.Black, 400, 170)
e.Graphics.DrawString(lblnettotal.Text, font2, Brushes.Black, 500, 170)
lv.Items.Clear()
End Sub
Tag : VB.NET, VS 2008 (.NET 3.x)

|
|
 |
 |
 |
 |
Date :
2013-05-28 21:35:18 |
By :
nongtawees |
View :
1930 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็ต้องทับอยู่แล้วนี่ครับ เพราะ ตามที่คุณเขียนใน Loop For คุณเขียนให้มันทับกัน ??
Code (VB.NET)
e.Graphics.DrawString(lv1.Items(i).SubItems(0).Text, font2, Brushes.Black, 200, 150)
e.Graphics.DrawString(lv1.Items(i).SubItems(1).Text, font2, Brushes.Black, 300, 150)
ตัวเลขหลังสุด(150) มันคือตัวเลขแกน Y ที่จะแสดงผลแนวตั้ง ส่วนตัวเลขหน้า (150) คือ แกน X แสดงผลในแนวขวางตามหน้ากระดาษ
|
 |
 |
 |
 |
Date :
2013-05-29 10:04:54 |
By :
CPU4Core |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|