📄 kumanage.frm
字号:
Combo1.Visible = False
If KeyAscii = 13 And MSFlexGrid2.Row <> MSFlexGrid2.Rows - 1 Then
MSFlexGrid2.Row = MSFlexGrid2.Row + 1
MSFlexGrid2.Col = 3
nextpos MSFlexGrid2.Row, MSFlexGrid2.Col
End If
End Sub
Private Sub Form_Load()
On Error GoTo loaderror
Dim sql As String
sql = "select * from 客户名"
rs_custom.CursorLocation = adUseClient
rs_custom.Open sql, conn, adOpenKeyset, adLockPessimistic
While Not rs_custom.EOF
Combo1.AddItem rs_custom.Fields(0)
rs_custom.MoveNext
Wend
findok = True
modify = False '非修改状态
showgrid2 = False
cmdcancel.Enabled = False
displaygrid1 '调用显示Datagrid1子程序
setgrid2head
loaderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
'显示msflexgrid1子程序
Public Sub displaygrid1()
Dim i As Integer
On Error GoTo displayerror
setgrid
setgridhead
MSFlexGrid1.Row = 0
If Not rs_data1.EOF Then
rs_data1.MoveFirst
Do While Not rs_data1.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
If Not IsNull(rs_data1.Fields(0)) Then MSFlexGrid1.Text = rs_data1.Fields(0) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 1
If Not IsNull(rs_data1.Fields(1)) Then MSFlexGrid1.Text = rs_data1.Fields(1) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 2
If Not IsNull(rs_data1.Fields(2)) Then MSFlexGrid1.Text = rs_data1.Fields(2) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 3
If Not IsNull(rs_data1.Fields(3)) Then MSFlexGrid1.Text = rs_data1.Fields(3) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 4
If Not IsNull(rs_data1.Fields(4)) Then MSFlexGrid1.Text = rs_data1.Fields(4) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 5
If Not IsNull(rs_data1.Fields(5)) Then MSFlexGrid1.Text = rs_data1.Fields(5) Else MSFlexGrid1.Text = ""
MSFlexGrid1.Col = 6
If rs_data1.Fields(6) = True Then MSFlexGrid1.Text = "入库" Else MSFlexGrid1.Text = "出库"
rs_data1.MoveNext
Loop
End If
displayerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Public Sub setgrid()
Dim i As Integer
On Error GoTo seterror
With MSFlexGrid1
.ScrollBars = flexScrollBarBoth
.FixedCols = 0
.Rows = rs_data1.RecordCount + 1
.Cols = 7
.SelectionMode = flexSelectionByRow
For i = 0 To .Rows - 1
.RowHeight(i) = 315
Next
For i = 0 To .Cols - 1
.ColWidth(i) = 1300
Next i
End With
Exit Sub
seterror:
MsgBox Err.Description
End Sub
Public Sub setgridhead()
On Error GoTo setheaderror
MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 0
MSFlexGrid1.Text = "货单号"
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "日期"
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = "货源地"
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = "编号"
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = " 经手人"
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = "备注"
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = "入出库"
Exit Sub
setheaderror:
MsgBox Err.Description
End Sub
Private Sub MSFlexGrid1_Click()
On Error GoTo griderror
Dim getrow As Long
If showgrid2 = True Then
rs_data2.Close
End If
getrow = MSFlexGrid1.Row
If MSFlexGrid1.Rows = 1 Then
MsgBox "无相关纪录", vbOKOnly + vbExclamation, ""
Else
select_row = MSFlexGrid1.TextMatrix(getrow, 0)
'入出库标志
jinchu = MSFlexGrid1.TextMatrix(getrow, 6)
displaygrid2
modify = True
End If
griderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Public Sub displaygrid2()
Dim sql As String
Dim i As Integer
On Error GoTo displaybasicerror
sql = "select * from 货物详况 where 货单号=" & "'" & select_row & "'"
rs_data2.Open sql, conn, adOpenKeyset, adLockPessimistic
showdata
showgrid2 = True
Exit Sub
displaybasicerror:
MsgBox Err.Description
End Sub
Public Sub setgrid2head()
Dim i As Integer
On Error GoTo set2error
With MSFlexGrid2
.ScrollBars = flexScrollBarBoth
.FixedCols = 0
.Cols = 9
.SelectionMode = flexSelectionByRow
For i = 0 To .Rows - 1
.RowHeight(i) = 315
Next
For i = 0 To .Cols - 1
.ColWidth(i) = 1000
Next i
.Row = 0
.Col = 0
.Text = "货单号"
.Col = 1
.Text = "日期"
.Col = 2
.Text = "货源地"
.Col = 3
.Text = "物品名称"
.Col = 4
.Text = "单价"
.Col = 5
.Text = "数量"
.Col = 6
.Text = "单位"
.Col = 7
.Text = "金额"
.Col = 8
.Text = "客户名"
End With
Exit Sub
set2error:
MsgBox Err.Description
End Sub
Public Sub showdata()
With MSFlexGrid2
.Rows = rs_data2.RecordCount + 1
.Row = 0
'rs_data2.RecordCount.Open
'MSFlexGrid2.Rows = rs_data2.RecordCount + 1
'MSFlexGrid2.Row = 0
If Not rs_data2.EOF Then
rs_data2.MoveFirst
Do While Not rs_data2.EOF
.Row = .Row + 1
.Col = 0
If Not IsNull(rs_data2.Fields(0)) Then .Text = rs_data2.Fields(0) Else .Text = ""
.Col = 1
If Not IsNull(rs_data2.Fields(1)) Then .Text = rs_data2.Fields(1) Else .Text = ""
.Col = 2
If Not IsNull(rs_data2.Fields(2)) Then .Text = rs_data2.Fields(2) Else .Text = ""
.Col = 3
If Not IsNull(rs_data2.Fields(3)) Then .Text = rs_data2.Fields(3) Else .Text = ""
.Col = 4
If Not IsNull(rs_data2.Fields(4)) And CDbl(rs_data2.Fields(4)) < 0 Then
.Text = -CDbl(rs_data2.Fields(4))
Else
.Text = rs_data2.Fields(4)
End If
.Col = 5
If Not IsNull(rs_data2.Fields(5)) Then .Text = rs_data2.Fields(5) Else .Text = ""
.Col = 6
If Not IsNull(rs_data2.Fields(6)) Then .Text = rs_data2.Fields(6) Else .Text = ""
.Col = 7
If Not IsNull(rs_data2.Fields(7)) And CDbl(rs_data2.Fields(4)) < 0 Then
.Text = -CDbl(rs_data2.Fields(7))
Else
.Text = rs_data2.Fields(7)
End If
.Col = 8
If Not IsNull(rs_data2.Fields(8)) Then .Text = rs_data2.Fields(8) Else .Text = ""
rs_data2.MoveNext
Loop
rs_data2.MoveLast
End If
End With
End Sub
Private Sub MSFlexGrid2_Click()
If cmdmodify.Caption = "确定" Then
MSFlexGrid2.Col = 3
nextpos MSFlexGrid2.Row, MSFlexGrid2.Col
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim i As Integer, j As Integer
Dim price As Double, coun As Integer
On Error GoTo texterror
If KeyAscii = 13 Then
MSFlexGrid2.Text = Text1.Text
i = MSFlexGrid2.Row
j = MSFlexGrid2.Col
If j = 3 And Trim(Text1.Text) = "" Then
MsgBox "物品名称不能为空", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If j = 4 And Not IsNumeric(Text1.Text) Then
MsgBox "单价请输入数字!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If j = 5 And Not IsNumeric(Text1.Text) Then
MsgBox "数量请输入数字!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If j = 6 And Trim(Text1.Text) = "" Then
MsgBox "单位不能为空!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Exit Sub
End If
If j = 6 And Not IsNull(Text1.Text) Then
MSFlexGrid2.Col = 4 '金额由程序算出
price = CDbl(MSFlexGrid2.Text)
MSFlexGrid2.Col = 5
coun = CInt(MSFlexGrid2.Text)
MSFlexGrid2.Col = 7
MSFlexGrid2.Text = price * coun
MSFlexGrid2.Col = MSFlexGrid2.Col + 1
Text1.Visible = False
Combo1.Width = MSFlexGrid2.CellWidth
Combo1.Left = MSFlexGrid2.Left + MSFlexGrid2.ColPos(8)
Combo1.Top = MSFlexGrid2.Top + MSFlexGrid2.RowPos(MSFlexGrid2.Row)
Combo1.Text = MSFlexGrid2.Text
Combo1.Visible = True
Combo1.SetFocus
KeyAscii = 0
Exit Sub
End If
MSFlexGrid2.Col = MSFlexGrid2.Col + 1
KeyAscii = 0
nextpos MSFlexGrid2.Row, MSFlexGrid2.Col
End If
Exit Sub
texterror:
MsgBox Err.Description
End Sub
Public Sub nextpos(ByVal r As Integer, ByVal c As Integer)
On Error GoTo nexterror
Text1.Width = MSFlexGrid2.CellWidth
Text1.Height = MSFlexGrid2.CellHeight
Text1.Left = MSFlexGrid2.Left + MSFlexGrid2.ColPos(c)
Text1.Top = MSFlexGrid2.Top + MSFlexGrid2.RowPos(r)
Text1.Text = MSFlexGrid2.Text
Text1.Visible = True
Text1.SetFocus
Exit Sub
nexterror:
MsgBox Err.Description
End Sub
Private Sub Form_Unload(Cancel As Integer)
findok = False
rs_data1.Close
rs_custom.Close
If showgrid2 = True Then
rs_data2.Close
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -