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

📄 main_qtgl_ktgl_ktfw.frm

📁 根据餐饮行业的特点和该企业的实际情况
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   -210
      Top             =   5520
      Visible         =   0   'False
      Width           =   1845
      _ExtentX        =   3254
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   1
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=CYGLXT"
      OLEDBString     =   "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=CYGLXT"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "select * from 商品基础信息表"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "main_qtgl_ktgl_ktfw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs5 As New ADODB.Recordset
Dim rs6 As New ADODB.Recordset
Dim s, y, i   '定义变量
Dim lsph As Integer     '定义一个整型变量
Private Sub Form_Activate()
 '初始化设置
 Combo1.AddItem ("点单"): Combo1.AddItem ("赠单"): Combo1.ListIndex = 0
 Adodc1.RecordSource = "select * from 房间台号信息表 where 编号='" + Label4(0).Caption + "'order by 编号"
 Adodc1.Refresh
 For a = 0 To 5
  If Adodc1.Recordset.RecordCount > 0 Then
   Label4(a).Caption = Trim(Adodc1.Recordset.Fields(a))     '赋值给label4(a).caption
  End If
 Next a
 Label4(6).Caption = "营业"
 Label4(7).Caption = Trim(Adodc1.Recordset.Fields("容纳人数"))
End Sub
Private Sub Form_Load()
 MS1.Rows = 102: MS1.Cols = 9     '定义ms1表的总行数、总列数
 s = Array("450", "2400", "1200", "750", "900", "900", "1200", "900", "2100")
 y = Array("序号", "商品名称", "商品编号", "单位", "单价", "数量", "金额", "状态", "备注")
 For i = 0 To 8
  MS1.ColWidth(i) = s(i): MS1.TextMatrix(0, i) = y(i)
 Next i
 MS1.FixedRows = 1: MS1.FixedCols = 1     '设置固定行、列
 '定义MS1表的列序号
 For i = 1 To 101
   MS1.TextMatrix(i, 0) = i
 Next i
 Me.Caption = Me.Caption & "    " & frm_main.St1.Panels(3).text
End Sub
Private Sub Form_Unload(Cancel As Integer)
  main_qtgl_ktgl.Enabled = True
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyReturn Then
  MS1.text = Combo1.text
  Combo1.Visible = False
  MS1.Col = 8
  Text1.Visible = True
  Text1.SetFocus
 End If
End Sub
Private Sub grid1_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyReturn Then
   With Adodc2.Recordset
   If .RecordCount > 0 Then     '当记录大于零时
     If .Fields("本级名称") <> "" Then
        '赋值给MS1表格
        If .Fields("本级名称") <> "" Then MS1.TextMatrix(MS1.Row, 1) = Trim(.Fields("本级名称"))
        If .Fields("商品编号") <> "" Then MS1.TextMatrix(MS1.Row, 2) = Trim(.Fields("商品编号"))
        If .Fields("单位") <> "" Then MS1.TextMatrix(MS1.Row, 3) = Trim(.Fields("单位"))
        If .Fields("单价") <> "" Then MS1.TextMatrix(MS1.Row, 4) = .Fields("单价")
        Text1.text = MS1.text     '赋值给text1
        Text1.SetFocus
        MS1.Col = 5
        grid1.Visible = False
       Else
        MsgBox ("无数据选择!!!")
        grid1.Visible = False
        Text1.SetFocus
     End If
   End If
   End With
   Text1.SetFocus
  End If
  If KeyCode = vbKeyEscape Then    '按ESC键
   grid1.Visible = False     'grid1不可见
   Text1.SetFocus
  End If
End Sub
Private Sub MS1_Click()     '单击MS1表格
 If MS1.Row >= 1 And MS1.TextMatrix(MS1.Row - 1, 7) <> "" Then
  Text1.Visible = True
  Text1.SetFocus
 End If
End Sub
Private Sub MS1_entercell()
 frm_main.Text1.text = "2"
 Call frm_main.entercell     '调用函数
