📄 pipedata-input.frm
字号:
Exit Sub
End If
If Not IsNumeric(Trim(Text15.Text)) Then
MsgBox ("进水支管长度错误!")
Exit Sub
End If
If CDbl(Trim(Text15.Text)) > 32767 Or CDbl(Trim(Text15.Text)) < 0 Then
MsgBox ("进水支管长度超出范围!")
Exit Sub
End If
If (Trim(Combo8.Text) <> "") And (Not (IsNumeric(Mid(Trim(Combo8.Text), 1, 3)))) Then
MsgBox ("泵站编号必须为3位数字!")
Exit Sub
End If
If ((Trim(Text18.Text) <> "") And (Len(Trim(Text18.Text)) <> 4 Or (Not IsNumeric(Text18.Text)))) Then
MsgBox ("所属污水厂必须为4位数字!")
Exit Sub
End If
If ((Trim(Text19.Text) <> "") And (Len(Trim(Text19.Text)) <> 3 Or (Not IsNumeric(Text19.Text)))) Then
MsgBox ("所属出口闸必须为3位数字!")
Exit Sub
End If
If ((Trim(Text20.Text) <> "") And (Len(Trim(Text20.Text)) <> 7 Or (Not IsNumeric(Text20.Text)))) Then
MsgBox ("上级管段编码必须为7位数字!")
Exit Sub
End If
If (Trim(Combo9.Text) <> "") And (Not (IsNumeric(Mid(Trim(Combo9.Text), 1, 2)))) Then
MsgBox ("行政区必须为2位数字!")
Exit Sub
End If
'保存数据前,查询该数据是否存在
txtSQL = " Select * from ghd where PipeSegId='" & Mid(Trim(Combo1.Text), 1, 2) + Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
If MsgBox("该记录已存在,是否要修改该记录!", vbOKCancel) = vbOK Then
txtSQL = "Delete from ghd where PipeSegId='" & Mid(Trim(Combo1.Text), 1, 2) + Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
Else
Text1.SetFocus
Exit Sub
End If
End If
'保存数据
txtSQL = "Select * from ghd"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = Mid(Trim(Combo1.Text), 1, 2) + Trim(Text1.Text)
If (IsNumeric(Mid(Trim(Combo2.Text), 1, 4))) Then
mrc.Fields(1) = Trim(Mid(Trim(Combo2.Text), 1, 4))
Else
mrc.Fields(1) = Trim(Mid(Trim(Combo2.Text), 1, 2))
End If
mrc.Fields(2) = Trim(Text2.Text)
mrc.Fields(3) = Trim(Text3.Text)
mrc.Fields(4) = CInt(Trim(Text4.Text))
mrc.Fields(5) = CInt(Trim(Text5.Text))
mrc.Fields(6) = Round(CDbl(Trim(Text6.Text)), 2)
mrc.Fields(7) = Round(CDbl(Trim(Text7.Text)), 2)
mrc.Fields(8) = Round(CDbl(Trim(Text8.Text)), 2)
mrc.Fields(9) = CInt(Trim(Text9.Text))
mrc.Fields(10) = CInt(Trim(Text10.Text))
mrc.Fields(11) = CInt(Trim(Text11.Text))
mrc.Fields(12) = CInt(Trim(Text12.Text))
mrc.Fields(13) = CInt(Trim(Text13.Text))
mrc.Fields(14) = CInt(Trim(Text14.Text))
mrc.Fields(15) = CInt(Trim(Text15.Text))
mrc.Fields(16) = Trim(Mid(Combo3.Text, 1, 1))
mrc.Fields(17) = Trim(Mid(Combo4.Text, 1, 1))
mrc.Fields(18) = Trim(Mid(Combo5.Text, 1, 1))
mrc.Fields(19) = Trim(Mid(Combo6.Text, 1, 1))
mrc.Fields(20) = Trim(Text16.Text)
mrc.Fields(21) = Trim(Mid(Combo8.Text, 1, 3))
mrc.Fields(22) = Trim(Text18.Text)
mrc.Fields(23) = Trim(Text19.Text)
mrc.Fields(24) = Trim(Text20.Text)
mrc.Fields(25) = Trim(Text21.Text)
mrc.Fields(26) = Trim(Mid(Trim(Combo9.Text), 1, 2))
mrc.Update
MsgBox ("该条记录保存成功!")
mrc.Close
Text2.SetFocus
'数据更新
t = Mid(Trim(Combo1.Text), 1, 2) + Mid(Trim(Text1.Text), 1, 2) + "%"
Adodc1.RecordSource = "Select * from ghd where PipeSegId like '" & t & "' "
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1.Recordset
DataGrid1.Refresh
'设置列标题及列宽度
szbt
DataGrid1.TextMatrix(DataGrid1.RowSel, 0) = "*"
'定位指针到最近插入的记录
j = 1
X = DataGrid1.Rows
For i = 1 To X - 1 Step 1
t = Mid(Trim(Combo1.Text), 1, 2) + Trim(Text1.Text)
If (t = DataGrid1.TextMatrix(i, 1)) Then
Me.DataGrid1.RowSel = i
j = i
Exit For
End If
Next i
X = j
Me.DataGrid1.Row = X - 1
Me.DataGrid1.RowSel = X
Me.DataGrid1.TopRow = X
'为下一次添加数据准备
Text1.Text = Right("000000" + Trim(Str((Val(Text1.Text) + 1))), 5)
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Text15.Text = ""
Text21.Text = ""
End Sub
Private Sub Command4_Click()
Dim mrc As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
Dim t As String
Set mrc = New ADODB.Recordset
If Trim(Text1.Text) = "" Then
MsgBox ("删除时,管段编码不能为空!")
Exit Sub
End If
t = Mid(Trim(Combo1.Text), 1, 2) + Trim(Text1.Text)
txtSQL = " Select * from ghd where PipeSegId='" & t & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox ("不存在该记录!")
Exit Sub
End If
If mrc.EOF = False Then
If MsgBox("该记录已存在,是否要删除该记录!", vbOKCancel) = vbOK Then
'删除记录
txtSQL = "Delete from ghd where PipeSegId='" & t & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'数据更新
t = Mid(Trim(Combo1.Text), 1, 2) + Mid(Trim(Text1.Text), 1, 4) + "%"
Adodc1.RecordSource = "Select * from ghd where PipeSegId like '" & t & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1.Recordset
DataGrid1.Refresh
szbt
DataGrid1.TextMatrix(DataGrid1.Row, 0) = "*"
Else
Exit Sub
End If
End If
End Sub
Private Sub Command5_Click()
Dim X As Long
X = Me.DataGrid1.RowSel
X = X - 1
If (X > 0) Then
Me.DataGrid1.Row = X - 1
Me.DataGrid1.RowSel = X
Me.DataGrid1.TopRow = X
DataGrid1_EnterCell11
End If
End Sub
Private Sub Command6_Click()
Dim X As Long
X = Me.DataGrid1.RowSel
X = X + 1
If (X < Me.DataGrid1.Rows) Then
Me.DataGrid1.Row = X - 1
Me.DataGrid1.RowSel = X
Me.DataGrid1.TopRow = X
DataGrid1_EnterCell11
End If
End Sub
Private Sub Command7_Click()
Me.DataGrid1.Row = Me.DataGrid1.Rows - 2
Me.DataGrid1.RowSel = Me.DataGrid1.Rows - 1
Me.DataGrid1.TopRow = Me.DataGrid1.Rows - 1
DataGrid1_EnterCell11
End Sub
Private Sub Command8_Click()
Me.DataGrid1.Row = 0
Me.DataGrid1.RowSel = 1
Me.DataGrid1.TopRow = 1
DataGrid1_EnterCell11
End Sub
Private Sub DataGrid1_Click()
DataGrid1_EnterCell11
End Sub
Private Sub DataGrid1_EnterCell11()
Dim X, Y As Long
X = Me.DataGrid1.RowSel
If (X < 0) Then
Exit Sub
End If
If (DataGrid1.TextMatrix(X, 1) = "") Then
Exit Sub
End If
Combo1.Text = Mid(DataGrid1.TextMatrix(X, 1), 1, 2)
Text1.Text = Mid(DataGrid1.TextMatrix(X, 1), 3, 5)
Combo2.Text = DataGrid1.TextMatrix(X, 2)
Text2.Text = DataGrid1.TextMatrix(X, 3)
Text3.Text = DataGrid1.TextMatrix(X, 4)
Text4.Text = DataGrid1.TextMatrix(X, 5)
Text5.Text = DataGrid1.TextMatrix(X, 6)
Text6.Text = DataGrid1.TextMatrix(X, 7)
If (DataGrid1.TextMatrix(X, 7) <> "") Then
Text6.Text = Round(CDbl(DataGrid1.TextMatrix(X, 7)), 2)
End If
Text7.Text = DataGrid1.TextMatrix(X, 8)
If (DataGrid1.TextMatrix(X, 8) <> "") Then
Text7.Text = Round(CDbl(DataGrid1.TextMatrix(X, 8)), 2)
End If
Text8.Text = DataGrid1.TextMatrix(X, 9)
If (DataGrid1.TextMatrix(X, 9) <> "") Then
Text8.Text = Round(CDbl(DataGrid1.TextMatrix(X, 9)), 2)
End If
Text9.Text = DataGrid1.TextMatrix(X, 10)
Text10.Text = DataGrid1.TextMatrix(X, 11)
Text11.Text = DataGrid1.TextMatrix(X, 12)
Text12.Text = DataGrid1.TextMatrix(X, 13)
Text13.Text = DataGrid1.TextMatrix(X, 14)
Text14.Text = DataGrid1.TextMatrix(X, 15)
Text15.Text = DataGrid1.TextMatrix(X, 16)
Combo3.Text = DataGrid1.TextMatrix(X, 17)
Combo4.Text = DataGrid1.TextMatrix(X, 18)
Combo5.Text = DataGrid1.TextMatrix(X, 19)
Combo6.Text = DataGrid1.TextMatrix(X, 20)
Text16.Text = DataGrid1.TextMatrix(X, 21)
Combo8.Text = DataGrid1.TextMatrix(X, 22)
Text18.Text = DataGrid1.TextMatrix(X, 23)
Text19.Text = DataGrid1.TextMatrix(X, 24)
Text20.Text = DataGrid1.TextMatrix(X, 25)
Text21.Text = DataGrid1.TextMatrix(X, 26)
Combo9.Text = DataGrid1.TextMatrix(X, 27)
For Y = 1 To DataGrid1.Rows - 1
If (Y <> DataGrid1.RowSel) Then
DataGrid1.TextMatrix(Y, 0) = ""
Else
DataGrid1.TextMatrix(Y, 0) = "*"
End If
Next Y
End Sub
Private Sub Form_Load()
szbt
DataGrid1.TextMatrix(DataGrid1.Row, 0) = "*"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo2.SetFocus
End If
End Sub
Private Sub Text10_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text12_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text13_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text14_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text15_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text16_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text18_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text19_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text20_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
Private Sub Text21_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command2_Click
End If
End Sub
P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -