设计要求:
设计要求:
在为"登录窗口"的窗体Form1上,添加两个标签分别设置为“用户名称”和“用户密码”。添加两个文本框,用于输入用户名称和密码。一个PictureBox控件,美化登录页面。输入用户名和密码验证登录,验证通过后进入下级页面。并设置L和C访问键。下级页面(Form2)设置为一张简单的采购单。form2上添加了8个标签,分别设置为:货品编码、货品名称、货品数量、货品单位、货品单价、税率、税额、价税合计;8个TextBox;4个Button按钮,设置为:新建、保存、取消、删除。form2的下方添加DataGridView用于浏览添加的数据。
界面设计:
代码设计:
Form1代码:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim user As String
Dim passwd As String
user = TextBox1.Text
passwd = TextBox2.Text
If YonghuTableAdapter.ScalarQuerylogin(user, passwd) Then
MessageBox.Show("登录成功")
Form2.Show()
Me.Hide()
Else
MessageBox.Show("密码或用户名错误")
TextBox1.Text = ""
TextBox2.Text = ""
End If
End Sub
Private Sub YonghuBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.YonghuBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.BjcgDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: 这行代码将数据加载到表“BjcgDataSet.yonghu”中。您可以根据需要移动或删除它。
Me.YonghuTableAdapter.Fill(Me.BjcgDataSet.yonghu)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Form2代码:
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: 这行代码将数据加载到表“BjcgDataSet.item”中。您可以根据需要移动或删除它。
Me.ItemTableAdapter.Fill(Me.BjcgDataSet.item)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
On Error GoTo SaveErr
ItemBindingSource.EndEdit()
ItemTableAdapter.Update(BjcgDataSet.item)
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim s As String
a = TextBox3.Text
b = TextBox8.Text
c = TextBox5.Text
d = TextBox6.Text
s = TextBox7.Text
s = a * b
d = s / (1 + c) * c
TextBox6.Text = FormatNumber(d, 2)
TextBox7.Text = FormatNumber(s, 2)
SaveErr:
Exit Sub
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ItemBindingSource.AddNew()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ItemBindingSource.RemoveCurrent()
End Sub
End Class
运行结果:
程序运行后,可以实现用户登录验证,并进入下级页面实现简单的录入操作。并计算货品的总价和相应的税额计算。
如若转载,请注明出处:https://www.daxuejiayuan.com/5606.html