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

📄 frmqsale.frm

📁 超市的管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
        MSFlexGrid1.CellFontBold = True
        
    Next intindex
    
    MSFlexGrid1.TextMatrix(0, 0) = "序号"
    
    MSFlexGrid1.TextMatrix(0, 1) = "商品编号"
    
    MSFlexGrid1.TextMatrix(0, 2) = "商品名称"
    
    MSFlexGrid1.TextMatrix(0, 3) = "单价/元"
    
    MSFlexGrid1.TextMatrix(0, 4) = "数量"
    
    MSFlexGrid1.TextMatrix(0, 5) = "总价/元"
    
    MSFlexGrid1.TextMatrix(0, 6) = "记录号"
    
End Sub

Private Sub CmdAdd_Click()
    
    frmSalesMOD.Show
    
    frmSalesMOD.Caption = "添加销售记录"                    '修改窗体名称
    
    With frmSalesMOD
    
    .TxtID.Text = ""                                        '窗体运行时,所有文本框为空
    
    .TxtName.Text = ""
    
    .TxtPrice.Text = ""
    
    .TxtAmount.Text = ""
    
    .TxtTotal.Text = ""
    
    .TxtPrice.Enabled = False                               '设置单价为只读
    
    .TxtID.Enabled = True                                   '修改商品编号文本框可用
    
    .TxtID.SetFocus
    
    End With


End Sub

Private Sub CmdClear_Click()

rct.MoveFirst

rct1.MoveFirst

Dim str1 As String

Dim str2 As String

    If MSFlexGrid1.TextMatrix(1, 0) <> "" Then

        If MsgBox("确实要清空该销售数据表吗?操作结果将被保存到数据库!", vbInformation + vbOKCancel, "操作警告!!") = vbOK Then
                    
            str1 = "delete from sales where salesinvoiceid=" & "'" & TxtID.Text & "'"
            
            QueryXFInfo (str1)
            
            str2 = "delete from salesinvoice where salesinvoiceid=" & "'" & TxtID.Text & "'"
            
            QueryXFInfo (str2)
            
            temp(HSC1.Value) = ""                                       '将当前销售单序号数组变量设置为空
            
            TxtID.Text = ""
        
            MSFlexGrid1.Clear
        
            Dim X As Integer
        
            For X = MSFlexGrid1.Rows - 1 To 2 Step -1                   '清空当前表格中记录
        
                MSFlexGrid1.RemoveItem (X)
        
            Next X
        
            Call flexView
            
            CmdAdd.Enabled = False                                      '清空后添加按纽和修改按纽不可用
            
            CmdModify.Enabled = False
            
            MsgBox "清空完毕并保存到数据库!", vbInformation + vbOKOnly, "操作提示!"
            
        Else
        
           Exit Sub
            
        End If
        
    Else
    
         MsgBox "无记录可以清空!", vbInformation + vbOKOnly, "删除提示!"
         
    End If

End Sub

