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

📄 frmqueryorder.frm

📁 用vb写的饮食管理系统功能全面
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmQueryOrder 
   Caption         =   "消费明细表"
   ClientHeight    =   6255
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8880
   Icon            =   "frmQueryOrder.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MDIChild        =   -1  'True
   ScaleHeight     =   6255
   ScaleWidth      =   8880
   WindowState     =   2  'Maximized
   Begin VB.PictureBox Picture1 
      Height          =   540
      Left            =   30
      ScaleHeight     =   480
      ScaleWidth      =   11505
      TabIndex        =   3
      Top             =   2925
      Width           =   11565
      Begin VB.CommandButton cmdPrinter 
         Caption         =   "打印(&P)"
         Height          =   435
         Left            =   8385
         TabIndex        =   1
         Top             =   -15
         Width           =   1110
      End
      Begin VB.CommandButton cmdClose 
         Cancel          =   -1  'True
         Caption         =   "关闭(&C)"
         Height          =   435
         Left            =   10215
         TabIndex        =   2
         Top             =   15
         Width           =   1110
      End
   End
   Begin MSFlexGridLib.MSFlexGrid Grid1 
      Height          =   2430
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   3885
      _ExtentX        =   6853
      _ExtentY        =   4286
      _Version        =   393216
      Rows            =   3
      RowHeightMin    =   50
      BackColorSel    =   14737632
      ForeColorSel    =   12582912
      BackColorBkg    =   12632256
      WordWrap        =   -1  'True
      AllowBigSelection=   0   'False
      FocusRect       =   0
      SelectionMode   =   1
      AllowUserResizing=   1
   End
   Begin VB.Menu MnuStoreDisplay 
      Caption         =   "事务(&T)"
      Begin VB.Menu MnuStorePrint 
         Caption         =   "打印(&P) ..."
         Shortcut        =   ^P
      End
      Begin VB.Menu Line02 
         Caption         =   "-"
      End
      Begin VB.Menu MnuReturn 
         Caption         =   "返回首页(&R)"
      End
   End
   Begin VB.Menu MnuClose 
      Caption         =   "返回首页(&R)"
   End
End
Attribute VB_Name = "frmQueryOrder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub cmdClose_Click()

  Unload Me
  
End Sub

Private Sub cmdPrinter_Click()

  Me.MousePointer = 11
     frmSellPrint.Show 1
  Me.MousePointer = 0
  
End Sub

Private Sub cmdSearch_Click()

  Screen.MousePointer = 11
    Load frmMainSearch
    frmMainSearch.cmbBranchName.Enabled = False
    frmMainSearch.cmbBranchName.BackColor = &H8000000F
  Screen.MousePointer = 0
    frmMainSearch.Show 1
    
    '继续工作
    Call QuerySell(optBranch.Value, optStyle.Value, MnuDisplayStoreMerge.Checked)
    
End Sub


Private Sub Form_Load()

    Screen.MousePointer = 11
    
     DCondStr = ""
     
     '给出当前行的ID
     SCondStr = " ID=" & Val(frmCustomerOrder.Grid1.TextMatrix(frmCustomerOrder.Grid1.Row, 0))
     
     QueryStr = "Select * From SellList"
    Call QuerySell(True, False, True)

    Screen.MousePointer = 0
End Sub

Private Sub Form_Resize()

    Dim sngButtonTop As Single
    Dim sngScaleWidth As Single
    Dim sngScaleHeight As Single

    'On Error GoTo Form_Resize_Error
    With Me
        sngScaleWidth = .ScaleWidth
        sngScaleHeight = .ScaleHeight

        ' 移动“关闭”按钮到右下角
        With .Picture1
              sngButtonTop = sngScaleHeight - (.Height + MARGIN_SIZE)
              .Move MARGIN_SIZE, sngButtonTop, sngScaleWidth - (2 * MARGIN_SIZE), .Height
        End With
        
        With .cmdClose
              .Move Picture1.ScaleWidth - 10 - .Width, 30
        End With
        With .cmdPrinter
              .Move Picture1.ScaleWidth - 10 - .Width - cmdClose.Width - 40, 30
        End With
        
        .Grid1.Move MARGIN_SIZE, _
            MARGIN_SIZE, _
            sngScaleWidth - (2 * MARGIN_SIZE), _
            sngButtonTop - (2 * MARGIN_SIZE)

    End With
    Exit Sub

