Imports System.Drawing.Printing
Public Class Form1
Private username As Label = New Label()
Private username2 As Label = New Label()
Private huanzhe As Label = New Label()
Private huanzhe2 As TextBox = New TextBox()
Private danwei As Label = New Label()
Private danwei2 As Label = New Label()
Private xiangmu As Label = New Label()
Private danjia As Label = New Label()
Private tb1 As TextBox = New TextBox()
Private tb2 As TextBox = New TextBox()
Private tb3 As TextBox = New TextBox()
Private tb4 As TextBox = New TextBox()
Private tb5 As TextBox = New TextBox()
Private tb6 As TextBox = New TextBox()
Private tb7 As TextBox = New TextBox()
Private tb8 As TextBox = New TextBox()
Private tb9 As TextBox = New TextBox()
Private tb10 As TextBox = New TextBox()
Private heji11 As Label = New Label()
Private heji12 As Label = New Label()
Private shijian As Label = New Label()
Private dtp As DateTimePicker = New DateTimePicker()
Private kaipiaoren1 As Label = New Label()
Private kaipiaoren2 As TextBox = New TextBox()
Private WithEvents jisuan As Button = New Button()
Private WithEvents yulan As Button = New Button()
Private WithEvents dayin As Button = New Button()
Private pd As PrintDialog = New PrintDialog()
Private WithEvents pdoc As PrintDocument = New PrintDocument()
Private ppd As PrintPreviewDialog = New PrintPreviewDialog()
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.SetBounds(0, 0, 400, 640)
Me.username.BorderStyle = BorderStyle.Fixed3D
Me.username.Font = New Font("微软雅黑", 14)
Me.username.SetBounds(0, 0, 110, 25)
Me.username.Text = "开票单位:"
Me.Controls.Add(username)
Me.username2.BorderStyle = BorderStyle.Fixed3D
Me.username2.Font = New Font("微软雅黑", 14)
Me.username2.SetBounds(Me.username.Width + 10, 0, 220, 25)
Me.username2.Text = "口腔诊所"
Me.Controls.Add(username2)
Me.huanzhe.BorderStyle = BorderStyle.Fixed3D
Me.huanzhe.Font = New Font("微软雅黑", 14)
Me.huanzhe.SetBounds(0, 35, 110, 25)
Me.huanzhe.Text = "患者姓名:"
Me.Controls.Add(huanzhe)
Me.huanzhe2.BorderStyle = BorderStyle.Fixed3D
Me.huanzhe2.Font = New Font("微软雅黑", 10)
Me.huanzhe2.SetBounds(Me.huanzhe.Width + 10, 35, 220, 25)
Me.Controls.Add(huanzhe2)
Me.danwei.BorderStyle = BorderStyle.Fixed3D
Me.danwei.Font = New Font("微软雅黑", 14)
Me.danwei.SetBounds(0, 70, 110, 25)
Me.danwei.Text = "计价单位:"
Me.Controls.Add(danwei)
Me.danwei2.BorderStyle = BorderStyle.Fixed3D
Me.danwei2.Font = New Font("微软雅黑", 14)
Me.danwei2.SetBounds(Me.danwei.Width + 10, 70, 220, 25)
Me.danwei2.Text = "元"
Me.Controls.Add(danwei2)
Me.xiangmu.BorderStyle = BorderStyle.Fixed3D
Me.xiangmu.Font = New Font("微软雅黑", 14)
Me.xiangmu.Text = "治疗项目"
Me.xiangmu.SetBounds(0, 150, 220, 25)
Me.Controls.Add(xiangmu)
Me.danjia.BorderStyle = BorderStyle.Fixed3D
Me.danjia.Font = New Font("微软雅黑", 14)
Me.danjia.Text = "单价"
Me.danjia.SetBounds(Me.xiangmu.Width + 10, 150, 110, 25)
Me.Controls.Add(danjia)
Me.tb1.BorderStyle = BorderStyle.Fixed3D
Me.tb1.Font = New Font("微软雅黑", 10)
Me.tb1.SetBounds(0, 185, 220, 25)
Me.Controls.Add(tb1)
Me.tb2.BorderStyle = BorderStyle.Fixed3D
Me.tb2.Font = New Font("微软雅黑", 10)
Me.tb2.SetBounds(Me.tb1.Width + 10, 185, 110, 25)
Me.Controls.Add(tb2)
Me.tb3.BorderStyle = BorderStyle.Fixed3D
Me.tb3.Font = New Font("微软雅黑", 10)
Me.tb3.SetBounds(0, 220, 220, 25)
Me.Controls.Add(tb3)
Me.tb4.BorderStyle = BorderStyle.Fixed3D
Me.tb4.Font = New Font("微软雅黑", 10)
Me.tb4.SetBounds(Me.tb3.Width + 10, 220, 110, 25)
Me.Controls.Add(tb4)
Me.tb5.BorderStyle = BorderStyle.Fixed3D
Me.tb5.Font = New Font("微软雅黑", 10)
Me.tb5.SetBounds(0, 255, 220, 25)
Me.Controls.Add(tb5)
Me.tb6.BorderStyle = BorderStyle.Fixed3D
Me.tb6.Font = New Font("微软雅黑", 10)
Me.tb6.SetBounds(Me.tb5.Width + 10, 255, 110, 25)
Me.Controls.Add(tb6)
Me.tb7.BorderStyle = BorderStyle.Fixed3D
Me.tb7.Font = New Font("微软雅黑", 10)
Me.tb7.SetBounds(0, 290, 220, 25)
Me.Controls.Add(tb7)
Me.tb8.BorderStyle = BorderStyle.Fixed3D
Me.tb8.Font = New Font("微软雅黑", 10)
Me.tb8.SetBounds(Me.tb7.Width + 10, 290, 110, 25)
Me.Controls.Add(tb8)
Me.tb9.BorderStyle = BorderStyle.Fixed3D
Me.tb9.Font = New Font("微软雅黑", 10)
Me.tb9.SetBounds(0, 325, 220, 25)
Me.Controls.Add(tb9)
Me.tb10.BorderStyle = BorderStyle.Fixed3D
Me.tb10.Font = New Font("微软雅黑", 10)
Me.tb10.SetBounds(Me.tb9.Width + 10, 325, 110, 25)
Me.Controls.Add(tb10)
Me.heji11.BorderStyle = BorderStyle.Fixed3D
Me.heji11.Font = New Font("微软雅黑", 14)
Me.heji11.Text = "合计:"
Me.heji11.SetBounds(0, 400, 220, 25)
Me.Controls.Add(heji11)
Me.heji12.BorderStyle = BorderStyle.Fixed3D
Me.heji12.Font = New Font("微软雅黑", 14)
Me.heji12.Text = "0.00"
Me.heji12.SetBounds(Me.heji11.Width + 10, 400, 110, 25)
Me.Controls.Add(heji12)
Me.shijian.BorderStyle = BorderStyle.Fixed3D
Me.shijian.Font = New Font("微软雅黑", 14)
Me.shijian.Text = "开票时间"
Me.shijian.SetBounds(0, 470, 110, 25)
Me.Controls.Add(shijian)
Me.dtp.Font = New Font("微软雅黑", 10)
Me.dtp.SetBounds(Me.shijian.Width + 10, 470, 220, 25)
Me.Controls.Add(dtp)
Me.kaipiaoren1.BorderStyle = BorderStyle.Fixed3D
Me.kaipiaoren1.Font = New Font("微软雅黑", 14)
Me.kaipiaoren1.Text = "开票人"
Me.kaipiaoren1.SetBounds(0, 505, 110, 25)
Me.Controls.Add(kaipiaoren1)
Me.kaipiaoren2.BorderStyle = BorderStyle.Fixed3D
Me.kaipiaoren2.Font = New Font("微软雅黑", 10)
Me.kaipiaoren2.Text = "许"
Me.kaipiaoren2.SetBounds(Me.kaipiaoren1.Width + 10, 505, 220, 25)
Me.Controls.Add(kaipiaoren2)
Me.jisuan.Font = New Font("微软雅黑", 14)
Me.jisuan.Text = "计算"
Me.jisuan.SetBounds(0, 540, 110, 60)
Me.Controls.Add(jisuan)
Me.yulan.Font = New Font("微软雅黑", 14)
Me.yulan.Text = "预览"
Me.yulan.SetBounds(120, 540, 110, 60)
Me.Controls.Add(yulan)
Me.dayin.Font = New Font("微软雅黑", 14)
Me.dayin.Text = "打印"
Me.dayin.SetBounds(240, 540, 110, 60)
Me.Controls.Add(dayin)
Me.yulan.Enabled = False
Me.dayin.Enabled = False
End Sub
Private Sub jisuan_Click(sender As Object, e As EventArgs) Handles jisuan.Click
Dim i1 = Val(Me.tb2.Text)
Dim i2 = Val(Me.tb4.Text)
Dim i3 = Val(Me.tb6.Text)
Dim i4 = Val(Me.tb8.Text)
Dim i5 = Val(Me.tb10.Text)
Me.heji12.Text = (i1 + i2 + i3 + i4 + i5).ToString("#0.00")
Me.yulan.Enabled = True
End Sub
Private Sub yulan_Click(sender As Object, e As EventArgs) Handles yulan.Click
Me.dayin.Enabled = True
Me.ppd.Document = Me.pdoc
Me.ppd.ShowDialog()
End Sub
Private Sub dayin_Click(sender As Object, e As EventArgs) Handles dayin.Click
If Me.pd.ShowDialog() = Windows.Forms.DialogResult.OK Then
Me.pdoc.Print()
End If
End Sub
Private Sub pdoc_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles pdoc.PrintPage
Dim f As Font = New Font("宋体", 9)
Dim b As Brush = Brushes.Black
e.Graphics.DrawString(Me.username2.Text, f, b, 32, 65)
e.Graphics.DrawString(Me.username2.Text, f, b, 262, 65)
e.Graphics.DrawString(Me.username2.Text, f, b, 542, 65)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 32, 87)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 262, 87)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 512, 87)
e.Graphics.DrawString("计价单位:元", f, b, 12, 119)
e.Graphics.DrawString("计价单位:元", f, b, 232, 119)
e.Graphics.DrawString("计价单位:元", f, b, 512, 119)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 13, 147)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 233, 147)
e.Graphics.DrawString(Me.huanzhe2.Text, f, b, 513, 147)
End Sub
End Class