📄 mdimain.frm
字号:
Begin VB.Menu mnurepPR
Caption = "Prod&uct Report"
End
Begin VB.Menu mnurepSr
Caption = "Sales Rep&ort"
End
End
End
Attribute VB_Name = "mdiMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub c_Click()
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Password.Show
Me.Hide
Else
Exit Sub
End If
End Sub
Private Sub MDIForm_Load()
mnufile.Visible = False
mnurep.Visible = False
End Sub
Private Sub MDIForm_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu mnufile
End If
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
ans = MsgBox("Are you sure do you want to exit?", vbCritical + vbYesNo, "Exit?")
If ans = vbYes Then
End
Else
Cancel = Not Me
End If
End Sub
Private Sub mnucat_Click()
Category.Show
End Sub
Private Sub mnuexit_Click()
Unload Me
End Sub
Private Sub mnuprod_Click()
Products.Show
End Sub
Private Sub mnurepPR_Click()
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM Product", con, adOpenDynamic, adLockPessimistic
Set drpt1.DataSource = rs
Me.Toolbar1.Visible = False
drpt1.Title = "As of " & Format(Date, "mmmm dd, yyyy")
drpt1.Show
End Sub
Private Sub mnurepSr_Click()
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
With rs1
.Open "Select * from SalesRep", con, adOpenDynamic, adLockPessimistic
Do While Not .EOF
With rs2
.Open "Select * from [Temp] WHERE [Product Id] = '" & rs1.Fields("Product Id") & "'", con, adOpenDynamic, adLockPessimistic
If .EOF = True Then
con.BeginTrans
.AddNew
.Fields(0) = rs1.Fields("Product Id")
.Fields(1) = rs1.Fields!QtySold
.Fields(2) = rs1.Fields!TAmount
.Update
con.CommitTrans
Else
con.BeginTrans
.Fields!Totalamount = .Fields!Totalamount + rs1.Fields!TAmount
.Fields!QtySold = .Fields!QtySold + rs1.Fields!QtySold
.Update
con.CommitTrans
End If
.Close
Set rs2 = Nothing
End With
.MoveNext
Loop
.Close
Set rs1 = Nothing
End With
Dim rvd As New ADODB.Recordset
rvd.CursorLocation = adUseClient
rvd.Open "SELECT * FROM Sales_Report", con, adOpenDynamic, adLockPessimistic
Set drptDailySales.DataSource = rvd
drptDailySales.Title = "As of " & Format(Date, "mmmm dd, yyyy")
drptDailySales.Show
mdiMain.Toolbar1.Visible = False
If rs3.State = 1 Then Set rs3 = Nothing
rs3.Open "Delete * from Temp", con, adOpenDynamic, adLockPessimistic
End Sub
Private Sub mnusales_Click()
Sales.Show
sb1.Visible = False
End Sub
Private Sub mnuser_Click()
User.Show
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Dim rsSecurity As New ADODB.Recordset
Dim level As String
If rsSecurity.State = 1 Then Set rsSecurity = Nothing
rsSecurity.Open "SELECT * from [User] where [User Name] ='" & sb1.Panels(5).Text & "'", con, adOpenDynamic, adLockPessimistic
If Not rsSecurity.EOF Then
level = rsSecurity.Fields("User Level")
Else
Exit Sub
End If
Select Case Button.Index
Case 1:
Toolbar1.Visible = False
Me.Hide
Sales.Show
Case 4:
If level = "Cashier" Then
MsgBox "You are restricted in this module!", vbCritical, "Restricted"
Exit Sub
Else
User.Show
End If
Case 6:
Call c_Click
Case 7:
Unload Me
Case 8:
AboutMe.Show
End Select
End Sub
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
Dim rsSecurity As New ADODB.Recordset
Dim level As String
If rsSecurity.State = 1 Then Set rsSecurity = Nothing
rsSecurity.Open "SELECT * from [User] where [User Name] ='" & sb1.Panels(5).Text & "'", con, adOpenDynamic, adLockPessimistic
level = rsSecurity.Fields("User Level")
Select Case ButtonMenu.Key
Case "keyprod"
If level = "Cashier" Then
MsgBox "You are restricted in this module!", vbCritical, "Restricted"
Exit Sub
Else
Products.Show
End If
Case "keycat"
If level = "Cashier" Then
MsgBox "You are restricted in this module!", vbCritical, "Restricted"
Exit Sub
Else
Category.Show
End If
Case "keysales"
Call mnurepSr_Click
Case "keyprods"
Call mnurepPR_Click
End Select
End Sub
Function prodReport()
Dim rs As New ADODB.Recordset
Dim TQty As String
If rs.State = 1 Then Set rs = Nothing
rs.Open "select * from Product", _
con, adOpenKeyset, adLockPessimistic
TQty = rs.Fields!Quantity
With drptProduct
Set .DataSource = Nothing
.DataMember = ""
Set .DataSource = rs.DataSource
With .Sections("Section1").Controls
For i = 1 To .Count
If TypeOf .Item(i) Is RptTextBox Then
.Item(i).DataMember = ""
.Item(i).DataField = rs.Fields(i - 1).Name
End If
Next i
End With
.Show
mdiMain.Toolbar1.Visible = False
End With
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -