📄 frm_xqinfo.frm
字号:
Top = 1695
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "小区名称"
Height = 180
Index = 1
Left = 2190
TabIndex = 32
Top = 360
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "负责人"
Height = 180
Index = 3
Left = 165
TabIndex = 31
Top = 1260
Width = 540
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "竣工日期:"
Height = 180
Left = 3090
TabIndex = 30
Top = 3420
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "建筑面积"
Height = 180
Index = 6
Left = 165
TabIndex = 29
Top = 1695
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "绿化面积"
Height = 180
Index = 8
Left = 4125
TabIndex = 28
Top = 1695
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "楼栋数"
Height = 180
Index = 4
Left = 2190
TabIndex = 27
Top = 1260
Width = 540
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "总户数"
Height = 180
Index = 5
Left = 4140
TabIndex = 26
Top = 1245
Width = 540
End
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = -240
Top = 2415
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Frame Frame3
Height = 645
Left = 4230
TabIndex = 5
Top = 3945
Width = 5160
Begin VB.CommandButton CmdExit
Caption = "返回"
Height = 360
Left = 4020
TabIndex = 9
Top = 180
Width = 990
End
Begin VB.CommandButton CmdDelete
Caption = "删除"
Height = 360
Left = 3045
TabIndex = 10
Top = 180
Width = 990
End
Begin VB.CommandButton CmdCancel
Caption = "取消"
Height = 360
Left = 2070
TabIndex = 8
Top = 180
Width = 990
End
Begin VB.CommandButton CmdSave
Caption = "保存"
Height = 360
Left = 1095
TabIndex = 7
Top = 180
Width = 990
End
Begin VB.CommandButton CmdAdd
Caption = "添加"
Height = 360
Left = 120
TabIndex = 6
Top = 180
Width = 990
End
End
Begin VB.Frame Frame4
BackColor = &H80000000&
Height = 645
Left = 60
TabIndex = 0
Top = 3945
Width = 4140
Begin VB.CommandButton CmdMD
BackColor = &H00FFC0C0&
Caption = "最后一个"
Height = 360
Index = 3
Left = 3015
Picture = "Frm_xqinfo.frx":0000
TabIndex = 1
Top = 180
Width = 990
End
Begin VB.CommandButton CmdMD
BackColor = &H00FFC0C0&
Caption = "下一个"
Height = 360
Index = 2
Left = 2040
Picture = "Frm_xqinfo.frx":15AD
TabIndex = 2
Top = 180
Width = 990
End
Begin VB.CommandButton CmdMD
BackColor = &H00FFC0C0&
Caption = "上一个"
Height = 360
Index = 1
Left = 1065
Picture = "Frm_xqinfo.frx":2AB1
TabIndex = 3
Top = 180
Width = 990
End
Begin VB.CommandButton CmdMD
BackColor = &H00FFC0C0&
Caption = "第一个"
Height = 360
Index = 0
Left = 90
Picture = "Frm_xqinfo.frx":3FE3
TabIndex = 4
Top = 180
Width = 990
End
End
End
Attribute VB_Name = "Frm_xqinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub view_data() '声明一个显示reads表中数据的过程
With Adodc1.Recordset
For i = 0 To 11
If .Fields(i) <> "" Then
Text1(i).Text = .Fields(i)
Else
Text1(i).Text = ""
End If
If .Fields("图片") <> "" Then
Lbllj.Caption = .Fields("图片")
If Dir(.Fields("图片")) <> "" Then
Picture1.Picture = LoadPicture(.Fields("图片"))
Else
MsgBox "此图片路径错误,请更改!"
Picture1.Picture = LoadPicture("")
End If
Else
Lbllj.Caption = ""
Picture1.Picture = LoadPicture("")
End If
Next i
End With
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTPicker2.SetFocus
End Sub
Private Sub DTPicker2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then CmdSave.SetFocus
End Sub
Private Sub CmdAdd_Click()
For i = 1 To 11
Text1(i).Text = ""
Next i
adors.Open "select * from tab_xqinfo order by val(小区编号)", cn, adOpenKeyset, adLockOptimistic
With adors
If .RecordCount > 0 Then
If .EOF = False Then .MoveLast
Text1(0).Text = Val(.Fields("小区编号")) + 1
Else
Text1(0).Text = "1"
End If
End With
adors.Close
Text1(1).SetFocus
End Sub
Private Sub CmdAddPicture_Click()
'添加图片
With CommonDialog1
.DialogTitle = "选择要追加的图片"
.Filter = "JPG图片|*.JPG"
.ShowOpen '打开对话框
Picture1.Picture = LoadPicture(.FileName)
Lbllj.Caption = .FileName
End With
End Sub
Private Sub CmdCancel_Click()
For i = 1 To 11
Text1(i).Text = ""
Next i
Picture1.Picture = LoadPicture("")
Lbllj.Caption = ""
End Sub
Private Sub CmdClearPicture_Click()
Picture1.Picture = LoadPicture("")
End Sub
Private Sub CmdDelete_Click()
If Adodc1.Recordset.RecordCount > 0 Then
a = MsgBox("您确实要删除这条数据吗?", vbYesNo)
If a = vbYes Then
'删除当前记录
Adodc1.Recordset.Delete
Adodc1.Recordset.Update
End If
End If
End Sub
Private Sub CmdMD_Click(Index As Integer)
Select Case Index
Case Is = 0 '移到第一条记录
If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
Case Is = 1 '移到上一条记录
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
End If
Case Is = 2 '移到下一条记录
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
End If
Case Is = 3 '移到最后一条记录
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
End Select
Call view_data '调用过程
End Sub
Private Sub CmdSave_Click()
adors.Open "select * from tab_xqinfo where 小区编号='" & Text1(0) & "'", cn, adOpenKeyset, adLockOptimistic
If adors.RecordCount > 0 Then
Set adors = cn.Execute("update tab_xqinfo set 小区名称 ='" & Text1(1) & "',小区说明 ='" & Text1(2) & "',负责人 ='" & Text1(3) & "',楼栋数 ='" & Text1(4) & "',总户数 ='" & Text1(5) & "',建筑面积 ='" & Text1(6) & "',居住面积 ='" & Text1(7) & "',绿化面积 ='" & Text1(8) & "',占地面积 ='" & Text1(9) & "',地址 ='" & Text1(10) & "',备注 ='" & Text1(11) & "',图片 ='" & Lbllj.Caption & "',交工日期='" & DTPicker1 & "',竣工日期='" & DTPicker2 & "'where 小区编号='" & Text1(0) & "'")
MsgBox "数据保存成功", 32, "管理信息系统"
Adodc1.Refresh
CmdCancel_Click
Else
adors.AddNew
For i = 0 To 11
adors.Fields(i) = Text1(i).Text
Next i
adors.Fields(12) = Lbllj.Caption
adors.Fields(13) = DTPicker1.Value
adors.Fields(14) = DTPicker2.Value
adors.Update
Adodc1.Refresh
CmdCancel_Click
End If
adors.Close
End Sub
Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub Form_Load()
Adodc1.RecordSource = "select * from tab_xqinfo order by 小区编号"
Adodc1.Refresh
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If Index < 11 And KeyCode = vbKeyReturn Then
SendKeys "{Home}+{End}"
Text1(Index + 1).SetFocus
End If
If Index = 11 And KeyCode = vbKeyReturn Then DTPicker1.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -