purchase_form.frm

来自「很好一套库存管理」· FRM 代码 · 共 1,560 行 · 第 1/4 页

FRM
1,560
字号
    
    End If
    RS_AVA_PU_STOCK.Close
End Sub

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If Len(Combo1.Text) > 0 Then
If KeyCode = 13 Then
    SendKeys "{TAB}"
    SendKeys "{TAB}"
End If
End If
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
'KeyAscii = 0
End Sub

Private Sub Combo2_Click()
Refresh_combobox (1)
End Sub

Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
If Len(Combo2.Text) > 0 Then
    If KeyCode = 13 Then
        SendKeys "{TAB}"
        SendKeys "{TAB}"
    End If
End If

End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
'KeyAscii = 0

End Sub

Private Sub Combo3_KeyDown(KeyCode As Integer, Shift As Integer)
If Len(Combo3.Text) > 0 Then
        If KeyCode = 13 Then
            SendKeys "{TAB}"
            SendKeys "{TAB}"
        End If
End If
End Sub

Private Sub DataGrid1_Click()
Call FILLTEXT
End Sub

Private Sub DataGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
    If cmd_op(0).Enabled = False Then
        Dim x As Integer
        x = MsgBox("Are you sure you want to Cancel updates ...", vbQuestion Or vbYesNo, "Want to cancel ?")
        If x = 6 Then
                Call cmd_op_Click(4)
        End If
        
    Exit Sub
    End If
    
    Dim y As Integer
    y = MsgBox("Are you Sure you want to Cancel Purchase Bill?", vbQuestion Or vbYesNo, "Want to Cancel Purchase Invoice ?")
    If y = 6 Then
            Unload Me
    End If

ElseIf KeyCode = 116 Then
    Call cmd_update_Click
End If

End Sub

Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
    SendKeys "{TAB}"
End If

End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 27 Then
    If cmd_op(0).Enabled = False Then
        x = MsgBox("Are you sure you want to Cancel updates ...", vbQuestion Or vbYesNo, "Want to cancel ?")
        If x = 6 Then
                Call cmd_op_Click(4)
        End If
        Exit Sub
    End If
    
    Dim y As Integer
    y = MsgBox("Are you Sure you want to Cancel Purchase Bill?", vbQuestion Or vbYesNo, "Want to Cancel Purchase Invoice ?")
    If y = 6 Then
            Unload Me
    End If

ElseIf KeyCode = 116 Then
    Call cmd_update_Click
End If

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 23 Then
        Text1(0).Text = "WithoutBill_" & Now
End If
End Sub

Private Sub Form_Load()

DTPicker1.Value = Date

Dim DEL_RS As New ADODB.Recordset
DEL_RS.Open "SELECT * FROM SYS_CURRENT_INVOICE", db, adOpenDynamic, adLockOptimistic

While DEL_RS.EOF <> True
    DEL_RS.Delete
    DEL_RS.MoveNext
Wend

DEL_RS.Close
KeyPreview = True
PADD = False

Me.Left = 0
Me.Top = 0

pur_rs.Open "select * from Purchase_master", db, adOpenDynamic, adLockOptimistic
item_rs.Open "select * from item_master", db, adOpenDynamic, adLockOptimistic
item_type.Open "select * from ItemType", db, adOpenDynamic, adLockOptimistic
rs_cur_invoice_item.CursorLocation = adUseClient
rs_cur_invoice_item.Open "select * from SYS_CURRENT_INVOICE", db, adOpenDynamic, adLockOptimistic
rs_cur_record_count.Open "select count(*) from SYS_CURRENT_INVOICE", db, adOpenDynamic, adLockOptimistic
pname.Open "select * from purchase_partynames", db, adOpenDynamic, adLockOptimistic

Combo3.Clear
While pname.EOF <> True
    
    Combo3.AddItem pname.Fields(0).Value
    pname.MoveNext
Wend


Set DataGrid1.DataSource = rs_cur_invoice_item
Call Refresh_combobox(2)

Call ENABLE_DISABLE(False)
opbutton_status (True)
A1:

End Sub

Private Sub Form_Unload(Cancel As Integer)
If cmd_op(0).Enabled = False Then
        Call cmd_op_Click(4)
End If


If PADD = True Then
    Dim R As New ADODB.Recordset
        R.Open "SELECT * FROM purchase_partynames WHERE purchase_partyname='" & Combo3.Text & "'", db, adOpenDynamic, adLockOptimistic
    R.Delete
    R.Close
End If

pur_rs.Close
item_rs.Close
item_type.Close
pname.Close

rs_cur_record_count.Requery
If rs_cur_record_count.Fields(0).Value > 0 Then
    rs_cur_invoice_item.Requery
    While rs_cur_invoice_item.EOF <> True
        rs_cur_invoice_item.Delete
        rs_cur_invoice_item.MoveNext
    Wend
    
End If

If Status = True Then
rs_cur_invoice_item.CancelBatch
rs_cur_invoice_item.CancelUpdate
End If

rs_cur_invoice_item.Close
rs_cur_record_count.Close
End Sub

Private Sub LaVolpeButton1_Click()
'Combo1.Text = Clear
Refresh_combobox (1)


If Len(Combo2.Text) <> 0 Then
    add_Item_form.FN = "PR"
    add_Item_form.Show vbModal
Else
    MsgBox "Select Item Type to add new item ...", vbInformation, "Select Item Type ..."
    Combo2.SetFocus
End If
End Sub

Private Sub LaVolpeButton2_Click()

