📄 form_outbill.frm
字号:
'赋值给mf1表格
If .Fields("OrgId") <> "" Then txttakeunit.Text = .Fields("OrgId")
If .Fields("fullName") <> "" Then takeunitName.Text = .Fields("fullName")
gridCustomer.Visible = False
Else
MsgBox "没有数据可选择!", vbCritical, "提示"
gridCustomer.Visible = False 'gridCustomer不可见
End If
End If
End With
' takeunitName.SetFocus: takeunitName.SelStart = 0: takeunitName.SelLength = Len(takeunitName.Text)
mf1GetFocus
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
' '赋值给mf1表格
text1.Text = mf1.Text '赋值给text1
text1.SetFocus
If (mf1.row = mf1.rows - mf1.FixedRows) Then
mf1.rows = mf1.rows + 1
mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = mf1.rows - mf1.FixedRows
End If
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 mf1_GotFocus()
If mf1.row >= mf1.FixedRows And (mf1.col = 1) Then
On Error Resume Next
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
End If
End Sub
Private Sub takeunitName_Change()
'查询客户信息
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=0 and ((hpos_organization.fullName like " + Chr(34) + takeunitName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + takeunitName.Text + "*" + Chr(34) + "))order by fullName"
Data2.Refresh
Dim rsMaster As Recordset
Set rsMaster = Data2.Recordset
' If rsMaster.EOF Or takeunitName.Text = "" Or IsNull(rsMaster) Or IsNull(rsMaster.Fields("fullName")) Or (takeunitName.Text = rsMaster.Fields("fullName") And Not isAdd) Then
If rsMaster.EOF Or takeunitName.Text = "" Or IsNull(rsMaster) Then
gridCustomer.Visible = False
Else
gridCustomer.Visible = True
End If
End Sub
Private Sub takeunitName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Then '按PageDown键
Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=0 and ((hpos_organization.fullName like " + Chr(34) + takeunitName.Text + "*" + Chr(34) + ")or (hpos_organization.shortenedform like " + Chr(34) + takeunitName.Text + "*" + Chr(34) + "))order by fullName"
Data2.Refresh
gridCustomer.Visible = True 'gridCustomer可见
gridCustomer.SetFocus 'gridCustomer获得焦点
End If
If KeyCode = vbKeyReturn Then '按回车键
' handler.SetFocus 'jsr获得焦点
mf1GetFocus
' gridCustomer.Visible = False 'gridCustomer不可见
End If
End Sub
Private Sub takeunitName_LostFocus()
' gridCustomer.Visible = False 'gridCustomer不可见
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获得焦点
takeunitName.SetFocus: takeunitName.SelStart = 0: takeunitName.SelLength = Len(takeunitName.Text)
End If
End Sub
Private Sub mf1_EnterCell()
frm_main.text1.Text = "4"
' 当列处于条形码编号、总净重、单价、皮重、件数及工号时允许编辑
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 '按回车键
mf1GetFocus
End If
If KeyCode = vbKeyUp Then handler.SetFocus '按向上键gys获得焦点
End Sub
Private Sub mf1GetFocus()
'到达第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 Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
If PreviousTab = 0 Then
If isAdd Or DataMaster.Recordset.RecordCount > 0 Then
EditData
Else
txttakeunit.Text = ""
txtBillId.Text = ""
takeunitName.Text = ""
handler.Text = ""
txtStockDataNo.Text = ""
Me.txtPrevBillNo.Text = ""
billDate.Text = CStr(Now)
clearData mf1
clearData msfgTtl
End If
Else
' cmdEdit.Enabled = False
isAdd = False
DataMaster.RecordSource = sqlMaster + sqlOrderBy
DataMaster.Refresh
DBGrid1.Refresh
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
frm_main.text1.Text = "4"
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 = 9
Exit Sub
End If
If (mf1.col = mf1.cols - 2) And mf1.row < mf1.rows - 1 Then
If (mf1.row = mf1.rows - mf1.FixedRows) Then
mf1.rows = mf1.rows + 1
mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = mf1.rows - mf1.FixedRows
End If
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 = 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 < mf1.rows - mf1.FixedRows Then mf1.row = mf1.row + 1
End If
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
' End If
Dim productCode As String
productCode = Mid(text1.Text, g_barcode_product_start, g_barcode_weight_start - g_barcode_product_start - g_barcode_sequenceno_len)
Dim netWeight As Double
netWeight = Val(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) / g_barcode_weight_base
' 产品编号取条形码中的3到7位
Data1.RecordSource = "select * from hpos_products where (hpos_products.productCode ='" + productCode + "')"
Data1.Refresh
With Data1.Recordset
If Data1.Recordset.RecordCount > 0 Then
If Data1.Recordset.Fields("productCode") <> "" Then
'赋值给mf1表格
If IsNumeric(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) Then
mf1.TextMatrix(mf1.row, 6) = Format(netWeight, g_barcode_weight_scale)
End If
If Not IsNull(.Fields("productName")) Then
mf1.TextMatrix(mf1.row, 2) = .Fields("productName")
End If
If Not IsNull(.Fields("productModel")) Then
mf1.TextMatrix(mf1.row, 3) = .Fields("productModel")
End If
If Not IsNull(.Fields("productSpecs")) Then
mf1.TextMatrix(mf1.row, 3) = mf1.TextMatrix(mf1.row, 3) + " || " + .Fields("productSpecs")
End If
If Not IsNull(.Fields("productStd")) Then
mf1.TextMatrix(mf1.row, 4) = .Fields("productStd")
End If
If Not IsNull(.Fields("productUnit")) Then
mf1.TextMatrix(mf1.row, 5) = .Fields("productUnit")
End If
If Not IsNull(.Fields("price")) Then
mf1.TextMatrix(mf1.row, 7) = .Fields("price")
End If
If IsNumeric(mf1.TextMatrix(mf1.row, 6)) And IsNumeric(mf1.TextMatrix(mf1.row, 7)) Then
mf1.TextMatrix(mf1.row, 8) = Val(mf1.TextMatrix(mf1.row, 7)) * Val(mf1.TextMatrix(mf1.row, 6))
mf1.TextMatrix(mf1.row, 8) = Format(mf1.TextMatrix(mf1.row, 8), g_barcode_weight_scale)
End If
If Trim(mf1.TextMatrix(mf1.row, 9)) = "" Then
mf1.TextMatrix(mf1.row, 9) = Val(mf1.TextMatrix(mf1.row, 7))
End If
If Trim(mf1.TextMatrix(mf1.row, 10)) = "" Then
mf1.TextMatrix(mf1.row, 10) = "1"
End If
mf1.TextMatrix(mf1.row, 11) = Val(mf1.TextMatrix(mf1.row, 9)) + Val(mf1.TextMatrix(mf1.row, 10)) * netWeight
mf1.TextMatrix(mf1.row, 9) = Format(mf1.TextMatrix(mf1.row, 9), g_barcode_weight_scale)
mf1.TextMatrix(mf1.row, 11) = Format(mf1.TextMatrix(mf1.row, 11), g_barcode_weight_scale)
If Not IsNull(.Fields("productId")) Then
mf1.TextMatrix(mf1.row, 13) = .Fields("productId")
End If
text1.Text = mf1.Text '赋值给text1
grid1.Visible = False
End If
Else
' MsgBox "无此商品编号!", vbCritical, "警告"
' grid1.Visible = False 'grid1不可见
' If mf1.row > 1 Then
'' mf1.Row = mf1.Row - 1
' text1.Visible = True
' text1.SetFocus
' text1.SelStart = 0
' text1.SelLength = Len(text1.Text)
' Exit Sub
' End If
End If
End With
fillTotalDataFromDtlData
Call frm_main.movereturn '调用函数
If (mf1.row = mf1.rows - mf1.FixedRows) Then
mf1.rows = mf1.rows + 1
' mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = mf1.rows - mf1.FixedRows
If g_CustomerSN > 1 And mf1.TextMatrix(mf1.row, 0) = "" And IsNumeric(mf1.TextMatrix(mf1.row - 1, 0)) Then
mf1.TextMatrix(mf1.row, 0) = CInt(mf1.TextMatrix(mf1.row - 1, 0)) + 1
End If
End If
mf1.row = mf1.row + 1: mf1.col = 1
End Sub
Private Sub text1_Change()
frm_main.text1.Text = "4"
gridCustomer.Visible = False
mf1.Text = text1.Text '赋值给mf1.text
text1.Visible = True
If mf1.col = 1 Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -