?? dlg_outbill.frm
字號:
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 '調用函數(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 = ""
' 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
' 產品編號取條形碼中的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 '調用函數(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()
gridCustomer.Visible = False
mf1.Text = text1.Text '賦值給mf1.text
text1.Visible = True
If mf1.col = 1 Then
If Len(Trim(text1.Text)) = g_barcode_length Then
' Call fillDataFromBarcode
Call fillTotalDataFromDtlData
End If
End If
' 總凈重和價格變化時更新金額
If mf1.col = 6 Or mf1.col = 7 Then
If text1.Text <> "" And Not IsNumeric(text1.Text) Then
MsgBox "總凈重/價格必須為數(shù)值!", vbCritical, "輸入錯誤"
text1.SetFocus
Exit Sub
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, 6)) * Val(mf1.TextMatrix(mf1.row, 7))
mf1.TextMatrix(mf1.row, 8) = Format(mf1.TextMatrix(mf1.row, 8), g_barcode_weight_scale)
End If
fillTotalDataFromDtlData
End If
' 皮重和件數(shù)變化時候更新總皮重
If mf1.col = 9 Or mf1.col = 10 Then
If text1.Text <> "" And Not IsNumeric(text1.Text) Then
MsgBox "件數(shù)/皮重必須為數(shù)值!", vbCritical, "輸入錯誤"
text1.SetFocus
Exit Sub
End If
If IsNumeric(mf1.TextMatrix(mf1.row, 9)) And IsNumeric(mf1.TextMatrix(mf1.row, 10)) Then
mf1.TextMatrix(mf1.row, 11) = Val(mf1.TextMatrix(mf1.row, 9)) + Val(mf1.TextMatrix(mf1.row, 10)) * Val(mf1.TextMatrix(mf1.row, 6))
mf1.TextMatrix(mf1.row, 11) = Format(mf1.TextMatrix(mf1.row, 11), g_barcode_weight_scale)
End If
fillTotalDataFromDtlData
End If
End Sub
Private Sub Comdj_Click()
isAdd = True
SSTab1.Tab = 1
'設置控件有效或無效
enableControls (True)
'清空數(shù)據(jù)
txttakeunit.Text = ""
txtBillId.Text = ""
takeunitName.Text = ""
handler.Text = g_userName
' Me.txtPrevBillNo.Text = ""
billDate.Text = CStr(Now)
clearData mf1
clearData msfgTtl
takeunitName.Enabled = True
takeunitName.SetFocus
billNo.Text = getNextBillNo("hpos_StockOutBill_Master", "billNo")
End Sub
Private Sub Combc_Click()
Set rs1 = g_db.OpenRecordset("hpos_StockOutBill_Dtl", dbOpenTable)
Set rsMaster = g_db.OpenRecordset("hpos_StockOutBill_Master", dbOpenTable)
Dim hasDtl As Boolean
Dim billId As String
hasDtl = False
If isAdd = True Then
billId = CStr(getNextPK("hpos_StockOutBill_Master", "billId")) 'billNo.Text
txtBillId.Text = billId
Else
billId = txtBillId.Text
End If
Dim rsTmp As Recordset
' Set rsTmp = g_db.OpenRecordset("select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=0 and orgId=" + txttakeunit.Text + " and ((fullName = " + "'" + takeunitName.Text + "" + "'" + ")or (shortenedform = " + "'" + takeunitName.Text + "" + "'" + ")) order by fullName")
' If rsTmp.EOF Then
' MsgBox "請選擇正確的客戶名稱!", vbCritical, "數(shù)據(jù)無效"
' takeunitName.SetFocus
' takeunitName.SelStart = 0
' takeunitName.SelLength = Len(takeunitName.Text)
' Exit Sub
' End If
Set rsTmp = g_db.OpenRecordset("select fullName,orgId,orgCode,shortenedform from hpos_organization " _
& "where orgType=0 and ((fullName = " + "'" + takeunitName.Text + "" + "'" + ")) order by fullName")
If rsTmp.EOF Then
MsgBox "無此客戶,請按【PageDown】鍵選擇!", vbCritical, "數(shù)據(jù)無效"
txttakeunit.Text = ""
takeunitName.Text = ""
takeunitName.SetFocus
takeunitName.SelStart = 0
takeunitName.SelLength = Len(takeunitName.Text)
Exit Sub
Else
txttakeunit.Text = rsTmp.Fields("orgId")
End If
'查詢庫存商品信息
' Data1.RecordSource = "SELECT * FROM KC"
' Data1.Refresh
If billNo.Text = "" Then
MsgBox "單據(jù)編號不能為空!", vbCritical, "數(shù)據(jù)無效"
Exit Sub
End If
'Dim rsTmp As Recordset
Set rsTmp = g_db.OpenRecordset("select * from hpos_StockOutBill_Master where billId<>'" + billId + "' and billType=" + CStr(m_billType) + " and billNo='" & billNo.Text & "'")
If rsTmp.RecordCount > 0 Then
MsgBox "單據(jù)編號已經存在,請輸入其它!", vbCritical, "數(shù)據(jù)無效"
billNo.SetFocus
Exit Sub
End If
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -