⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlg_outbill.frm

📁 仓库扫描管理系统
💻 FRM
📖 第 1 页 / 共 5 页
字号:
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 = ""
'        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()
    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 "总净重/价格必须为数值!", 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
    '  皮重和件数变化时候更新总皮重
    If mf1.col = 9 Or mf1.col = 10 Then
        If text1.Text <> "" And Not IsNumeric(text1.Text) Then
            MsgBox "件数/皮重必须为数值!", 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)
    '清空数据
    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, "数据无效"
'       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, "数据无效"
        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 "单据编号不能为空!", vbCritical, "数据无效"
       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 "单据编号已经存在,请输入其它!", vbCritical, "数据无效"
       billNo.SetFocus
       Exit Sub
    End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -