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

📄 dlg_outbill.frm

📁 仓库扫描管理系统
💻 FRM
📖 第 1 页 / 共 5 页
字号:
    If (cmbField.Text = "客户全称") Then
      fldName = "hpos_organization.fullName"
    End If
    If (cmbField.Text = "单据编号") Then
      fldName = "hpos_StockOutBill_Master.billNo"
    End If
    Dim sql As String
    sql = sqlMaster & " and ( " + fldName + " like " + Chr(34) + "*" + txtConditon.Text + "*" + Chr(34) + ")"
    sql = sql + " and (hpos_StockOutBill_Master.billDate between " + Chr(35) + CStr(DTP1.Value) + " 00:00:00" + Chr(35) + " and " + Chr(35) + CStr(DTP2.Value) + " 23:59:59" + Chr(35) + ") "
    sql = sql + sqlOrderBy
    DataMaster.RecordSource = sql
    DataMaster.Refresh
    DBGrid1.Refresh
     If Not DataMaster.Recordset.EOF Then
        cmdEdit.Enabled = True
     End If
End Sub

Private Sub cmdEdit_Click()
  EditData
End Sub

Private Sub EditData()
    enableControls (True)
    clearMasterData
      Dim billId As String
      Dim rs As Recordset
    '  isAdd = False
      Set rs = DataMaster.Recordset
      If rs.EOF And Not isAdd Then
        MsgBox "没有数据了,请先登记!", vbInformation, "提示"
'        Comdj_Click
          Exit Sub
      End If
        takeunitName.Enabled = True: handler.Enabled = True
        text1.Enabled = True: mf1.Enabled = True: Combc.Enabled = True: Comqx.Enabled = True: Comdj.Enabled = True
        billNo.Enabled = True
      cmdEdit.Enabled = True

      If Not isAdd Then
        If Not IsNull(rs.Fields("billId")) Then txtBillId.Text = rs.Fields("billId")
        If Not IsNull(rs.Fields("billNo")) Then billNo.Text = rs.Fields("billNo")
        If Not IsNull(rs.Fields("takeunit")) Then txttakeunit.Text = rs.Fields("takeunit")
        If Not IsNull(rs.Fields("fullName")) Then takeunitName.Text = rs.Fields("fullName")
        If Not IsNull(rs.Fields("billDate")) Then billDate.Text = CStr(rs.Fields("billDate"))
        If Not IsNull(rs.Fields("handler")) Then handler.Text = rs.Fields("handler")
            '    续单号码
'        If Not IsNull(rs.Fields("rsvFld1")) Then Me.txtPrevBillNo.Text = rs.Fields("rsvFld1")
      End If
      SSTab1.Tab = 1

      Dim rsDtl As Recordset
      Dim sql As String
      strSQL = "select D.*,P.productCode,P.productName,P.productModel,P.productSpecs,P.productStd,P.productUnit from hpos_StockOutBill_dtl as D left join hpos_products as P on D.productId=P.productId "
