Text1(6).Text = ""
Text1(1).SetFocus 'text1(1)获得焦点
End Sub
Private Sub ComModify_Click() '允许修改数据
If Adodc1.Recordset.RecordCount > 0 Then '当记录大于零时
Frame1.Visible = True 'frame1可见
'赋值给Text1(i)等
If Adodc1.Recordset.Fields(0) <> "" Then Text1(0).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(1) <> "" Then Text1(3).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(2) <> "" Then Text1(6).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(3) <> "" Then Text1(4).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(4) <> "" Then Text1(1).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(5) <> "" Then Text1(2).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(6) <> "" Then Text1(5).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(7) <> "" Then Text1(9).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields("属性") <> "" Then Combo1.Text = Trim(Adodc1.Recordset.Fields("属性"))
If Adodc1.Recordset.Fields(8) <> "" Then Text1(10).Text = Trim(Adodc1.Recordset.Fields(i))
Else
MsgBox "没有要修改的记录,请核对!"
End If
End Sub
Private Sub ComDelete_Click() '删除包房信息
Frame1.Visible = False 'frame1不可见
On Error Resume Next
Adodc1.Recordset.Delete '删除记录
Adodc1.Refresh '刷新记录
End Sub
Private Sub ComSave_Click()
txtSQL = "select * from 实验设备基本信息 where 型号='" & Trim(Text1(0).Text) & "'order by 型号"
Set rs1 = ESQL(txtSQL)
If rs1.RecordCount > 0 Then '当记录大于零时
Dim a As String '定义字符串变量
a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If a = vbYes Then
If Text1(10).Text = "" Then
MsgBox ("请输入型号!")
Exit Sub
End If
'赋值给数据库字段
rs1.Fields("型号") = Text1(0).Text: rs1.Fields("数量") = Text1(1).Text
rs1.Fields("单价") = Text1(2).Text: rs1.Fields("设备名称") = Text1(3).Text
rs1.Fields("生产厂家") = Text1(4).Text: rs1.Fields("属性") = Combo1.Text
rs1.Fields("总价") = Val(Text1(5).Text): rs1.Fields("购置日期") = Val(Text1(9).Text)
rs1.Fields("资金来源") = Val(Text1(10).Text): rs1.Fields("负责人姓名") = Text1(6).Text
rs1.Update '更新记录集
Adodc1.Refresh
End If
Else
If Text1(0).Text = "" Then
MsgBox ("请输入型号!")
Exit Sub
End If
If Text1(1).Text = "" Then
MsgBox ("请输入数量!")
Exit Sub
End If
If Text1(2).Text = "" Then
MsgBox ("请输入单价!")
Exit Sub
End If
If Text1(3).Text = "" Then
MsgBox ("请输入设备名称!")
Exit Sub
End If
If Text1(4).Text = "" Then
MsgBox ("请输入生产厂家!")
Exit Sub
End If
rs1.AddNew
'赋值给数据库字段
rs1.Fields("型号") = Text1(0).Text: rs1.Fields("数量") = Text1(1).Text
rs1.Fields("单价") = Text1(2).Text: rs1.Fields("设备名称") = Text1(3).Text
rs1.Fields("生产厂家") = Text1(4).Text: rs1.Fields("属性") = Combo1.Text
rs1.Fields("总价") = Val(Text1(5).Text): rs1.Fields("购置日期") = Val(Text1(9).Text)
rs1.Fields("资金来源") = Val(Text1(10).Text): rs1.Fields("负责人姓名") = Text1(6).Text
rs1.Update '更新记录集
Adodc1.Refresh
MsgBox "包房信息已成功保存!"
End If
Frame1.Visible = False '设置Frame1不可见
End Sub
Private Sub Comfind_Click() '查询
Select Case Combo4.Text
Case Is = "like"
Adodc1.RecordSource = "select * from 实验设备基本信息 where (实验设备基本信息." & Combo3.Text & " like +'%'+ '" + Text2.Text + "'+'%') order by 型号"
Adodc1.Refresh
Case Is = "="
Adodc1.RecordSource = "select * from 实验设备基本信息 where (实验设备基本信息." & Combo3.Text & " = '" + Text2.Text + "') order by 型号"
Adodc1.Refresh
End Select
End Sub
Private Sub ComEsc_Click() '取消操作
Frame1.Visible = False
End Sub
Private Sub ComExit_Click()
Unload Me
Form1.Enabled = True
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 12 Then KeyAscii = valiText(KeyAscii, "0123456789." & Chr(13), True)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then ComFind.SetFocus
End Sub若图片无法显示请联系QQ752018766,本论文免费,转发请注明源于www.youerw.com
图6.4 查询设备窗体
图6.5添加设备窗体
图6.5修改设备窗体
图6.5删除设备窗体
图6.6设备状态窗体
图6.7添加损坏的设备窗体
图6.8修改损坏的设备窗体
图6.9删除损坏的设备窗体
Dim i As Integer '定义整数变量,表示字段编号和数组编号
Dim rs1 As New ADODB.Recordset '定义数据集对象
Dim txtSQL As String '定义一个字符串变量
Private Sub Command2_Click()
Frame1.Visible = False
Form1.Enabled = True
End Sub
Private Sub Form_Load()
'添加部门列表
Combo1.AddItem ("是"):
Combo1.AddItem ("否"): Combo1.ListIndex = 0
'添加查询内容列表
Combo3.AddItem ("设备编号"): Combo3.ListIndex = 0
'添加查询条件列表
Combo4.AddItem ("like"): Combo4.AddItem ("=")
Combo4.ListIndex = 0
'查询所有包房信息,并按"编号"排序
Adodc1.RecordSource = "select * from 设备状态信息 order by 设备编号"
Adodc1.Refresh
End Sub
Private Sub Command1_Click()
txtSQL = "select * from 设备状态信息 order by 设备编号 ='" & Trim(Text1(0).Text) & "'order by 设备编号"
Set rs1 = ESQL(txtSQL)
If rs1.RecordCount > 0 Then '当记录大于零时
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>