Private Sub CmdDel_Click()

    Dim str1 As String
    
    Dim str2 As String
    
    Dim str3 As String

    Dim id As Integer
    
    Dim deltotal As String
    
    rct1.MoveFirst
    
    rct.MoveFirst
    
    deltotal = Val(MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5))
    
        If MSFlexGrid1.Rows > 3 Then                                                                '判断表格中是否存在有效记录

            If MSFlexGrid1.Row > 0 And MSFlexGrid1.Row < MSFlexGrid1.Rows - 2 Then                  '判断是否选中有效记录
            
                If MsgBox("确定要删除该记录吗?", vbInformation + vbOKCancel, "操作警告!") = vbOK Then
                
                str1 = "delete from sales  where saleid=" & "'" & MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6) & "'"
                        
                QueryXFInfo (str1)
                    
                    For id = MSFlexGrid1.Row To MSFlexGrid1.Rows - 3                                '依次将表格中所删记录后面的所有记录覆盖前一个记录,然后删除最后一个记录。
    
                        MSFlexGrid1.TextMatrix(id, 1) = MSFlexGrid1.TextMatrix(id + 1, 1)
    
                        MSFlexGrid1.TextMatrix(id, 2) = MSFlexGrid1.TextMatrix(id + 1, 2)
    
                        MSFlexGrid1.TextMatrix(id, 3) = MSFlexGrid1.TextMatrix(id + 1, 3)
    
                        MSFlexGrid1.TextMatrix(id, 4) = MSFlexGrid1.TextMatrix(id + 1, 4)
    
                        MSFlexGrid1.TextMatrix(id, 5) = MSFlexGrid1.TextMatrix(id + 1, 5)
                        
                        MSFlexGrid1.TextMatrix(id, 6) = MSFlexGrid1.TextMatrix(id + 1, 6)
    
                    Next id
    
                        MSFlexGrid1.RemoveItem (MSFlexGrid1.Rows - 3)
    
                        MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
                        
                        '在原来的总金额中减去删除记录的金额
    
                        MSFlexGrid1.Text = "销售日期为:" & DT(HSC1.Value) & "           金额总计为:" & (Val(total(HSC1.Value)) - Val(deltotal)) & "元"
    
                        total(HSC1.Value) = Val(total(HSC1.Value)) - Val(deltotal)
                        
                        MsgBox "已删除所选记录!", vbInformation + vbOKOnly, "删除成功!"
                     
                    If MSFlexGrid1.Rows = 3 Then
                    
                        '如果删除的是表格中最后一条记录,则把该销售单从销售单表中删除

                        str2 = "delete from salesinvoice where salesinvoiceid=" & "'" & TxtID.Text & "'"

                        QueryXFInfo (str2)
                    
                        TxtID.Text = ""
                    
                        MSFlexGrid1.RemoveItem (MSFlexGrid1.Rows - 1)
                    
                        MsgBox "该销售单的所有记录都已删除!", vbInformation, "删除提示!"
                        
                        CmdAdd.Enabled = False
            
                        CmdModify.Enabled = False
                        
                    Else
                    
                        '如果删除的不是表格中最后一条记录,则在相应的销售单记录中修改总金额
                    
                        Do While Not rct1.EOF

                        If rct1.Fields.Item(0).Value = TxtID.Text Then

                            str3 = "update salesinvoice set totalprices=" & "'" & total(HSC1.Value) & "'" & "where salesinvoiceid=" & "'" & TxtID.Text & "'"
                            
                            QueryXFInfo (str3)
                            
                           Exit Sub
                            
                        Else

                            rct1.MoveNext

                        End If

                        Loop
                        
                    End If
    
                Else
                
                    Exit Sub
                    
                End If

            Else

                MsgBox "无法删除,请点击要删除的记录!", vbInformation + vbOKOnly, "删除提示!"

                Exit Sub

            End If

        Else

            MsgBox "无记录可以删除!", vbInformation + vbOKOnly, "删除提示!"

        End If


End Sub

Private Sub CmdExit_Click()

    Unload Me

End Sub

Private Sub CmdINT_Click()

    If IsEmpty(rct) = False Then                    '判断查询表中是否有记录
        
        Exit Sub

    End If

    HSC1.Value = 0
    
    '初始化时,将数组变量的值清空

    ReDim temp(intindex)
    
    ReDim total(intindex)
    
    ReDim DT(intindex)
    
    intindex = 0
    
    CmdQuery.Enabled = True
    
    MSFlexGrid1.Clear

    Dim X As Integer

    For X = MSFlexGrid1.Rows - 1 To 2 Step -1

        MSFlexGrid1.RemoveItem (X)

    Next X

    Call flexView
    
    Combo2.Text = Combo2.List(0)
    
    OpNUM.Value = True
    
    HSC1.Enabled = False
    
    TxtID.Text = ""
    
    DTP1.Value = Date
    
    DTP2.Value = Date
    
    CmdClear.Enabled = False
    
    CmdDel.Enabled = False
    
    CmdModify.Enabled = False
    
    rct.MoveFirst
    
    rct1.MoveFirst
    

End Sub


Private Sub CmdModify_Click()

    If MSFlexGrid1.Row > 0 And MSFlexGrid1.Row < MSFlexGrid1.Rows - 2 Then      '判断是否选中有效记录
        
        frmSalesMOD.Show
        
    Else
    
        MsgBox "请选择要修改的记录!", vbInformation + vbOKOnly, "修改提示!"
        
        Exit Sub
        
    End If
    
    

End Sub

