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

📄 form_outbill.frm

📁 仓库扫描管理系统
💻 FRM
📖 第 1 页 / 共 5 页
字号:
        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
    txtStockDataNo.Text = ""
    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
'    rsTmp.Close
    
   Dim strMsg As String
' 检验出库净重、件数、毛重是否超出库存 colArray 中的值分别为物料ID、物料编号、净重、件数、毛重的列号。
   strMsg = checkOutWeight(Me.msfgTtl, Array(10, 1, 6, 8, 9), billId)
   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 deleted As Boolean
    deleted = False
    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
            If isAdd = False And deleted = False Then
              Dim sql As String
              sql = " delete from hpos_StockOutBill_Dtl where billId=" + Chr(34) + txtBillId.Text + Chr(34)
              g_db.Execute sql
              sql = " delete from hpos_StockOutBill_Master where billId=" + Chr(34) + txtBillId.Text + Chr(34)
              g_db.Execute sql
              deleted = True
            End If
       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)
        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 txtStockDataNo.Text <> "" Then rsMaster.Fields("rsvFld3") = txtStockDataNo.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
    DataMaster.RecordSource = sqlMaster + sqlOrderBy
    DataMaster.Refresh
    DataMaster.Recordset.FindFirst (" hpos_StockOutBill_Master.billId='" + billId + "'")
    rsMaster.Close
    rs1.Close
    isAdd = False
    
    strMsg = strMsg + ""
    If strMsg <> "" Then
        strMsg = "保存成功,以下条码因为没有登记或者无效而没有保存。" + vbCrLf + "请记录以下条码让超级管理员登记之后在出库管理中补录。" + vbCrLf + vbCrLf + strMsg + vbCrLf
    Else
        strMsg = "保存成功!"
    End If
    MsgBox strMsg, vbInformation, "提示"
'    SSTab1.Tab = 0
'     '清空数据
'    clearData mf1
'     takeunitName.Text = "": handler.Text = ""
'     Me.txtPrevBillNo.Text = ""
'     billNo.Enabled = True: billNo.Text = ""
'     text1.Visible = False: gridCustomer.Visible = False     '设置控件不可见
'     enableControls (False)
End Sub
Private Sub Comqx_Click()      '取消操作
'     takeunitName.Text = "": handler.Text = ""
'     Me.txtPrevBillNo.Text = ""
'    clearData mf1
    takeunitName.Enabled = False: handler.Enabled = False
    enableControls (False)
     SSTab1.Tab = 0
    ' cmdEdit.Enabled = True
     If DataMaster.Recordset.EOF Then
        cmdEdit.Enabled = True
     End If
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

Private Sub clearData(msfg As MSFlexGrid)
'    For r = mf1.FixedRows To mf1.Rows - mf1.FixedRows
'        For c = mf1.FixedCols To mf1.Cols - mf1.FixedCols
'            mf1.TextMatrix(r, c) = ""
'        Next
'    Next
    For r = msfg.FixedRows To msfg.rows - msfg.FixedRows
        For c = msfg.FixedCols To msfg.cols - msfg.FixedCols
            msfg.TextMatrix(r, c) = ""
        Next
    Next
End Sub

Private Sub fillTotalDataFromDtlData()
    clearData msfgTtl
    Dim ttlQty As Double
    ttlQty = 0  '总件数
    For r = mf1.FixedRows To mf1.rows - mf1.FixedRows
        '  只对存在的物料进行总净重、皮重等的累加
        If mf1.TextMatrix(r, 13) <> "" Then
        ' 求总件数
            ttlQty = ttlQty + Val(mf1.TextMatrix(r, 10))
            For i = msfgTtl.FixedRows To msfgTtl.rows - msfgTtl.FixedRows
                If msfgTtl.TextMatrix(i, 10) = mf1.TextMatrix(r, 13) Then
                '对于存在的物料(productId相等)总净重、皮重等累加
                    msfgTtl.TextMatrix(i, 6) = Format(Val(msfgTtl.TextMatrix(i, 6)) + Val(mf1.TextMatrix(r, 6)) * Val(mf1.TextMatrix(r, 10)), g_barcode_weight_scale) '总净重
                    msfgTtl.TextMatrix(i, 7) = Format(Val(msfgTtl.TextMatrix(i, 7)) + Val(mf1.TextMatrix(r, 8)), g_barcode_weight_scale) '金额
                    msfgTtl.TextMatrix(i, 8) = Format(Val(msfgTtl.TextMatrix(i, 8)) + Val(mf1.TextMatrix(r, 10)), "#0")  '件数
                    msfgTtl.TextMatrix(i, 9) = Format(Val(msfgTtl.TextMatrix(i, 9)) + Val(mf1.TextMatrix(r, 11)), g_barcode_weight_scale)  '皮重
                    Exit For
                Else '对于没有的物料新增一行并填充数据
                    If msfgTtl.TextMatrix(i, 10) = "" Then
'                        msfgTtl.Rows = msfgTtl.Rows + 1
                        msfgTtl.TextMatrix(i, 1) = Mid(mf1.TextMatrix(r, 1), g_barcode_product_start, g_barcode_weight_start - g_barcode_product_start - g_barcode_sequenceno_len)
                        For col = 2 To 6
                            msfgTtl.TextMatrix(i, col) = mf1.TextMatrix(r, col)
                        Next
                        msfgTtl.TextMatrix(i, 6) = Format(Val(mf1.TextMatrix(r, 6)) * Val(mf1.TextMatrix(r, 10)), g_barcode_weight_scale) '总净重
                        msfgTtl.TextMatrix(i, 7) = Format(mf1.TextMatrix(r, 8), g_barcode_weight_scale) '金额
                        msfgTtl.TextMatrix(i, 8) = Format(mf1.TextMatrix(r, 10), "#0") '件数
                        msfgTtl.TextMatrix(i, 9) = Format(mf1.TextMatrix(r, 11), g_barcode_weight_scale) '皮重
                        msfgTtl.TextMatrix(i, 10) = mf1.TextMatrix(r, 13)  ' productId
                        Exit For
                    End If
                End If
            Next
        End If
    Next
    ' 设置界面总件数
    Me.lblTtlQty.Caption = Format(ttlQty, "#0")
End Sub
' 激活或者去活相关控件
Private Sub enableControls(flag As Boolean)
    takeunitName.Enabled = flag
    handler.Enabled = flag
    Me.txtStockDataNo.Enabled = flag
    billNo.Enabled = flag
' 网格
    text1.Enabled = flag
    mf1.Enabled = flag
    msfgTtl.Enabled = flag
' 按钮
    Combc.Enabled = flag
    Comqx.Enabled = flag
    cmdDeleteLine.Enabled = flag
    Comdj.Enabled = Not flag
'   增加的几个孔件
    Me.txtPrevBillNo.Enabled = flag
    Me.cmdPrevNo.Enabled = flag
End Sub

Private Sub previewData1()
    Dim excelSheet, sheet As New Excel.Worksheet
    If Me.SSTab1.Tab = 0 Then
        Me.SSTab1.Tab = 1
    End If
    If mf1.rows = mf1.FixedRows Then
        MsgBox "没有数据可打印,请先查询!", vbInformation, "提示"
        Exit Sub
    End If
    Dim dtlRow As Integer
    Dim colCount As Integer
    dtlRow = 3
    colCo

⌨️ 快捷键说明

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