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

📄 frmsell.frm

📁 Visual basic 数据库编程技术与实例源码 源码
💻 FRM
📖 第 1 页 / 共 4 页
字号:
    txtQuantitySold.TabStop = True
    txtWord.SetFocus
    txtWord = ""
'ErrorDetail:
    Call MacButton("   Tag/Return Items", frmSelling.cmdDetail, 0, 0, 170, 30, frmLogin.Source, 147, 0, 2)
End Sub

Private Sub cmdDetail_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Tag/Return Items", frmSelling.cmdDetail, 0, 0, 170, 30, frmLogin.Source, 182, 30, 2)
End Sub

Private Sub cmdDetail_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Tag/Return Items", frmSelling.cmdDetail, 0, 0, 170, 30, frmLogin.Source, 147, 0, 2)
End Sub

Private Sub cmdEdit_Click()
'    On Error GoTo ErrorEdit
    EditMode = True
    Press_Button ("EDIT")
    datPrimaryRS.Recordset.Edit
'ErrorEdit:
'    Call MessageBox("frmSelling", Err.Description, 0)
End Sub

Private Sub cmdEdit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("    Edit", frmSelling.cmdEdit, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdEdit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("    Edit", frmSelling.cmdEdit, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Private Sub cmdFind_Click()
'    On Error GoTo ErrorFind
    EditMode = True
    Call FindBox(" Find by Invoice Number ", _
                    "INVOICE", "INVOICE_NO", 0, 1, "frmLogin")
    Call MacButton("   Find", frmSelling.cmdFind, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
'ErrorFind:
'    Call MessageBox("frmSelling", Err.Description, 0)
End Sub

Public Sub FindInvoiceNo()
'    On Error GoTo ErrorFindInvoiceNo
    datPrimaryRS.Recordset.FindFirst "INVOICE_NO >= '" & frmFind.txtWord & "'"
'ErrorFindInvoiceNo:
'    Call MessageBox("frmSelling", Err.Description, 0)
End Sub


Private Sub cmdFind_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Find", frmSelling.cmdFind, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdFind_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Find", frmSelling.cmdFind, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Private Sub cmdLast_Click()
    On Error Resume Next
    Press_Button ("LAST")
End Sub

Private Sub cmdLast_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("q", frmSelling.cmdLast, 0, 0, 100, 50, frmLogin.Source, 112, 39, 3)
End Sub

Private Sub cmdLast_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("q", frmSelling.cmdLast, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
End Sub

Private Sub cmdNext_Click()
    On Error Resume Next
    Press_Button ("NEXT")
End Sub

Private Sub cmdNext_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("u", frmSelling.cmdNext, 0, 0, 100, 49, frmLogin.Source, 112, 39, 3)
End Sub

Private Sub cmdNext_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("u", frmSelling.cmdNext, 0, 0, 100, 49, frmLogin.Source, 138, 39, 3)
End Sub

Private Sub cmdPrev_Click()
    On Error Resume Next
    Press_Button ("PREV")
End Sub

Private Sub cmdPrev_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("t", frmSelling.cmdPrev, 0, 0, 100, 50, frmLogin.Source, 112, 39, 3)
End Sub

Private Sub cmdPrev_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("t", frmSelling.cmdPrev, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
End Sub

Private Sub cmdPrint_Click()
'    On Error GoTo ErrorPrint
    If txtPaid = "" Then
        Call MessageBox("frmSelling", "Cannot print if not yet paid..", 0)
    Else
        Call frmSelling.PrintInvoice
    End If
    Call MacButton("   Print", frmSelling.cmdPrint, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
'ErrorPrint:
End Sub

Private Sub cmdPrint_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Print", frmSelling.cmdPrint, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdPrint_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Print", frmSelling.cmdPrint, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Private Sub cmdHelp_Click()
'    On Error GoTo ErrorHelp
    Call MacButton("   Help", frmSelling.cmdHelp, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
'ErrorHelp:
'    Call MessageBox("frmSelling", Err.Description, 0)
End Sub

Private Sub cmdHelp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Help", frmSelling.cmdHelp, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdHelp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Help", frmSelling.cmdHelp, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub



Private Sub cmdTag_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("    Tag", frmSelling.cmdTag, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Function Valid_Fields() As Boolean
    On Error Resume Next
    Dim r_val As Boolean
    r_val = True
    If txtField(0) = "" Then
        Call MessageBox("frmSelling", "Invoice Number required.", 0)
        frmMessageBox.SetFocus
        r_val = False
    End If
    If txtProductCode = "" Then
        r_val = False
        Call MessageBox("frmSelling", "Product Number required.", 0)
        frmMessageBox.SetFocus
    End If
    If txtQuantitySold = "" Then
        r_val = False
    End If
    If CDbl(txtAvailableStock) < CDbl(txtQuantitySold) Then
        Call MessageBox("frmSelling", "Quantity Sold must be less than available product.", 0)
        frmMessageBox.SetFocus
        txtQuantitySold.SetFocus
        r_val = False
    End If
    Valid_Fields = r_val
End Function

Private Sub cmdReturn_Click()
    On Error Resume Next
    Call Update_Stocks(txtProductCode, True, txtQuantitySold)
    Delete_Detail
    txtAvailableStock = Convert_Numeric(CDbl(txtAvailableStock) + CDbl(txtQuantitySold), False)
    txtTotalCost = Convert_Numeric(CDbl(txtUnitCost) * CDbl(txtAvailableStock), True)
    'Set invoice = frmLogin.db.OpenRecordset("select * from INVOICE_DETAIL where INVOICE_NOD = '" & txtField(0) & "'")
    Set invoice = New adodb.Recordset
    invoice.Open "select * from INVOICE_DETAIL where INVOICE_NOD = '" & txtField(0) & "'", myDB, 1, 3

    datSecondaryRS.Refresh
    txtTotal = dspTotal
    Call MacButton("  Return", frmSelling.cmdReturn, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Private Sub cmdReturn_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("  Return", frmSelling.cmdReturn, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdReturn_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("  Return", frmSelling.cmdReturn, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub

Private Sub Delete_Detail()
    On Error Resume Next
    strs = "select * from INVOICE_DETAIL where PRODCODE = '" & txtProductCode & "'"
    
    'Set dummy = frmLogin.db.OpenRecordset(strs)
    Set dummy = New adodb.Recordset
    dummy.Open strs, myDB, 1, 3

    
    If Not dummy.BOF Then
        With dummy
            
            .Fields("QTYSOLD") = .Fields("QTYSOLD") - txtQuantitySold
            .Update
            If .Fields("QTYSOLD") < 1 Then
                .Delete
                .MoveFirst
            End If
        End With
    End If
End Sub

Private Sub cmdTop_Click()
    On Error Resume Next
    Press_Button ("TOP")
End Sub

Private Sub cmdTop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("p", frmSelling.cmdTop, 0, 0, 100, 50, frmLogin.Source, 112, 39, 3)
End Sub

Private Sub cmdTop_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("p", frmSelling.cmdTop, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
End Sub

Private Sub cmdTotal_Click()
    txtPaid.SetFocus
    Call MacButton("     Total-Payment", frmSelling.cmdTotal, 0, 0, 170, 30, frmLogin.Source, 147, 0, 2)
End Sub

Private Sub cmdTotal_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("     Total-Payment", frmSelling.cmdTotal, 0, 0, 170, 30, frmLogin.Source, 182, 30, 2)
End Sub

Private Sub cmdTotal_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("     Total-Payment", frmSelling.cmdTotal, 0, 0, 170, 30, frmLogin.Source, 147, 0, 2)
End Sub

Private Sub cmdUndo_Click()
'    On Error GoTo ErrorUndo
    If EditMode = True Then
        Call MacButton("    Edit", frmSelling.cmdEdit, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
    Else
        Call MacButton("   New", frmSelling.cmdAdd, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
    End If
    Press_Button ("UNDO")
    Call MacButton("   Undo", frmSelling.cmdUndo, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
'ErrorUndo:
End Sub

Private Sub cmdUndo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Undo", frmSelling.cmdUndo, 0, 0, 73, 50, frmLogin.Source, 74, 0, 1)
End Sub

Private Sub cmdUndo_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Call MacButton("   Undo", frmSelling.cmdUndo, 0, 0, 73, 50, frmLogin.Source, 0, 0, 1)
End Sub
'
Private Sub Form_Activate()
    On Error Resume Next
    Enable_Buttons
    Enable_Buttons
    
   '进入前台售货系统的时候
   txtWord.SetFocus
End Sub

Private Sub Form_Load()
    On Error Resume Next
    Call ColForm(BoxContainer, 217, 211, 213, 125)
    Call ColForm(CounterContainer, 217, 211, 213, 125)
    Call ColForm(DetailsContainer, 217, 211, 213, 125)
    Call CreateMacOSTitleBar(titleBar, " 前台销售 ")
    Call BitBlt(frmSelling.Closed.hDC, 0, 0, 73, 50, frmLogin.Source.hDC, 0, 107, SRCCOPY)
    frmMain.Closed.Refresh
    Call BitBlt(frmSelling.Maximized.hDC, 0, 0, 73, 50, frmLogin.Source.hDC, 0, 72, SRCCOPY)
    frmMain.Maximized.Refresh
    Call BitBlt(frmSelling.Minimized.hDC, 0, 0, 73, 50, frmLogin.Source.hDC, 0, 124, SRCCOPY)
    frmMain.Minimized.Refresh
    Call MacButton("p", frmSelling.cmdTop, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
    Call MacButton("u", frmSelling.cmdNext, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
    Call MacButton("t", frmSelling.cmdPrev, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
    Call MacButton("q", frmSelling.cmdLast, 0, 0, 100, 50, frmLogin.Source, 138, 39, 3)
    KeyPreview = True
    
    Set invoice = New adodb.Recordset
    invoice.Open "select * from INVOICE_DETAIL where INVOICE_NOD = '" & txtField(0) & "'", myDB, 1, 3

    Set datprimary2 = New adodb.Recordset
    datprimary2.Open "select * from SETUP order by COMPANY_NAME", myDB, 1, 3

    
    
    
    
    p_isadding = False
    p_isadding = False
    p_isediting = False
    Enable_Fields (True)
    frmSelling.txtWord.SelLength = Len(frmSelling.txtWord.Text)
    
    
    With ListView1
        .ColumnHeaders.Add , , "编号"
        .ColumnHeaders.Add , , "名称"
        .ColumnHeaders.Add , , "数量"
        .ColumnHeaders.Add , , "单价"
        
    End With
    
    '初始化商品数量
    txtSellNum.Text = "1"
    
    Set SellRs = myDB.Execute("select count(*) from invoice")
    InvoiceNum = SellRs(0).Value + 1
    txtField(0).Text = CStr(InvoiceNum)
    DTPick.Value = Today
    TotalMoney = 0
    
    
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    On Error Resume Next
    Dim AltDown
    AltDown = (Shift And vbAltMask) > 0
    Select Case KeyCode
        Case vbKeyEscape:
                Unload Me
    End Select
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    On Error Resume Next
    Dim AltDown
    AltDown = (Shift And vbAltMask) > 0
    Select Case KeyCode
        Case vbKeyEscape:
                Unload Me
        Case vbKeyF1:
                frmHelp.Show
                frmHelp.Help_Values = Space(1) & vbCrLf & _
                                      "Note: The following are Key Shortcuts." & vbCrLf & _
                                      Space(1) & vbCrLf & _
                                      "ALT-N=New, ALT-E=Edit, ALT-S=Save, ALT-U=Undo, ALT-D=Delete" & vbCrLf & _
                                      "ALT-F=Find, ALT-X=Exit, ALT-P=Print" & vbCrLf & _
                                      "ALT-I=Tag/Return Items, ALT-Y=Total-Payment, " & vbCrLf & _
                                      Space(1) & vbCrLf & _
                                      "Left Arrow=Previous Records, Right Arrow=Next Records" & vbCrLf & _
                                      "Top Arrow=Top Record, Down Arrow=Last Record" & vbCrLf & _
                                      Space(1) & vbCrLf & _
                                      "Tag/Return Item Selection Key Shortcuts." & vbCrLf & _
                                      "ALT-T=Tag, ALT-R=Return, ALT-C=Close"

    End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Screen.MousePointer = vbDefault
End Sub

Private Sub Enable_Fields(p As Boolean)
    txtField(0).Locked = p
End Sub

Public Sub Press_Button(p_type As String)
    On Error Resume Next
    Select Case p_type
            Case "TOP"
                p_save = False
                p_isadding = False
                p_isediting = False
                datPrimaryRS.Recordset.MoveFirst
            Case "PREV"

⌨️ 快捷键说明

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