实例介绍
【实例简介】vb.net语言做的吊牌打印软件
【实例截图】
【核心代码】
Public Class Form1
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
'如果我没记错的话, .net里是没Any这个类型的, 你把他改为Long
Private Declare Sub ReleaseCapture Lib "User32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
End
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackgroundImage = Image.FromFile(Application.StartupPath "\01.png")
db_m = GetDataSet("select * from 模版")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If db_m Is Nothing Then
Button1_Click(sender, e)
Else
Form3.ShowDialog()
If ck_m = "" Then
Exit Sub
Else
Dim db As DataSet
db = GetDataSet("select * from 模版 where 名称='" & ck_m & "'")
pback1.Width = pback1.Height / db.Tables(0).Rows(0).Item(32) * db.Tables(0).Rows(0).Item(31)
Dim scw, sch, sc As Integer
Dim bl As Double
scw = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width
sch = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height
sc = Math.Sqrt(scw * scw sch * sch) / 17
bl = pback1.Height / (120 / 25.4 * 96)
'MsgBox(bl)
ps = db.Tables(0).Rows(0).Item(33)
For i = 1 To 10
px(i - 1) = db.Tables(0).Rows(0).Item((i - 1) * 3 1)
py(i - 1) = db.Tables(0).Rows(0).Item((i - 1) * 3 2)
pback1.Controls("lab" & i).Text = db.Tables(0).Rows(0).Item((i - 1) * 3)
pback1.Controls("lab" & i).Font = New Font("黑体", db.Tables(0).Rows(0).Item(33) * bl)
pback1.Controls("lab" & i).Left = pback1.Height / db.Tables(0).Rows(0).Item(32) * db.Tables(0).Rows(0).Item((i - 1) * 3 1) * bl
pback1.Controls("lab" & i).Top = pback1.Height / db.Tables(0).Rows(0).Item(32) * db.Tables(0).Rows(0).Item((i - 1) * 3 2) * bl
If pback1.Controls("lab" & i).Text = "" Then
Me.Controls("tb" & i).Visible = False
Me.Controls("lbc" & i).Visible = False
Else
Me.Controls("lbc" & i).Text = db.Tables(0).Rows(0).Item((i - 1) * 3)
Me.Controls("tb" & i).Visible = True
Me.Controls("lbc" & i).Visible = True
End If
Next
Button8_Click(sender, e)
Button3.Enabled = True
Button4.Enabled = True
Button7.Enabled = True
Button8.Enabled = True
Button9.Enabled = True
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.TextBox31.Text = ""
Form2.Button1.Text = "添加"
Form2.ShowDialog()
' Form1_Load(sender, e)
For i = 1 To 10
Me.pback1.Controls("lab" & i).Text = ""
Me.Controls("tb" & i).Visible = False
Me.Controls("lbc" & i).Visible = False
Next
DGV1.Rows.Clear()
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
Button10.Enabled = False
Button11.Enabled = False
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Form4.Text = ck_m
Form4.ShowDialog()
Button8_Click(sender, e)
End Sub
Private Sub DGV1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGV1.DoubleClick
End Sub
Private Sub DGV1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DGV1.Click
On Error GoTo err
If DGV1(0, DGV1.CurrentCell.RowIndex).Value <> "" Then
For i = 1 To 10
Me.Controls("tb" & i).Text = DGV1(i, DGV1.CurrentCell.RowIndex).Value
pn(i - 1) = DGV1(i, DGV1.CurrentCell.RowIndex).Value
pback1.Controls("lab" & i).Text = DGV1(i, DGV1.CurrentCell.RowIndex).Value
Next
Button5.Enabled = True
Button10.Enabled = True
Button11.Enabled = True
End If
err:
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Dim db As DataSet
db = GetDataSet("select * from 参数 where 模版='" & ck_m & "'")
DGV1.Rows.Clear()
If db Is Nothing Then
Else
For i = 1 To db.Tables(0).Rows.Count
DGV1.Rows.Add()
For j = 0 To 10
DGV1(j, i - 1).Value = db.Tables(0).Rows(i - 1).Item(j)
Next
Next
End If
Button5.Enabled = False
Button10.Enabled = False
Button11.Enabled = False
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If MsgBox("确定要删除当前参数", vbYesNo, "参数删除") = vbNo Then Exit Sub
Dim str As String = ""
For i = 1 To 10
If Me.Controls("tb" & i).Visible = True Then
str = str " and " "内容" i.ToString "='" Me.Controls("tb" & i).Text "'"
End If
Next
str = "delete * from 参数 where 模版='" ck_m "'" str
InsertDataSet(str)
MsgBox("删除成功!")
Button8_Click(sender, e)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If MsgBox("确定要删除模版" ck_m, vbYesNo, "模版删除") = vbYes Then
InsertDataSet("delete * from 模版")
MsgBox("删除成功!")
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If ck_m <> "" Then
Form2.TextBox31.Text = ck_m
Form2.TextBox31.Enabled = False
Form2.Button1.Text = "修改"
Form2.ShowDialog()
Form1_Load(sender, e)
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If lab1.Text = "" Then
MsgBox("请先选择模版,在进行搜索!")
Exit Sub
End If
If TextBox1.Text = "" Then
MsgBox("搜索内容不能为空!")
Exit Sub
End If
Dim db As DataSet
db = GetDataSet("select * from 参数 where 模版='" & ck_m & "' and 内容1 like '%" TextBox1.Text "%' or 内容2 like '%" TextBox1.Text "%' or 内容3 like '%" TextBox1.Text "%' or 内容4 like '%" TextBox1.Text "%' or 内容5 like '%" TextBox1.Text "%' or 内容6 like '%" TextBox1.Text "%' or 内容7 like '%" TextBox1.Text "%' or 内容8 like '%" TextBox1.Text "%' or 内容9 like '%" TextBox1.Text "%' or 内容10 like '%" TextBox1.Text "%'")
DGV1.Rows.Clear()
If db Is Nothing Then
Else
For i = 1 To db.Tables(0).Rows.Count
DGV1.Rows.Add()
For j = 0 To 10
DGV1(j, i - 1).Value = db.Tables(0).Rows(i - 1).Item(j)
Next
Next
End If
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
Form5.Button1.Enabled = True
Form5.ShowDialog()
If Form5.Button1.Enabled = False Then
For i = 1 To 10
pn(i - 1) = Me.Controls("tb" & i).Text
Next
PrintDialog1.Document = PrintDocument1
PrintDialog1.ShowDialog()
For i = 1 To CInt(Form5.TextBox1.Text)
PrintDocument1.Print()
Next
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
For i = 1 To 10
e.Graphics.DrawString(pn(i - 1), New Font("黑体", ps), Brushes.Black, px(i - 1) * 38 / 10, py(i - 1) * 38 / 10)
Next
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Button5_Click(sender, e)
End Sub
Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim lngReturnValue As Long
If e.Button = MouseButtons.Left Then
ReleaseCapture()
lngReturnValue = SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
For i = 1 To 10
If DGV1(i, DGV1.CurrentCell.RowIndex).Value <> Me.Controls("tb" & i).Text Then
GoTo nt
End If
Next
Exit Sub
nt:
If MsgBox("确定要保存当前参数么?", vbYesNo, "参数保存") = vbNo Then Exit Sub
Dim str As String = ""
Dim st1, st2 As String
st1 = ""
st2 = ""
For i = 1 To 10
If Me.Controls("tb" & i).Visible = True Then
If Me.Controls("tb" & i).Text = "" Then
MsgBox("内容不能为空")
Exit Sub
End If
st1 = st1 ",内容" i.ToString "='" Me.Controls("tb" & i).Text "'"
st2 = st2 " and 内容" i.ToString "='" DGV1(i, DGV1.CurrentCell.RowIndex).Value "'"
str = str " and 内容" i.ToString "='" Me.Controls("tb" & i).Text "'"
End If
Next
st1 = " 模版='" ck_m "'" st1
str = " where 模版='" ck_m "'" str
st2 = " where 模版='" ck_m "'" st2
If GetDataSet("select * from 参数" str) Is Nothing Then
UpdateDataSet("update 参数 set " st1 st2)
MsgBox("参数保存成功", , "参数保存")
Button8_Click(sender, e)
End If
End Sub
End Class
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论