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

📄 form_outadd.frm

📁 仓库扫描管理系统
💻 FRM
📖 第 1 页 / 共 4 页
字号:
    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(Val(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) / g_barcode_weight_base, 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 + m_prevBillNo
    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
    '设置控件有效或无效
    enableControls (True)
    '清空数据
    txttakeunit.Text = ""
    txtBillId.Text = ""
    takeunitName.Text = ""
    handler.Text = g_userName
    Me.txtPrevBillNo.Text = ""
    billDate.Text = CStr(Now)
    text1.Text = ""
    clearData mf1
    clearData msfgTtl
    takeunitName.SetFocus
    billNo.Text = getNextBillNo("hpos_StockOutBill_Master", "billNo")
End Sub
Private Sub Combc_Click()
    If Me.chkSkinWeight.Value = 1 Then
        g_outputSkinWeight = True
    Else
        g_outputSkinWeight = False
    End If
     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
    billId = CStr(getNextPK("hpos_StockOutBill_Master", "billId")) 'billNo.Text
    txtBillId.Text = billId
     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")
    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
     
    If billNo.Text = "" Then
       MsgBox "单据编号不能为空!", vbCritical, "数据无效"
       billNo.SetFocus
       Exit Sub
    End If
    
'    Set rsTmp = g_db.OpenRecordset("select * from hpos_StockOutBill_Master where billType=" + CStr(m_billType) + " and billNo='" & billNo.Text & "'")
'    If rsTmp.RecordCount > 0 Then
'       MsgBox "单据编号已经存在,请输入其它!", vbCritical, "数据无效"
'       billNo.SetFocus
'       Exit Sub
'    End If
'    rsTmp.Close
   Dim strMsg As String
' 检验出库净重、件数、毛重是否超出库存 colArray 中的值分别为物料ID、物料编号、净重、件数、毛重的列号。
   strMsg = checkOutWeight(Me.msfgTtl, Array(10, 1, 6, 8, 9), "")
   If strMsg <> "" Then
     MsgBox strMsg, vbCritical, "数据无效"
     Exit Sub
   End If
    strMsg = Trim(checkbarcodesRepeated(mf1))
    If strMsg <> "" Then
        If MsgBox("红色显示部分条码重复,继续保存吗?", vbYesNo + vbQuestion + vbDefaultButton1, "提示") = vbNo Then
            Exit Sub
        End If
    End If
   strMsg = ""
    Dim productCode As String
     For i = mf1.FixedRows To mf1.rows - mf1.FixedRows
        productCode = Mid(mf1.TextMatrix(i, 1), g_barcode_product_start, g_barcode_weight_start - g_barcode_product_start - g_barcode_sequenceno_len)
       If mf1.TextMatrix(i, 13) <> "" And mf1.TextMatrix(i, 6) <> "" Then
           hasDtl = True
           rs1.AddNew
        
           If billNo.Text <> "" Then rs1.Fields("billId") = billId
           rs1.Fields("dtlId") = billId & "_" & i
           ' 产品ID
           If mf1.TextMatrix(i, 13) <> "" Then rs1.Fields("productId") = mf1.TextMatrix(i, 13)
           ' 条形码
           If mf1.TextMatrix(i, 1) <> "" Then rs1.Fields("barcode") = mf1.TextMatrix(i, 1)
           If mf1.TextMatrix(i, 6) <> "" Then rs1.Fields("qty") = mf1.TextMatrix(i, 6)
           If mf1.TextMatrix(i, 7) <> "" Then rs1.Fields("price") = mf1.TextMatrix(i, 7)
           If mf1.TextMatrix(i, 9) <> "" Then rs1.Fields("axesWeight") = mf1.TextMatrix(i, 9)
           If mf1.TextMatrix(i, 10) <> "" Then rs1.Fields("pieceQty") = mf1.TextMatrix(i, 10)
           If mf1.TextMatrix(i, 12) <> "" Then rs1.Fields("comment") = mf1.TextMatrix(i, 12)
            '  如果不是第一个客户的版本就要保存编号
            If (g_CustomerSN > 1) Then
                ' 用于打印的编号,删除中间某行之后该编号不变,就是新增时的序号,便于在入库单管理模块中打印;当在出入库管理模块中删除中间某行之后,部分编号与序号就不一致了。
                rs1.Fields("rsvFld1") = Me.mf1.TextMatrix(i, 0)     ' CStr(i)
            End If
           rs1.Update        '更新表
        ElseIf mf1.TextMatrix(i, 1) <> "" And mf1.TextMatrix(i, 13) = "" Then
            strMsg = strMsg + "第" + CStr(i) + "行条码(" + mf1.TextMatrix(i, 1) + ")中的物品(" + productCode + ")没有登记" + vbCrLf
        ElseIf mf1.TextMatrix(i, 1) <> "" And mf1.TextMatrix(i, 6) = "" Then
            strMsg = strMsg + "第" + CStr(i) + "行条码(" + mf1.TextMatrix(i, 1) + ")无效(不能从中读取净重)" + vbCrLf
        End If
     Next i
     If Not hasDtl Then
        MsgBox "没有数据可保存,请检查输入数据的有效性!", vbCritical, "警告"
        Exit Sub
     End If
     If hasDtl Then
        rsMaster.AddNew
    '   店铺(仓库)标识
        rsMaster.Fields("store") = g_store
        rsMaster.Fields("billType") = m_billType
    '   单据ID--主关键字
        If billNo.Text <> "" Then rsMaster.Fields("billId") = billId
        If takeunitName.Text <> "" Then rsMaster.Fields("takeunit") = txttakeunit.Text
        If handler.Text <> "" Then rsMaster.Fields("handler") = handler.Text
        If billDate.Text <> "" Then rsMaster.Fields("billDate") = CDate(billDate.Text) ' Now 'billDate.Text
        If billNo.Text <> "" Then rsMaster.Fields("billNo") = billNo.Text
        '   入库单号码
        If txtPrevBillNo.Text <> "" Then rsMaster.Fields("rsvFld1") = txtPrevBillNo.Text
        '   页码
        If txtPageNo.Text <> "" Then rsMaster.Fields("rsvFld2") = txtPageNo.Text
        rsMaster.Update
    End If
    rsMaster.Close
    rs1.Close
'    MsgBox "保存成功!", vbInformation, "提示"
    isAdd = False
    ' 预览数据
    strMsg = strMsg + ""
'    Dim ss As String
'    ss = "保存成功,需要打印预览吗?"
    If strMsg <> "" Then
        strMsg = "保存成功,以下条码因为没有登记或者无效而没有保存。" + vbCrLf + "请记录以下条码让超级管理员登记之后在出库管理中补录。" + vbCrLf + vbCrLf + strMsg + vbCrLf + vbCrLf + "需要打印预览吗?"
    Else
        strMsg = "保存成功,需要打印吗?"
    End If
    If MsgBox(strMsg, vbYesNo + vbQuestion + vbDefaultButton1, "提示") = vbYes Then
        printBill
    End If
     '清空数据
     clearData mf1
     clearData msfgTtl
     takeunitName.Text = "": handler.Text = ""
     Me.txtPrevBillNo.Text = ""
     billNo.Text = ""
     text1.Visible = False: gridCustomer.Visible = False     '设置控件不可见
     enableControls (False)
End Sub
'  打印(预览)单据
Private Sub printBill()
    '  标准版本
'    If g_CustomerSN = 0 Then
'        previewData0
'    End If
    '  第一个客户
    If g_CustomerSN = 1 Then
        previewData1
    End If
    '  第二个客户
    If g_CustomerSN = 2 Then
        previewData2
    End If
End Sub
Private Sub Comqx_Click()      '取消操作
    takeunitName.Text = "": handler.Text = ""
    Me.txtPrevBillNo.Text = ""
    clearData mf1
    clearData Me.msfgTtl
    enableControls (False)
End Sub
Private Sub Comend_Click()
  frm_main.Enabled = True
  Unload Me
End Sub
Private Sub text1_Validate(Cancel As Boolean)
  If Len(Trim(text1.Text)) = g_barcode_length And mf1.col = 1 Then
     Call fillDataFromBarcode
     mf1.row = mf1.row - 1
  ElseIf mf1.col = 1 And Trim(text1.Text) <> "" Then
    MsgBox "条形码长度必须为" & CStr(g_barcode_length) & "位", vbCritical, "警告"
    Cancel = True
  End If
End Sub

' 校验某列的数据输入是否有效;diffRow:0-表示当前行,-1表示上一行,1表示下一行。
Private Function checkData(col As Integer, colName As String, diffRow As Integer) As Boolean
  If mf1.row > mf1.FixedRows - 1 Then
    If Not Trim(mf1.TextMatrix(mf1.row, 1)) = "" And (mf1.col = col Or mf1.col = 1) And Not IsNumeric(Mid(Trim(mf1.TextMatrix(mf1.row, 1)), g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) Then
      MsgBox colName + "必须为数值!", vbCritical, "输入错误"
      If mf1.row > 1 Then
        mf1.row = mf1.row + diffRow
        text1.Visible = True
        text1.SetFocus
        text1.SelStart = 0
        text1.SelLength = Len(text1.Text)
        Exit Function
      End If
      checkData = False
    Else
      checkData = True
    End If
  End If
End Function

⌨️ 快捷键说明

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