?? 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 "沒有數(shù)據(jù)可選擇!", 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 "沒有數(shù)據(jù)供選擇!", 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"
' 當列處于條形碼編號、總凈重、單價、皮重、件數(shù)及工號時允許編輯
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 '調(diào)用函數(shù)
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
' 當處于件數(shù)列回車跳到工號列
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
' 當輸入數(shù)據(jù)長度為13位
If KeyCode = vbKeyDelete Then
' 刪除某行數(shù)據(jù)
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位后按下字母或者數(shù)字鍵時換行并讀取條碼信息
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 "條碼編號不規(guī)范,不能從中讀取總凈重!", 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
' 產(chǎn)品編號取條形碼中的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 '調(diào)用函數(shù)
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 + -