'Combo2.Text = Clear
Refresh_combobox (2)
frm_item_type.FN = "PR"

frm_item_type.Show vbModal
End Sub

Private Sub LaVolpeButton3_Click()
Combo3.Enabled = False
PADD = True

LaVolpeButton3.Enabled = False
frm_party_name.Show vbModal
End Sub

Private Sub Text1_Change(Index As Integer)
If Index = 2 Or Index = 3 Then
    If VAL(Text1(2).Text) <> 0 And VAL(Text1(3).Text) <> 0 Then
        Text1(4).Text = VAL(Text1(2).Text) * VAL(Text1(3).Text)
    End If
End If
End Sub

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
        KeyCode = 0
        SendKeys "{TAB}"
    End If
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
    If Index = 0 Then
        If KeyAscii = 34 Or KeyAscii = 39 Then
            KeyAscii = 0
        End If
    ElseIf Index = 1 Then
        If KeyAscii >= 97 And KeyAscii <= 122 Then
        ElseIf KeyAscii >= 65 And KeyAscii <= 90 Then
        ElseIf KeyAscii = 32 Or KeyAscii = 46 Or KeyAscii = 8 Then
        Else
            KeyAscii = 0
        End If
    ElseIf Index = 2 Then
        
        If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
        ElseIf KeyAscii = 8 Then
        Else
            KeyAscii = 0
        End If
    ElseIf Index = 3 Then
        If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
        ElseIf KeyAscii = 46 Then
            If InStr(1, Text1(3).Text, ".", vbTextCompare) > 0 Then
                KeyAscii = 0
            End If
        ElseIf KeyAscii = 8 Then
        Else
            KeyAscii = 0
        End If
        
    End If
End Sub



Private Sub Text1_Validate(Index As Integer, Cancel As Boolean)
If Index = 0 Then
    If Len(Text1(0).Text) = 0 Then
        Cancel = True
    End If
ElseIf Index = 1 Then
    If Len(Combo3.Text) = 0 Then
        Cancel = True
    End If
ElseIf Index = 2 Then
        If Len(Text1(Index).Text) = 0 Then
            Text1(Index).Text = 0
        End If
    
ElseIf Index = 3 Then
        If Len(Text1(Index).Text) = 0 Then
            Text1(Index).Text = 0
        End If
End If
End Sub

Public Sub Refresh_combobox(Index As Integer)
    If Index = 2 Then
    Combo2.Clear
    item_type.Requery
    While item_type.EOF <> True
            Combo2.AddItem item_type(0).Value
            item_type.MoveNext
    Wend
    
    ElseIf Index = 1 Then
    Combo1.Clear
    item_rs.Close
    item_rs.Open "select * from item_master where Itemtype ='" & Combo2.Text & "'", db, adOpenDynamic, adLockOptimistic
    While item_rs.EOF <> True
            Combo1.AddItem item_rs.Fields(1).Value
            item_rs.MoveNext
    Wend
    
    ElseIf Index = 3 Then
    Combo3.Clear
    pname.Requery
    While pname.EOF <> True
        Combo3.AddItem pname.Fields(0).Value
        pname.MoveNext
    Wend

    End If
End Sub

Public Function ENABLE_DISABLE(t As Boolean)
If t = True Then
    Combo2.Enabled = True
    Combo1.Enabled = True
    LaVolpeButton1.Enabled = True
    LaVolpeButton2.Enabled = True
    Text1(2).Enabled = True
    Text1(3).Enabled = True
    Text1(5).Enabled = True
ElseIf t = False Then
    Combo2.Enabled = False
    Combo1.Enabled = False
    LaVolpeButton1.Enabled = False
    LaVolpeButton2.Enabled = False
    Text1(2).Enabled = False
    Text1(3).Enabled = False
    Text1(5).Enabled = False
End If
End Function

Public Sub opbutton_status(t As Boolean)
If t = True Then
    DataGrid1.Enabled = True
    cmd_op(0).Enabled = True
    cmd_op(1).Enabled = False
    Dim rs_check_data As New ADODB.Recordset
    rs_check_data.Open "select count(*) from SYS_CURRENT_INVOICE", db, adOpenDynamic, adLockOptimistic
    
    If rs_check_data.Fields(0).Value > 0 Then
        cmd_op(2).Enabled = True
        cmd_op(3).Enabled = True
    Else
        cmd_op(2).Enabled = False
        cmd_op(3).Enabled = False
    End If
    cmd_op(4).Enabled = False
    rs_check_data.Close
    
ElseIf t = False Then
    DataGrid1.Enabled = False
    cmd_op(0).Enabled = False
    cmd_op(1).Enabled = True
    cmd_op(2).Enabled = False
    cmd_op(3).Enabled = False
    cmd_op(4).Enabled = True
End If

End Sub

Public Sub clear_box()
Refresh_combobox (2)
Refresh_combobox (1)

Text1(2).Text = Clear
Text1(3).Text = Clear
Text1(4).Text = Clear
Text1(5).Text = Clear
End Sub

Public Sub FILLTEXT()
Combo2.Text = rs_cur_invoice_item.Fields(0).Value
Combo1.Text = rs_cur_invoice_item.Fields(1).Value
Text1(2).Text = rs_cur_invoice_item.Fields(2).Value
Text1(3).Text = rs_cur_invoice_item.Fields(3).Value
Text1(4).Text = rs_cur_invoice_item.Fields(4).Value
Text1(5).Text = rs_cur_invoice_item.Fields(5).Value
End Sub

⌨️ 快捷键说明

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