'      Set rsDtl = g_db.OpenRecordset(strSQL + " where D.billId='" + txtBillId.Text + "' order by int(MID(D.dtlId,len(D.billId)+2,len(D.dtlId)-len(D.billId)-1))")
      Set rsDtl = g_db.OpenRecordset(strSQL + " where D.billId='" + txtBillId.Text + "' order by D.billId,CINT(D.rsvFld1) ")
      Dim i As Integer
      Dim qty, amount, pieceQty, axesWeight As Double
      i = 0
     mf1.rows = mf1.FixedRows + 1
      Do While Not rsDtl.EOF
          '  序号列显示编号
        If (g_CustomerSN > 1 And Not IsNull(rsDtl.Fields("rsvFld1"))) Then
            mf1.TextMatrix(i + 1, 0) = rsDtl.Fields("rsvFld1")
        End If
        If (i + 1 >= 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 IsNumeric(mf1.TextMatrix(mf1.rows - mf1.FixedRows - 1, 0)) Then
                mf1.TextMatrix(mf1.rows - mf1.FixedRows, 0) = CInt(mf1.TextMatrix(mf1.rows - mf1.FixedRows - 1, 0)) + 1
            End If
        End If
        If Not IsNull(rsDtl.Fields("barcode")) Then
          mf1.TextMatrix(i + 1, 1) = rsDtl.Fields("barcode")
        End If
        If Not IsNull(rsDtl.Fields("productName")) Then
          mf1.TextMatrix(i + 1, 2) = rsDtl.Fields("productName")
        End If
        If Not IsNull(rsDtl.Fields("productModel")) Then
          mf1.TextMatrix(i + 1, 3) = rsDtl.Fields("productModel")
        End If
        If Not IsNull(rsDtl.Fields("productSpecs")) Then
          mf1.TextMatrix(i + 1, 3) = mf1.TextMatrix(i + 1, 3) + " || " + rsDtl.Fields("productSpecs")
        End If
        If Not IsNull(rsDtl.Fields("productStd")) Then
          mf1.TextMatrix(i + 1, 4) = rsDtl.Fields("productStd")
        End If
        
        If Not IsNull(rsDtl.Fields("productUnit")) Then
          mf1.TextMatrix(i + 1, 5) = rsDtl.Fields("productUnit")
        End If
        If Not IsNull(rsDtl.Fields("qty")) Then
          mf1.TextMatrix(i + 1, 6) = rsDtl.Fields("qty")
          qty = qty + rsDtl.Fields("qty")
        End If
        If Not IsNull(rsDtl.Fields("price")) Then
          mf1.TextMatrix(i + 1, 7) = rsDtl.Fields("price")
        End If
        If IsNumeric(mf1.TextMatrix(i + 1, 6)) And IsNumeric(mf1.TextMatrix(i + 1, 7)) Then
            mf1.TextMatrix(i + 1, 8) = Val(mf1.TextMatrix(i + 1, 7)) * Val(mf1.TextMatrix(i + 1, 6))
            mf1.TextMatrix(i + 1, 8) = Format(mf1.TextMatrix(i + 1, 8), g_barcode_weight_scale)
            mf1.TextMatrix(i + 1, 6) = Format(mf1.TextMatrix(i + 1, 6), g_barcode_weight_scale)
            mf1.TextMatrix(i + 1, 7) = Format(mf1.TextMatrix(i + 1, 7), g_barcode_weight_scale)
        End If
        amount = amount + Val(mf1.TextMatrix(i + 1, 8))
       
        If Not IsNull(rsDtl.Fields("axesWeight")) Then
          mf1.TextMatrix(i + 1, 9) = rsDtl.Fields("axesWeight")
        End If
        If Not IsNull(rsDtl.Fields("pieceQty")) Then
          mf1.TextMatrix(i + 1, 10) = rsDtl.Fields("pieceQty")
        End If

        If IsNumeric(mf1.TextMatrix(i + 1, 9)) And IsNumeric(mf1.TextMatrix(i + 1, 10)) Then
            mf1.TextMatrix(i + 1, 11) = Val(mf1.TextMatrix(i + 1, 9)) + Val(mf1.TextMatrix(i + 1, 10)) * Val(mf1.TextMatrix(i + 1, 6))
            mf1.TextMatrix(i + 1, 11) = Format(mf1.TextMatrix(i + 1, 11), g_barcode_weight_scale)
            mf1.TextMatrix(i + 1, 9) = Format(mf1.TextMatrix(i + 1, 9), g_barcode_weight_scale)
'            mf1.TextMatrix(i + 1, 10) = Format(mf1.TextMatrix(i + 1, 10), g_barcode_weight_scale)
            axesWeight = axesWeight + Val(mf1.TextMatrix(i + 1, 11))
        End If
    
        If Not IsNull(rsDtl.Fields("comment")) Then
          mf1.TextMatrix(i + 1, 12) = rsDtl.Fields("comment")
        End If
        If Not IsNull(rsDtl.Fields("productId")) Then
          mf1.TextMatrix(i + 1, 13) = rsDtl.Fields("productId")
        End If
      rsDtl.MoveNext
      i = i + 1
    Loop
    For r = i + 1 To mf1.rows - mf1.FixedRows
        For c = mf1.FixedCols To mf1.cols - mf1.FixedCols
            mf1.TextMatrix(r, c) = ""
        Next
    Next
    '  计算累加数据
    Call fillTotalDataFromDtlData
    takeunitName.SetFocus: takeunitName.SelStart = 0: takeunitName.SelLength = Len(takeunitName.Text)
    gridCustomer.Visible = False
End Sub

Private Sub DBGrid1_DblClick()
  EditData
End Sub

Private Sub Form_Load()
    Me.WindowState = vbMaximized
    enableControls (False)
    hiddenButtons
    SSTab1.Tab = 0
    grid1IsVisible = False
    isAdd = False
    cmbField.AddItem "客户编号", 0
    cmbField.AddItem "客户全称", 1
    cmbField.AddItem "单据编号", 2
    cmbField.Text = "单据编号"
    '自动识别数据库路径
     Data1.DatabaseName = g_dbPath
     Data2.DatabaseName = g_dbPath
     DataMaster.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)     '设置出库日期
    'DTP1.Format = dtpCustom
    'DTP1.CustomFormat = "yyyy-MM-dd HH:mm:ss"  '"yyyy年MM月dd日 HH时mm分ss秒"
    'DTP1.Value = Now
     DTP2.Value = CStr(Date)
     
     Data1.RecordSource = "select * from hpos_products"
     Data2.RecordSource = "select fullName,orgId,orgCode,shortenedform from hpos_organization where orgType=0 order by fullName"
     sqlMaster = "SELECT hpos_StockOutBill_Master.*,hpos_organization.* FROM hpos_StockOutBill_Master LEFT JOIN hpos_organization ON hpos_organization.orgId = hpos_StockOutBill_Master.takeunit where billtype=" + CStr(m_billType)
     sqlOrderBy = " order by hpos_StockOutBill_Master.billDate desc "
     cmdQuery_Click
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_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
'   '赋值给mf1表格
   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) Or IsNull(rsMaster.Fields("fullName")) Or (takeunitName.Text = rsMaster.Fields("fullName") And Not isAdd) Then
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
'    gridCustomer.Visible = False     'gridCustomer不可见
 End If
End Sub


Private Sub takeunitName_LostFocus()
'  gridCustomer.Visible = False     'gridCustomer不可见
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)

⌨️ 快捷键说明

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