form_outadd.frm

来自「仓库扫描管理系统」· FRM 代码 · 共 1,486 行 · 第 1/4 页

FRM
1,486
字号
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   2280
      TabIndex        =   21
      Top             =   8040
      Width           =   735
   End
   Begin VB.Label lblTtlQtyCaption 
      BackColor       =   &H00C0FFFF&
      Caption         =   "总件数:"
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   1440
      TabIndex        =   20
      Top             =   8160
      Width           =   735
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "出  库 单"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   5115
      TabIndex        =   18
      Top             =   0
      Width           =   1395
   End
   Begin VB.Label Label6 
      BackColor       =   &H00C0FFFF&
      Caption         =   "累计净重毛重"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   1200
      Left            =   615
      TabIndex        =   17
      Top             =   6480
      Width           =   255
   End
End
Attribute VB_Name = "form_outAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim s, y, i     '定义变量
Dim mydb As Database     '定义数据库
Dim rs1 As Recordset     '定义字段
Dim rs2 As Recordset
Dim rsMaster As Recordset
Dim lsph As Integer     '定义一个整型变量
Dim isAdd As Boolean    '是否新增
Dim grid1IsVisible As Boolean
Dim m_billType As Integer
'   续单的最大箱号
Dim m_prevBillNo As Integer

Private Sub cmdCHeck_Click()
  Dim strMsg As String
  strMsg = checkbarcodesRepeated(mf1)
  If strMsg <> "" Then
    MsgBox "红色显示部分条码重复!", vbCritical, "警告"
  End If
End Sub

Private Sub cmdDeleteLine_Click()
    For i = mf1.FixedCols To mf1.cols - mf1.FixedCols
      mf1.TextMatrix(mf1.row, i) = ""
    Next i
    text1.Text = ""
    Call fillTotalDataFromDtlData
    If mf1.row > 1 Then
        mf1.row = mf1.row - 1
    End If
    Exit Sub
End Sub

Private Sub cmdImport_Click()
    Dim filePath As String
    filePath = ""
    
   filePath = "C:\盘点机目录\ck.txt"
   If Dir(filePath) = "" Then
     MsgBox "对不起,找不到文件【" + filePath + "】", vbInformation, "提示"
     Exit Sub
   End If
    If MsgBox("真的要导入文件" + vbCrLf + "【" + filePath + "】的数据嘛?", vbYesNo + vbQuestion + vbDefaultButton1, "提示") = vbNo Then
        Exit Sub
    End If
'   将文本文件中的数据导入到数据库中
   If importDataFromFile(filePath, "CK") = True Then
    MsgBox "导入成功,请修改客户等信息!", vbInformation, "提示"
    Unload Me
    Load form_outBill
    form_outBill.Show
    frm_main.Enabled = False
   Else
    MsgBox "对不起,导入失败!", vbInformation, "提示"
   End If
End Sub

Private Sub cmdOutNo_Click()
        Load dlg_outBill
        dlg_outBill.Show vbModal, Me
        m_prevBillNo = 0
        m_prevBillNo = getPrevBillMaxBoxNo(Me.txtOutNo.Text, False)
'        Me.txtOutNo.Text = ""
        setGridSequence Me.mf1, m_prevBillNo + 1, 0
End Sub

Private Sub cmdPrevNo_Click()
'        If Me.txtOutNo.Text = "" Then
'            MsgBox "请先选择要续号的出库单!", vbInformation, "提示"
'            Exit Sub
'        End If
        Load dlg_incomeBill
        dlg_incomeBill.Show vbModal, Me
'   重新设置箱号
        If Me.txtOutNo.Text <> "" Then
            setGridSequence Me.mf1, m_prevBillNo + 1, 0
        End If
        fillTotalDataFromDtlData
        Me.mf1.row = mf1.rows - 1
        Me.mf1.SetFocus
End Sub


Private Sub Form_Load()
'    Me.cmdImport.Visible = False
    grid1IsVisible = False
    m_prevBillNo = 0
    isAdd = True
     enableControls (False)
    '自动识别数据库路径
     Data1.DatabaseName = g_dbPath
     Data2.DatabaseName = g_dbPath
     m_billType = 0
     mf1.rows = 2: mf1.cols = 14     '定义mf1表的总行数、总列数
    '定义mf1表的列宽和表头信息
     s = Array("500", "1300", "1200", "1300", "1100", "450", "1000", "0", "0", "1000", "500", "1000", "1300", 0)
     y = Array("序号", "条  码  号", "物料名称", "型号||规格", " 标 准", "单位", "净重", "价格", "金额", "总皮重", "件/箱", "毛重", "工号", "productId")
     For i = 0 To mf1.cols - 1
      mf1.ColWidth(i) = s(i): mf1.TextMatrix(0, i) = y(i)
     Next i
     mf1.FixedRows = 1: mf1.FixedCols = 1     '定义mf1表的固定行数、固定列数
     '定义mf1表的列序号
     For i = mf1.FixedRows To mf1.rows - mf1.FixedRows
         mf1.TextMatrix(i, 0) = i
     Next i
     mf1.AllowUserResizing = flexResizeColumns

    '定义msfgTtl表的列宽和表头信息
     msfgTtl.rows = 2: msfgTtl.cols = 11     '定义msfgTtl表的总行数、总列数
     msfgTtl.FixedRows = 1: msfgTtl.FixedCols = 1     '定义mf1表的固定行数、固定列数
     s = Array("500", "900", "1400", "1300", "1100", "700", "1000", "0", "600", "1000", 0)
     y = Array("序号", "物料编号", "物料名称", "型号||规格", " 标 准", "单位", "总净重", "金额", "总件数", "总毛重", "productId")
     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)
    mf1GetFocus
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 + m_prevBillNo
            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
        On Error Resume Next
        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获得焦点
    mf1GetFocus
 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     '按回车键
        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 Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  frm_main.text1.Text = "3"
    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) 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 + m_prevBillNo
        End If
        mf1.row = mf1.row + 1
        mf1.col = 1
        Exit Sub
    End If

⌨️ 快捷键说明

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