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

📄 form_outadd-bak.frm

📁 仓库扫描管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
     For i = 0 To msfgTtl.cols - 1
      msfgTtl.ColWidth(i) = s(i): msfgTtl.TextMatrix(0, i) = y(i)
     Next i
     msfgTtl.Rows = 101
     For i = msfgTtl.FixedRows To msfgTtl.Rows - msfgTtl.FixedRows
         msfgTtl.TextMatrix(i, 0) = i
     Next i
     
     billDate.Text = CStr(Now)     '设置出库日期
     Data1.RecordSource = "select * from hpos_products"
     Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=0 order by fullName"
End Sub
Private Sub Form_Unload(Cancel As Integer)
  frm_main.Enabled = True
End Sub

Private Sub gridCustomer_DblClick()
  selectCustomer
End Sub

Private Sub gridCustomer_GotFocus()
    text1.Visible = False
End Sub

Private Sub gridCustomer_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then     '当按回车键时
   selectCustomer
End If
If KeyCode = vbKeyEscape Then     '按ESC键
  gridCustomer.Visible = False     'gridCustomer不可见
End If
End Sub
Private Sub selectCustomer()
     With Data2.Recordset
     If Data2.Recordset.RecordCount > 0 Then
      If Data2.Recordset.Fields("orgId") <> "" Then
       '赋值给mf1表格
        If .Fields("OrgId") <> "" Then txttakeunit.Text = .Fields("OrgId")
        If .Fields("fullName") <> "" Then takeunitName.Text = .Fields("fullName")
       gridCustomer.Visible = False
     Else
       MsgBox "没有数据可选择!", vbCritical, "提示"
       gridCustomer.Visible = False     'gridCustomer不可见
      End If
     End If
     End With
    takeunitName.SetFocus: takeunitName.SelStart = 0: takeunitName.SelLength = Len(takeunitName.Text)
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
              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 "没有数据供选择!", 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
        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) 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获得焦点
 End If
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 = "3"
' 当列处于条形码编号、总净重、单价、轴重、件数及备注时允许编辑
    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     '按回车键
        '到达第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 If
    If KeyCode = vbKeyUp Then handler.SetFocus     '按向上键gys获得焦点
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  frm_main.text1.Text = "3"
    Dim StrMsg As String
    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
        StrMsg = fillDataFromBarcode()
'        If StrMsg = "" Then
'            mf1.col = 9
'        Else
'            MsgBox StrMsg, vbCritical, "警告"
'        End If
        Exit Sub
    End If
    If (mf1.col = mf1.cols - 2) 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位后按下字母或者数字键时换行并读取条码信息
            
            StrMsg = fillDataFromBarcode()
            If StrMsg = "" 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
            Else
                MsgBox StrMsg, vbCritical, "警告"
            End If
            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 Function fillDataFromBarcode() As String
' 隐藏grid1
      grid1.Visible = False
'      If Not IsNumeric(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) Then
'         text1.SetFocus
'         fillDataFromBarcode = "条码编号不规范,不能从中读取总净重!"
'         Exit Function
'      End If
'    If checkData(6, "总净重", 0) = False Then
'      Exit Function
'    End If
    ' 产品编号取条形码中的3到7位
    Dim productCode As String
    productCode = Mid(text1.Text, g_barcode_product_start, g_barcode_weight_start - g_barcode_product_start)
    Dim netWeight As Double
    netWeight = Val(Mid(text1.Text, g_barcode_weight_start, g_barcode_length - g_barcode_weight_start)) / g_barcode_weight_base
      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) = CDbl(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) = CDbl(mf1.TextMatrix(mf1.row, 9)) * CDbl(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
'            grid1.Visible = False     'grid1不可见
'           fillDataFromBarcode = "无此商品编号!"
'          If mf1.row > 1 Then
'    '        mf1.Row = mf1.Row - 1
'            text1.Visible = True
'            text1.SetFocus
'            text1.SelStart = 0
'            text1.SelLength = Len(text1.Text)
'            Exit Function
'          End If
         End If
        Dim pCode As String
        Dim qty As Double
        pCode = Mid(mf1.TextMatrix(mf1.row, 1), g_barcode_product_start, g_barcode_weight_start - g_barcode_product_start)
        qty = Val(mf1.TextMatrix(mf1.row, 6))
        If qty > getStockQty(pCode) Then
           mf1.col = 1
          fillDataFromBarcode = "出库数量(" + CStr(qty) + ")不能大于库存数量(" + CStr(getStockQty(pCode)) + ")!"
          Exit Function
        Else
             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
            End If
            mf1.row = mf1.row + 1: mf1.col = 1
        End If
     End With
End Function

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 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

⌨️ 快捷键说明

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