Text1.Text = ""
Text1.SetFocus
End If
End If
Else
If Option2.Value = True Then
Option1.Value = False
Text2.SetFocus
Set xinxi = New ADODB.Connection
xinxi.CursorLocation = adUseClient
xinxi.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=F:\仓库管理系统\cangkuzl.mdb;Persist Security Info=False"
Set rstxinxi = New ADODB.Recordset
Set rstxinxi.ActiveConnection = xinxi
rstxinxi.Open "select * from yiqixinxi", xinxi, adOpenStatic, adLockOptimistic
If Text2.Text = "" Then
MsgBox "请输入仪器名称", vbOKOnly, "警告"
Text2.SetFocus
Else
rstxinxi.Find ("yiqimingcheng = '" + Text2.Text + "'")
If rstxinxi.EOF Then
MsgBox "此仪器名称不存在,请重新输入!", vbOKOnly, "警告"
Text2.Text = " "
Else
txtyqbh.Text = rstxinxi.Fields("yiqibianhao")
txtflh.Text = rstxinxi.Fields("fenleihao")
txtyqmc.Text = rstxinxi.Fields("yiqimingcheng")
txtxh.Text = rstxinxi.Fields("xinghao")
txtgg.Text = rstxinxi.Fields("guige")
txtdj.Text = rstxinxi.Fields("danjia")
txtcj.Text = rstxinxi.Fields("changjia")
txtgzrq.Text = rstxinxi.Fields("gouzhiriqi")
txtxz.Text = rstxinxi.Fields("xianzhuang")
txtlyr.Text = rstxinxi.Fields("lingyongren")
txtjsr.Text = rstxinxi.Fields("jingshouren")
txtrksj.Text = rstxinxi.Fields("rukushijian")
rstxinxi.Close
xinxi.Close
Text2.Text = " "
Text2.SetFocus
End If
End If
End If
End If
End Sub
Private Sub Command2_Click()
If txtyqbh.Text = "" Then
MsgBox "请选择一条记录!", vbOKOnly + vbExclamation, "信息提示"
Else
Set xinxi = New ADODB.Connection
xinxi.CursorLocation = adUseClient
xinxi.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=F:\仓库管理系统\cangkuzl.mdb;Persist Security Info=False"
Set rstxinxi = New ADODB.Recordset
Set rstxinxi.ActiveConnection = xinxi
rstxinxi.Open "select * from yiqixinxi", xinxi, adOpenStatic, adLockOptimistic
rstxinxi.Find ("yiqibianhao = '" + txtyqbh.Text + "'")
If (vbYes = MsgBox("您确定要删除该纪录吗?,这可能回导致数据的丢失", vbYesNo + vbQuestion, "信息提示")) Then
rstxinxi.Delete
Call Command3_Click
MsgBox "删除信息成功!", vbOKOnly + vbExclamation, "信息提示"
rstxinxi.Close
xinxi.Close
End If
End If
End Sub
Private Sub a11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load Formtianjia
Formtianjia.Show
Case 2
Unload Me
Load Formxiugai
Formxiugai.Show
Case 3
Unload Me
Load Formshanchu
Formshanchu.Show
End Select
End Sub
Private Sub f11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load mainForm
mainForm.Show
Case 2
Dim i As Byte
Beep
i = MsgBox("你确定要退出仓库管理系统吗?", vbYesNo, "退出系统")
If i = vbYes Then
End
End If
End Select
End Sub
Private Sub s11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load Formchaxun
Formchaxun.Show
End Select
End Sub
Private Sub Timer1_Timer()
Labelsj.Caption = Now
End Sub
在visual basic中新建一个form,保存为formtianjia.frm。从工具箱中选择相应控件将其添加到窗体中,根据需要设置其各项属性,最后的添加信息窗体如图所示。
将窗体及其各控件的属性设置完毕后,根据需要为窗体及控件添加事件处理函数,程序如下:
Dim xinxi As New ADODB.Connection
Dim rstxinxi As New ADODB.Recordset
Private Sub Form_Load()
Set xinxi = New ADODB.Connection
xinxi.CursorLocation = adUseClient
xinxi.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=F:\仓库管理系统\cangkuzl.mdb;Persist Security Info=False"
Set rstxinxi = New ADODB.Recordset
Set rstxinxi.ActiveConnection = xinxi
rstxinxi.Open "select * from yiqixinxi", xinxi, adOpenStatic, adLockOptimistic
End Sub
Private Sub a11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load Formtianjia
Formtianjia.Show
Case 2
Unload Me
Load Formxiugai
Formxiugai.Show
Case 3
Unload Me
Load Formshanchu
Formshanchu.Show
End Select
End Sub
Private Sub Command1_Click()
txtyqbh.Text = ""
txtflh.Text = ""
txtyqmc.Text = ""
txtxh.Text = ""
txtgg.Text = ""
txtdj.Text = ""
txtcj.Text = ""
txtgzrq.Text = ""
txtxz.Text = ""
txtjsr.Text = ""
txtlyr.Text = ""
txtrksj.Text = ""
End Sub
Private Sub Command2_Click()
Set xinxi = New ADODB.Connection
xinxi.CursorLocation = adUseClient
xinxi.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=F:\仓库管理系统\cangkuzl.mdb;Persist Security Info=False"
Set rstxinxi = New ADODB.Recordset
Set rstxinxi.ActiveConnection = xinxi
rstxinxi.Open "select * from yiqixinxi", xinxi, adOpenStatic, adLockOptimistic
If Trim(txtyqbh.Text) = "" Then
MsgBox "请输入仪器编号!", vbOKOnly + vbExclamation, "信息提示"
txtyqbh.SetFocus
Exit Sub
End If
If Trim(txtyqmc.Text) = "" Then
MsgBox "请输入仪器名称!", vbOKOnly + vbExclamation, "信息提示"
txtyqmc.SetFocus
Exit Sub
End If
If Trim(txtxh.Text) = "" Then
MsgBox "请输入仪器型号!", vbOKOnly + vbExclamation, "信息提示"
txtxh.SetFocus
Exit Sub
End If
If Trim(txtdj.Text) = "" Then
MsgBox "请输入仪器单价!", vbOKOnly + vbExclamation, "信息提示"
txtdj.SetFocus
Exit Sub
End If
If Trim(txtgzrq.Text) = "" Then
MsgBox "请输入购置日期!", vbOKOnly + vbExclamation, "信息提示"
txtgzrq.SetFocus
Exit Sub
End If
If Trim(txtdj.Text) = "" Then
MsgBox "请输入领用单位号!", vbOKOnly + vbExclamation, "信息提示"
txtdj.SetFocus
Exit Sub
End If
If Trim(txtlyr.Text) = "" Then
MsgBox "请输入领用人!", vbOKOnly + vbExclamation, "信息提示"
txtlyr.SetFocus
Exit Sub
End If
If Trim(txtjsr.Text) = "" Then
MsgBox "请输入经手人!", vbOKOnly + vbExclamation, "信息提示"
txtjsr.SetFocus
Exit Sub
End If
rstxinxi.MoveFirst
rstxinxi.Find ("yiqibianhao = '" + txtyqbh.Text + "'")
If rstxinxi.Fields("yiqibianhao") = Trim(txtyqbh.Text) Then
MsgBox "此仪器编号已经存在!", vbOKOnly + vbExclamation, "警告"
txtyqbh.Text = ""
txtyqbh.SetFocus
Else
rstxinxi.MoveLast
rstxinxi.AddNew
rstxinxi.Fields("yiqibianhao") = Trim(txtyqbh.Text)
rstxinxi.Fields("fenleihao") = Trim(txtflh.Text)
rstxinxi.Fields("xinghao") = Trim(txtxh.Text)
rstxinxi.Fields("yiqimingcheng") = Trim(txtyqmc.Text)
rstxinxi.Fields("guige") = Trim(txtgg.Text)
rstxinxi.Fields("danjia") = Trim(txtdj.Text)
rstxinxi.Fields("changjia") = Trim(txtcj.Text)
rstxinxi.Fields("gouzhiriqi") = Trim(txtgzrq.Text)
rstxinxi.Fields("xianzhuang") = Trim(txtxz.Text)
rstxinxi.Fields("lingyongren") = Trim(txtlyr.Text)
rstxinxi.Fields("jingshouren") = Trim(txtjsr.Text)
rstxinxi.Fields("rukushijian") = Trim(txtrksj.Text)
rstxinxi.Update
MsgBox "添加信息成功", vbOKOnly + vbExclamation, "信息提示"
Call Command1_Click
rstxinxi.Close
xinxi.Close
End If
End Sub
Private Sub Command3_Click()
Call Command1_Click
End Sub
Private Sub f11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load mainForm
mainForm.Show
Case 2
Dim i As Byte
Beep
i = MsgBox("你确定要退出仓库管理系统吗?", vbYesNo, "退出系统")
If i = vbYes Then
End
End If
End Select
End Sub
Private Sub s11_Click(Index As Integer)
Select Case Index
Case 0
Unload Me
Load Formchaxun
Formchaxun.Show
End Select
End Sub
Private Sub Timer1_Timer()
Labelsj.Caption = Now
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页