End Sub
Private Sub MS1_RowColChange()     '格式化MS1表的第4列、第6列
 For i = 1 To 101
  If MS1.TextMatrix(i, 1) <> "" Then
     MS1.TextMatrix(MS1.Row, 4) = Format(MS1.TextMatrix(MS1.Row, 4), "#0.00")
     MS1.TextMatrix(MS1.Row, 6) = Val(MS1.TextMatrix(MS1.Row, 4)) * Val(MS1.TextMatrix(MS1.Row, 5))
     MS1.TextMatrix(MS1.Row, 6) = Format(MS1.TextMatrix(MS1.Row, 6), "#0.00")
  End If
 Next i
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
 frm_main.Text1.text = "2"
 If KeyCode = vbKeyReturn Then
     If MS1.Col = 1 Then
        With Adodc2.Recordset
        If .RecordCount > 0 Then
          '赋值给MS1表格
           If .Fields("本级名称") <> "" Then MS1.TextMatrix(MS1.Row, 1) = Trim(.Fields("本级名称"))
           If .Fields("商品编号") <> "" Then MS1.TextMatrix(MS1.Row, 2) = Trim(.Fields("商品编号"))
           If .Fields("单位") <> "" Then MS1.TextMatrix(MS1.Row, 3) = Trim(.Fields("单位"))
           If .Fields("单价") <> "" Then MS1.TextMatrix(MS1.Row, 4) = .Fields("单价")
           Text1.SetFocus
           Text1.text = MS1.text     '赋值给text1.text
           grid1.Visible = False
           MS1.Col = 4
        End If
        End With
     End If
     Call frm_main.movereturn     '调用函数
  End If
  If KeyCode = vbKeyUp Then
     If MS1.Row > 1 Then MS1.Row = MS1.Row - 1
  End If
  If KeyCode = vbKeyDown Then
     If MS1.Row < 99 Then MS1.Row = MS1.Row + 1
  End If
  If KeyCode = vbKeyLeft Then Call frm_main.moveleft     '调用函数
  If KeyCode = vbKeyRight Then Call frm_main.moveright     '调用函数
  If KeyCode = vbKeyPageDown Then
     If MS1.Col = 1 Then
        Adodc2.RecordSource = "select * from 商品基础信息表 where 商品级别='3级'"
        Adodc2.Refresh
        If Adodc2.Recordset.RecordCount > 0 Then
           grid1.Visible = True
           grid1.SetFocus
        End If
     End If
  End If
End Sub
Private Sub Text1_Change()
  MS1.text = Text1.text     '赋值给MS1表格
  If MS1.Col = 1 Then
   If Text1.text = "" Then
    grid1.Visible = False
   Else
    '筛选商品名称或简称符合text1的记录
    Adodc2.RecordSource = "select * from 商品基础信息表 where (本级名称 like '" + Text1.text + "'+ '%')or(本级简称  like '" + Text1.text + "'+'%')and 商品基础信息表.商品级别='3级'"
    Adodc2.Refresh
    If Adodc2.Recordset.RecordCount > 0 Then
       grid1.Visible = True
       Text1.SetFocus
    End If
   End If
  End If
  If MS1.Col = 2 Then
   If MS1.TextMatrix(MS1.Row, 1) = "" Then
      MsgBox ("无商品名称,请重新输入!!!")
      MS1.Col = 1
   End If
  End If
  If MS1.Col = 4 Then MS1.TextMatrix(MS1.Row, 6) = Val(MS1.TextMatrix(MS1.Row, 4)) * Val(MS1.TextMatrix(MS1.Row, 5))
  If MS1.Col = 5 Then MS1.TextMatrix(MS1.Row, 6) = Val(MS1.TextMatrix(MS1.Row, 4)) * Val(MS1.TextMatrix(MS1.Row, 5))
  If MS1.Col = 7 Then
   Text1.Visible = False: Combo1.Visible = True
   Combo1.Width = MS1.CellWidth:
   Combo1.Left = MS1.CellLeft + MS1.Left: Combo1.Top = MS1.CellTop + MS1.Top
   Combo1.SetFocus
  End If
  If MS1.Col = 8 Then
   Text1.Visible = True: Combo1.Visible = False
  End If
  Dim a, B As Single
  For i = 1 To 101
      If MS1.TextMatrix(i, 1) <> "" And MS1.TextMatrix(i, 5) <> "" Then
      pz.text = i                                  '品种数
      a = Val(MS1.TextMatrix(i, 6)) + a    '求合计金额
      B = Val(MS1.TextMatrix(i, 5)) + B    '求合计数量
  End If
  Next i
  hjsl.text = B: hjje.text = Format(a, "0.00")
End Sub
Private Sub Comdj_Click()
  '确定文本框在MS1表格中的位置
  Text1.Width = MS1.CellWidth: Text1.Height = MS1.CellHeight
  Text1.Left = MS1.CellLeft + MS1.Left: Text1.Top = MS1.CellTop + MS1.Top
  MS1.Enabled = True
  '打开连接
  rs1.Open "select * from 单据号表 ", cnn, adOpenKeyset, adLockOptimistic
  '创建单据号
 If rs1.RecordCount = 0 Then
    djh.Caption = Date & "No." & "0001"
  Else
    lsph = Right(Trim(rs1.Fields("单据号")), 4) + 1
    djh.Caption = Date & "No." & Format(lsph, "0000")
  End If
  rs1.Close
  '设置控件有效或无效
  Combc.Enabled = True: Comqx.Enabled = True
  Comdj.Enabled = False: Text1.Visible = True
  Text1.SetFocus
  '清空数据
  For i = 1 To 100
  For j = 1 To 8
      MS1.TextMatrix(i, j) = ""
  Next j
  Next i
  pz.text = "0": hjsl.text = "0": hjje.text = "0"
  labrq.Caption = Now
