POS单据打印

华乐 2005-05-25 09:21:37
如何在.NET中实现POS单据打印,最好有源码,望指教。
...全文
147 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Snrmnm_sx 2005-05-26
  • 打赏
  • 举报
回复
Imports System.Drawing.Printing
Public Class
.
.
.
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim PrintFont, HeaderFont, PrintFont_A, PrintFont_B, PrintFont_C As Font
Dim Height_H, Width_H As Single '每行高度,宽度
Dim HeaderLeft, HeaderTop As Single
‘字体设置
PrintFont = New Font("仿宋_GB2312", 11, FontStyle.Regular)
PrintFont_A = New Font("仿宋_GB2312", 11, FontStyle.Bold)
PrintFont_B = New Font("仿宋_GB2312", 13, FontStyle.Regular)
PrintFont_C = New Font("仿宋_GB2312", 11, FontStyle.Regular)
HeaderFont = New Font("仿宋_GB2312", 22, FontStyle.Bold)
’现在就可以对你的表格进行设置了!
e.Graphics.DrawString("日报表", HeaderFont, Brushes.Black, 360, 40, New StringFormat())
e.Graphics.DrawString("单位:", PrintFont_B, Brushes.Black, 15, 40, New StringFormat())
e.Graphics.DrawString("值班:", PrintFont_B, Brushes.Black, 400, 50, New StringFormat())
e.Graphics.DrawString("填表日期:_________", PrintFont_B, Brushes.Black, 805, 50, New StringFormat())
.
.
.
END SUB
.
.
.
END CLASS
SeeSunSet 2005-05-26
  • 打赏
  • 举报
回复
Const GENERIC_READ = &H80000000
Const GENERIC_WRITE = &H40000000
Const OPEN_EXISTING = 3
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, ByVal lpSecurityAttributes As Integer, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer) As IntPtr

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim iHandle As IntPtr
iHandle = CreateFile("LPT1", GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0)
If (iHandle.ToInt32 = -1) Then
MsgBox("没有连接打印机或者打印机端口不是LPT1")
Exit Sub
Else
If i = 0 Then MsgBox("打印机连接成功!")

Dim fs As New FileStream(iHandle, FileAccess.ReadWrite)
Dim sr As New StreamReader(fs) '读数据
Dim sw As New StreamWriter(fs, System.Text.Encoding.Default) '写数据

sw.WriteLine()


End If
sw.Close()
End If
Next
End If
End Sub



End Function
SeeSunSet 2005-05-25
  • 打赏
  • 举报
回复
老问题了.你搜索一下吧..我都给人答了N次了.
直接以文件方式打开LPT端口直接用streamwriter往里面写就行了..包括输出开钱箱和顾显的操作命令.

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