Private Sub CmdQuery_Click()

    If IsEmpty(rct) = False Then                                        '判断查询表中是否有记录

        Exit Sub

    End If

    intindex = 0

    If OpID.Value = True Then
    
        If TxtID.Text <> "" Then
    
            rct1.MoveFirst
        
            Do While Not rct1.EOF
            
                If rct1.Fields.Item(0).Value Like "*" & TxtID.Text & "*" Then           '找到符合查询条件的记录后
                
                    ReDim Preserve temp(intindex)                                       '将销售单序号值赋给temp数组变量
                
                    temp(intindex) = rct1.Fields.Item(0).Value
                    
                    ReDim Preserve total(intindex)                                      '将销售单序号值赋给total数组变量
                
                    total(intindex) = (rct1.Fields.Item(2).Value)
                    
                    ReDim Preserve DT(intindex)                                         '将销售单序号值赋给dt数组变量
                
                    DT(intindex) = rct1.Fields.Item(1).Value
                    
                    intindex = intindex + 1
                    
                    rct1.MoveNext
                    
                Else
                
                    rct1.MoveNext
                    
                End If
                
            Loop
            
                If intindex = 0 Then
            
                    MsgBox "无符合查询条件的销售记录表,请重新查询!", vbInformation + vbOKOnly, "查询提示!"
                    
                    Call CmdINT_Click
                    
                    Exit Sub
                    
                Else
                
                    MsgBox "共有" & intindex & "张符合查询条件的销售记录表!", vbInformation + vbOKOnly, "查询提示!"
                
                End If
                
            If intindex = 1 Then                        '当只查询到一张表时,水平滚动条不可用
            
               If viewRS(temp(0), total(0), DT(0)) = True Then
               
               End If
               
            Else
            
                HSC1.Enabled = True
            
                HSC1.Min = 0
                
                HSC1.Max = intindex - 1
                    
                If viewRS(temp(0), total(0), DT(0)) = True Then
                        
                End If
                    
            End If
            
        Else
        
            MsgBox "销售序号不能为空,请重输!", vbInformation + vbOKOnly, "查询提示!"
            
            Exit Sub
            
        End If
        
    ElseIf OpNUM.Value = True Then
    
        rct1.MoveFirst
            
        Do While Not rct1.EOF
            
            Select Case Combo2.Text
            
                Case "0--49.99"
                
                    If rct1.Fields.Item(2).Value > 0 And rct1.Fields.Item(2).Value <= 49.99 Then
                    
                        ReDim Preserve temp(intindex)
            
                        temp(intindex) = rct1.Fields.Item(0).Value
                        
                        ReDim Preserve total(intindex)
                    
                        total(intindex) = Val(rct1.Fields.Item(2).Value)
                        
                        ReDim Preserve DT(intindex)
                    
                        DT(intindex) = rct1.Fields.Item(1).Value
                        
                        intindex = intindex + 1
                        
                        rct1.MoveNext
                        
                    Else
            
                        rct1.MoveNext
                
                    End If
                        
                Case "50--99.99"
                
                    If rct1.Fields.Item(2).Value >= 50 And rct1.Fields.Item(2).Value <= 99.99 Then
                    
                        ReDim Preserve temp(intindex)
            
                        temp(intindex) = rct1.Fields.Item(0).Value
                        
                        ReDim Preserve total(intindex)
                    
                        total(intindex) = Val(rct1.Fields.Item(2).Value)
                        
                        ReDim Preserve DT(intindex)
                    
                        DT(intindex) = rct1.Fields.Item(1).Value
                        
                        intindex = intindex + 1
                        
                        rct1.MoveNext
                        
                    Else
            
                        rct1.MoveNext
                
                    End If
                        
                Case "100--499.99"
                
                    If rct1.Fields.Item(2).Value >= 100 And rct1.Fields.Item(2).Value <= 499.99 Then
                    
                        ReDim Preserve temp(intindex)
            
                        temp(intindex) = rct1.Fields.Item(0).Value
                        
                        ReDim Preserve total(intindex)
                    
                        total(intindex) = Val(rct1.Fields.Item(2).Value)
                        
                        ReDim Preserve DT(intindex)
                    
                        DT(intindex) = rct1.Fields.Item(1).Value
                        

⌨️ 快捷键说明

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