End Sub
Private Sub Combc_Click()
 rs1.Open "select * from 单据号表 ", cnn, adOpenKeyset, adLockOptimistic
  If rs1.RecordCount > 0 Then
  If djh.Caption <> "" Then rs1.Fields("单据号") = Trim(djh.Caption)
  rs1.Update
 Else
  rs1.AddNew
  If djh.Caption <> "" Then rs1.Fields("单据号") = Trim(djh.Caption)
  rs1.Update
 End If
 rs1.Close
 If MS1.TextMatrix(1, 1) <> "" And MS1.TextMatrix(1, 5) <> "" Then
   For i = 1 To 100
    If MS1.TextMatrix(i, 1) <> "" And MS1.TextMatrix(i, 5) <> "" Then
     Set rs5 = New ADODB.Recordset
     '筛选符合商品编号的记录
     rs5.Open "select * from 库存信息表 where 商品编号='" & Trim(MS1.TextMatrix(i, 2)) & "'", cnn, adOpenKeyset, adLockOptimistic
     If rs5.RecordCount > 0 Then     '当记录大于零时
       If rs5.Fields("商品名称") <> "" Then
        '更新库存数量、库存金额
         rs5.Fields("库存数量") = rs5.Fields("库存数量") - Trim(Val(MS1.TextMatrix(i, 5)))
         rs5.Fields("库存金额") = Val(rs5.Fields("库存数量")) * Val(rs5.Fields("进价"))
         rs5.Update
       End If
     End If
     rs5.Close
     rs2.Open "select * from 点单临时表", cnn, adOpenKeyset, adLockOptimistic
    '添加新记录到"点单临时表"中
      rs2.AddNew
      If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("商品名称") = Trim(MS1.TextMatrix(i, 1))
      If MS1.TextMatrix(i, 2) <> "" Then rs2.Fields("商品编号") = Trim(MS1.TextMatrix(i, 2))
      If MS1.TextMatrix(i, 3) <> "" Then rs2.Fields("单位") = Trim(MS1.TextMatrix(i, 3))
      If MS1.TextMatrix(i, 4) <> "" Then rs2.Fields("单价") = Val(MS1.TextMatrix(i, 4))
      If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("数量") = Val(MS1.TextMatrix(i, 5))
      If MS1.TextMatrix(i, 6) <> "" Then rs2.Fields("金额") = Val(MS1.TextMatrix(i, 6))
      If MS1.TextMatrix(i, 7) <> "" Then rs2.Fields("状态") = Trim(MS1.TextMatrix(i, 7))
      If MS1.TextMatrix(i, 8) <> "" Then rs2.Fields("备注") = Trim(MS1.TextMatrix(i, 8))
      If Label4(0).Caption <> "" Then rs2.Fields("房台编号") = Label4(0).Caption
      If Label4(6).Caption <> "" Then rs2.Fields("房台类别") = Label4(2).Caption
      If labrq.Caption <> "" Then rs2.Fields("点单日期") = Trim(labrq.Caption)
      If Labbh.Caption <> "" Then rs2.Fields("服务员编号") = Labbh.Caption
      If Labxm.Caption <> "" Then rs2.Fields("服务员姓名") = Labxm.Caption
      If djh.Caption <> "" Then rs2.Fields("单据号") = Trim(djh.Caption)
      rs2.Fields("是否结帐") = "否"
      rs2.Update
      rs2.Close
      '更新"房间台号信息表"中
      rs6.Open "select * from 房间台号信息表 where 编号='" + Label4(0).Caption + "'", cnn, adOpenKeyset, adLockOptimistic
      If rs6.RecordCount > 0 Then
         rs6.Fields("状态") = "营业"
        '更新数据库
         rs6.Update
      End If
      rs6.Close
     End If
   Next i
 '设置控件有效或无效
   Combc.Enabled = False: Comdj.Enabled = True: Comqx.Enabled = False
   Text1.Visible = False: MS1.Enabled = False: grid1.Visible = False
   Call main_qtgl_ktgl.list_change     '调用函数
   main_qtgl_ktgl.Enabled = True
   Unload Me
  Else
   MsgBox ("填写数据不完整,请核对,再保存")
   MS1.Col = 1: SFlexGrid1.Row = 1
 End If
End Sub
Private Sub Comqx_Click()     '取消操作
 For i = 1 To 101
 For j = 1 To 8
     MS1.TextMatrix(i, j) = ""
 Next j
 Next i
 MS1.Enabled = False
 pz.text = "0": hjje.text = "0": hjsl.text = "0"
 main_qtgl_ktgl.Enabled = True
 Unload Me
End Sub


⌨️ 快捷键说明

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