Form_Resize_Error:
    ' 避免负值错误
    Resume Next

End Sub

Private Sub QuerySell(CBranch As Boolean, CStyle As Boolean, CMerge As Boolean)

   Me.MousePointer = 11
   Dim DB As Database, EF As Recordset, HH As Integer
   Dim MargeRowBN As String, x As Integer, tmpBNX As String, ZF As String
   Dim MargeRow As String, tmpBN As String
   
    '配置网格

    Dim StoreQueryString As String
    
    Select Case SCondStr
           Case ""
               StoreQueryString = QueryStr
           Case Is <> ""
               StoreQueryString = QueryStr + " Where " & SCondStr
    End Select
    
    If CBranch = True Then
       StoreQueryString = StoreQueryString + " Order by MenuType"
       Else
       StoreQueryString = StoreQueryString + " Order by 日期"
    End If
    
Grid1.Visible = False
Grid1.Clear
Grid1.Cols = 9
Grid1.FormatString = "^ .. |^ 物品类别 |^ 物品名称 |^ 单位 |^ 物品代码 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期 "
Grid1.ColWidth(0) = 800
Grid1.ColWidth(1) = 1500
Grid1.ColWidth(2) = 2200
Grid1.ColWidth(3) = 1000
Grid1.ColWidth(4) = 1400
Grid1.ColWidth(5) = 1200
Grid1.ColWidth(6) = 800
Grid1.ColWidth(7) = 1400
Grid1.ColWidth(8) = 1300

  'On Error Resume Next
  
  Set DB = OpenDatabase(ConData, False, False, Constr)
    Set EF = DB.OpenRecordset("SellList", dbOpenTable)
        '增加一个合计
        Grid1.Rows = EF.RecordCount + 3
        
        If Grid1.Rows < 29 Then
           Grid1.Rows = 29
        End If

    Set EF = DB.OpenRecordset(StoreQueryString, dbOpenDynaset)
        HH = 1
        Do While Not EF.EOF()
           Grid1.Row = HH
           Grid1.Col = 0
           Grid1.CellAlignment = 4
        If Not IsNull(EF.Fields(0).Value) Then
           Grid1.Text = EF.Fields(0).Value
        End If
           Grid1.Row = HH
           Grid1.Col = 1
           Grid1.CellAlignment = 4
        If Not IsNull(EF.Fields(1).Value) Then '"^ .. |^ 物品类别 |^ 物品名称 |^ 单位 |^ 物品代码 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期 "
           Grid1.Text = EF.Fields(1).Value
         If CBranch = True Then
          If Trim(Grid1.Text) <> MargeRowBN Then
             tmpBN = Trim(Grid1.Text)
                If CMerge = False Then
                   Grid1.MergeCells = 0
                   Grid1.MergeCol(1) = False
                   Grid1.MergeRow(HH - 1) = False
                   Grid1.MergeRow(HH) = False
                End If
                For x = 1 To 8
                  Grid1.Col = x
                  If CMerge = False Then
                     Grid1.CellBackColor = &H80C0FF
                  Else
                     Grid1.CellBackColor = RGB(0, 0, 0)
                  End If
                Next
          ElseIf CMerge = True Then
              Grid1.MergeCells = 3
              Grid1.MergeCol(1) = True
              Grid1.MergeRow(HH - 1) = True
              Grid1.MergeRow(HH) = True
           Else
              Grid1.MergeCells = 0
              Grid1.MergeCol(1) = False
              Grid1.MergeRow(HH - 1) = False
              Grid1.MergeRow(HH) = False
          End If
              MargeRowBN = tmpBN
          Else
              Grid1.MergeCol(1) = False
         End If
        End If
           Grid1.Col = 2
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(3).Value) Then
           Grid1.Text = EF.Fields(3).Value '"^ .. |^ 物品类别 |^ 物品名称 |^ 单位 |^ 物品代码 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期 "
        End If
           Grid1.Col = 3
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(5).Value) Then
           Grid1.Text = EF.Fields(5).Value
        End If
           Grid1.Col = 4
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(2).Value) Then
           Grid1.Text = EF.Fields(2).Value '"^ .. |^ 物品类别 |^ 物品名称 |^ 单位 |^ 物品代码 |^ 单价 |^ 数量 |^ 金额 |^ 购物日期 "
        End If
           Grid1.Col = 5
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(4).Value) Then
           Grid1.Text = Format(EF.Fields(4).Value, "Currency")
        End If
           Grid1.Col = 6
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(6).Value) Then
           Grid1.Text = EF.Fields(6).Value
        End If
           Grid1.Col = 7
           Grid1.CellAlignment = 1
        If Not IsNull(EF.Fields(7).Value) Then
           Grid1.Text = EF.Fields(7).Value
        End If
           Grid1.Col = 8
           Grid1.CellAlignment = 4
        If Not IsNull(EF.Fields(8).Value) Then
           Grid1.Text = EF.Fields(8).Value
            If CStyle = True Then
              If Trim(Grid1.Text) <> MargeRow Then
                 tmpBN = Trim(Grid1.Text)
                 If CMerge = False Then
                   Grid1.MergeCells = 0
                   Grid1.MergeCol(8) = False
                   Grid1.MergeRow(HH - 1) = False
                   Grid1.MergeRow(HH) = False
                End If
                For x = 1 To 8
                    Grid1.Col = x
                 If CMerge = False Then
                    Grid1.CellBackColor = &H80C0FF
                 Else
                    Grid1.CellBackColor = RGB(0, 0, 0)
                 End If
                Next
            ElseIf CMerge = True Then
              Grid1.MergeCells = 3
              Grid1.MergeCol(8) = True
              Grid1.MergeRow(HH - 1) = True
              Grid1.MergeRow(HH) = True
              Else
              Grid1.MergeCells = flexMergeRestrictAll
           End If
              MargeRow = tmpBN
          Else
              Grid1.MergeCol(8) = False
         End If
        End If

          EF.MoveNext
          HH = HH + 1
        Loop
        EF.Close
        DB.Close
           Grid1.Row = HH + 1
        For x = 1 To 8
            Grid1.Col = x
            Grid1.CellForeColor = RGB(255, 0, 0)
        Next
        '定义合计
        Dim SumQTY As Long
            Grid1.Col = 7
        For x = 1 To HH - 1
            Grid1.Row = x
            SumQTY = SumQTY + Val(Grid1.Text)
        Next
            Grid1.Col = 2
            Grid1.Row = HH + 1
            Grid1.CellAlignment = 1
            Grid1.CellFontBold = True
            Grid1.CellFontSize = 10
            Grid1.Text = "--合  计--"
            Grid1.Col = 6
            Grid1.CellAlignment = 1
            Grid1.CellFontBold = True
            Grid1.CellFontSize = 10
            Grid1.Text = SumQTY
            SumQTY = 0
            Grid1.Col = 6   '合计第六行
        For x = 1 To HH - 1
            Grid1.Row = x
            SumQTY = SumQTY + Val(Grid1.Text)
        Next
            Grid1.Col = 6  '写入
            Grid1.Row = HH + 1
            Grid1.CellAlignment = 1
            Grid1.CellFontBold = True
            Grid1.CellFontSize = 10
            Grid1.Text = SumQTY
            SumQTY = 0
            Grid1.Col = 7  '合计第七行
        For x = 1 To HH - 1
            Grid1.Row = x
            SumQTY = SumQTY + Val(Grid1.Text)
        Next
            Grid1.Col = 7  '写入
            Grid1.Row = HH + 1
            Grid1.CellAlignment = 1
            Grid1.CellFontBold = True
            Grid1.CellFontSize = 10
            Grid1.Text = Format(SumQTY, "Currency")
            
        '定义合计结束
        
 Grid1.Col = 1
 Grid1.Row = 20
 Grid1.ColSel = 8
 Grid1.Visible = True
 Me.MousePointer = 0
 
End Sub



Private Sub Form_Unload(Cancel As Integer)
    
  Set frmQueryOrder = Nothing
 
  SCondStr = ""
  
End Sub

Private Sub Grid1_DblClick()

  PopupMenu MnuStoreDisplay
  
End Sub

Private Sub Grid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

  If Button = 2 Then
     PopupMenu MnuStoreDisplay
  End If
  
End Sub

Private Sub MnuClose_Click()

  MnuReturn_Click
  
End Sub

Private Sub MnuReturn_Click()
 
 Unload Me
 
End Sub


Private Sub MnuStorePrint_Click()

  cmdPrinter.Value = True
  
End Sub


⌨️ 快捷键说明

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