📄 form_incomeadd1.frm
字号:
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 1200
Left = 615
TabIndex = 22
Top = 5760
Width = 255
End
End
Attribute VB_Name = "form_incomeAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim s, y, i '定义变量
Dim mydb As Database '定义数据库
Dim rs1 As Recordset '定义字段
Dim rs2 As Recordset
Dim rsMaster As Recordset
Dim lsph As Integer '定义一个整型变量
Dim isAdd As Boolean '是否新增
Dim grid1IsVisible As Boolean
Dim m_billType As Integer
Private Sub cmdDeleteLine_Click()
For i = mf1.FixedCols To mf1.Cols - mf1.FixedCols
mf1.TextMatrix(mf1.Row, i) = ""
Next i
text1.Text = ""
Call fillTotalDataFromDtlData
If mf1.Row > 1 Then
mf1.Row = mf1.Row - 1
End If
Exit Sub
End Sub
Private Sub Form_Load()
grid1IsVisible = False
isAdd = True
enableControls (False)
'自动识别数据库路径
Data1.DatabaseName = g_dbPath
Data2.DatabaseName = g_dbPath
m_billType = 0
mf1.Rows = 31: mf1.Cols = 14 '定义mf1表的总行数、总列数
'定义mf1表的列宽和表头信息
s = Array("500", "1300", "1200", "900", "700", "450", "800", "800", "900", "700", "500", "900", "1000", 0)
y = Array("序号", "条 码 号", "物料名称", "型号", "规格", "单位", "净重", "价格", "金额", "轴重", "件数", "轴总重", "备注", "productId")
For i = 0 To 13
mf1.ColWidth(i) = s(i): mf1.TextMatrix(0, i) = y(i)
Next i
mf1.FixedRows = 1: mf1.FixedCols = 1 '定义mf1表的固定行数、固定列数
'定义mf1表的列序号
For i = mf1.FixedRows To mf1.Rows - mf1.FixedRows
mf1.TextMatrix(i, 0) = i
Next i
mf1.AllowUserResizing = flexResizeColumns
'定义msfgTtl表的列宽和表头信息
msfgTtl.Rows = 2: msfgTtl.Cols = 11 '定义msfgTtl表的总行数、总列数
msfgTtl.FixedRows = 1: msfgTtl.FixedCols = 1 '定义mf1表的固定行数、固定列数
s = Array("500", "1300", "1300", "900", "700", "700", "800", "900", "500", "900", 0)
y = Array("序号", "物料编号", "物料名称", "型号", "规格", "单位", "净重", "金额", "件数", "轴总重", "productId")
For i = 0 To 10
msfgTtl.ColWidth(i) = s(i): msfgTtl.TextMatrix(0, i) = y(i)
Next i
msfgTtl.Rows = mf1.Rows
For i = msfgTtl.FixedRows To msfgTtl.Rows - msfgTtl.FixedRows
msfgTtl.TextMatrix(i, 0) = i
Next i
billDate.Text = CStr(Now) '设置出库日期
Data1.RecordSource = "select * from hpos_products"
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 order by fullName"
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub gridCustomer_DblClick()
selectCustomer
End Sub
Private Sub gridCustomer_GotFocus()
text1.Visible = False
End Sub
Private Sub gridCustomer_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '当按回车键时
selectCustomer
End If
If KeyCode = vbKeyEscape Then '按ESC键
gridCustomer.Visible = False 'gridCustomer不可见
End If
End Sub
Private Sub selectCustomer()
With Data2.Recordset
If Data2.Recordset.RecordCount > 0 Then
If Data2.Recordset.Fields("orgId") <> "" Then
'赋值给mf1表格
If .Fields("OrgId") <> "" Then txtSupplier.Text = .Fields("OrgId")
If .Fields("fullName") <> "" Then supplierName.Text = .Fields("fullName")
gridCustomer.Visible = False
Else
MsgBox "没有数据可选择!", vbCritical, "提示"
gridCustomer.Visible = False 'gridCustomer不可见
End If
End If
End With
supplierName.SetFocus: supplierName.SelStart = 0: supplierName.SelLength = Len(supplierName.Text)
End Sub
Private Sub grid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '当按回车键时
With Data1.Recordset
If Data1.Recordset.RecordCount > 0 Then
If Data1.Recordset.Fields("barcode") <> "" Then
text1.Text = mf1.Text '赋值给text1
text1.SetFocus
mf1.Row = mf1.Row + 1: mf1.col = 1 '到达第5列
grid1.Visible = False
Else
MsgBox "没有数据供选择!", vbCritical, "提示"
grid1.Visible = False 'grid1不可见
text1.SetFocus
End If
End If
End With
text1.SetFocus 'text1获得焦点
End If
If KeyCode = vbKeyEscape Then '按ESC键
grid1.Visible = False 'grid1不可见
text1.SetFocus 'text1获得焦点
End If
End Sub
Private Sub gridCustomer_LostFocus()
gridCustomer.Visible = False
End Sub
Private Sub supplierName_Change()
'查询供应商信息
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 and ((hpos_organization.fullName like " + Chr(34) + supplierName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + supplierName.Text + "*" + Chr(34) + "))order by fullName"
Data2.Refresh
Dim rsMaster As Recordset
Set rsMaster = Data2.Recordset
If rsMaster.EOF Or supplierName.Text = "" Or IsNull(rsMaster) Then
gridCustomer.Visible = False
Else
gridCustomer.Visible = True
End If
End Sub
Private Sub supplierName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Then '按PageDown键
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=1 and ((hpos_organization.fullName like " + Chr(34) + supplierName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + supplierName.Text + "*" + Chr(34) + "))order by fullName"
Data2.Refresh
gridCustomer.Visible = True 'gridCustomer可见
gridCustomer.SetFocus 'gridCustomer获得焦点
End If
If KeyCode = vbKeyReturn Then '按回车键
handler.SetFocus 'jsr获得焦点
End If
End Sub
Private Sub handler_GotFocus()
gridCustomer.Visible = False 'gridCustomer不可见
End Sub
Private Sub handler_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '按回车键
billNo.SetFocus
End If
If KeyCode = vbKeyUp Then
'按向上键gys获得焦点
supplierName.SetFocus: supplierName.SelStart = 0: supplierName.SelLength = Len(supplierName.Text)
End If
End Sub
Private Sub mf1_entercell()
frm_main.text1.Text = "1"
' 当列处于条形码编号、净重、单价、轴重、件数及备注时允许编辑
If mf1.Row >= mf1.FixedRows And (mf1.col = 1 Or mf1.col = 6 Or mf1.col = 7 Or mf1.col = 9 Or mf1.col = 10 Or mf1.col = 12) Then
text1.Width = mf1.CellWidth
text1.Height = mf1.CellHeight
text1.Left = mf1.CellLeft + mf1.Left
text1.Top = mf1.CellTop + mf1.Top
text1.Text = mf1.Text
text1.Visible = True 'text1可见
text1.SetFocus
text1.Locked = False
Else
' text1.Visible = False
text1.Locked = True
End If
Call frm_main.entercell '调用函数
End Sub
Private Sub billNo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '按回车键
'到达第1行,第1列
mf1.Row = mf1.FixedRows
mf1.col = mf1.FixedCols
text1.Width = mf1.CellWidth
text1.Height = mf1.CellHeight
text1.Left = mf1.CellLeft + mf1.Left
text1.Top = mf1.CellTop + mf1.Top
text1.Text = mf1.Text 'mf1.TextMatrix(mf1.FixedRows, mf1.FixedCols)
text1.Visible = True
text1.Locked = False
text1.SetFocus
' mf1.SetFocus
End If
If KeyCode = vbKeyUp Then handler.SetFocus '按向上键gys获得焦点
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
frm_main.text1.Text = "1"
Dim strValid As String
strValid = "0123456789.-"
If KeyCode = vbKeyEscape And text1.Locked = False Then
text1.Text = "" 'mf1.TextMatrix(mf1.Row, mf1.col)
Exit Sub
End If
If KeyCode = vbKeyReturn Then
If mf1.col = 1 And Len(text1.Text) = g_barcode_length Then
Call fillDataFromBarcode
mf1.Row = mf1.Row - 1
mf1.col = 6
Exit Sub
End If
If (mf1.col = mf1.Cols - 2) And mf1.Row < mf1.Rows - 1 Then
mf1.Row = mf1.Row + 1
mf1.col = 1
Exit Sub
End If
If mf1.col = 6 Or mf1.col = 9 Then
mf1.col = mf1.col + 1
Exit Sub
End If
' 当处于价格列回车跳到轴重列
If mf1.col = 7 Then
mf1.col = 9
Exit Sub
End If
' 当处于价格列回车跳到轴重列
If mf1.col = 7 Then
mf1.col = 9
Exit Sub
End If
' 当处于件数列回车跳到备注列
If mf1.col = 10 Then
mf1.col = 12
Exit Sub
End If
End If
If mf1.col = 1 And Len(Trim(text1.Text)) = g_barcode_length Then
' 当输入数据长度为13位
If KeyCode = vbKeyDelete Then
' 删除某行数据
For i = mf1.FixedCols To mf1.Cols - mf1.FixedCols
mf1.TextMatrix(mf1.Row, i) = ""
Next i
Exit Sub
If mf1.Row > 1 Then
mf1.Row = mf1.Row - 1
End If
ElseIf Not (KeyCode = vbKeyUp Or KeyCode = vbKeyDown Or _
KeyCode = vbKeyLeft Or KeyCode = vbKeyRight Or KeyCode = vbKeyBack) Then
' 输入条形码长度为13位后按下字母或者数字键时换行并读取条码信息
Call fillDataFromBarcode
Exit Sub
End If
End If
If KeyCode = vbKeyUp Then
If mf1.Row > 1 Then mf1.Row = mf1.Row - 1
End If
If KeyCode = vbKeyDown Then
If mf1.Row < 29 Then mf1.Row = mf1.Row + 1
End If
' If KeyCode = vbKeyLeft Then Call frm_main.moveleft '调用函数
' If KeyCode = vbKeyRight Then Call frm_main.moveright '调用函数
End Sub
' 从条形码中获取物料及其重量信息填充界面表格
Private Sub fillDataFromBarcode()
' 隐藏grid1
grid1.Visible = False
If Not IsNumeric(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) Then
MsgBox "条码编号不规范,不能从中读取净重!", vbCritical, "警告"
text1.SetFocus
Exit Sub
End If
If checkData(6, "净重", 0) = False Then
Exit Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -