📄 frm_modify_purchase_book.frm
字号:
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 Updating 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_Load()
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, adOpenKeyset, 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)
FILLTEXT
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 = "M"
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 = "M"
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
If Len(rs_cur_invoice_item.Fields(5).Value) > 0 Then
Text1(5).Text = rs_cur_invoice_item.Fields(5).Value
End If
End Sub
Public Sub delete_old_rows()
Dim del_awa_st As New ADODB.Recordset
Dim del_pur_mas As New ADODB.Recordset
del_awa_st.Open "select * from AVAILABLE_PURCHASED_STOCK where Invoice_no='" & Text1(0).Text & "' and Party_name='" & Combo3.Text & "'", db, adOpenKeyset, adLockOptimistic
While del_awa_st.EOF <> True
del_awa_st.Delete
del_awa_st.MoveNext
Wend
del_pur_mas.Open "select * from Purchase_master where Invoice_no='" & Text1(0).Text & "' and Party_name='" & Combo3.Text & "'", db, adOpenKeyset, adLockOptimistic
While del_pur_mas.EOF <> True
del_pur_mas.Delete
del_pur_mas.MoveNext
Wend
Dim updata_item_master As New ADODB.Recordset
Dim critical_pur_data As New ADODB.Recordset
critical_pur_data.Open "select * from CRITICAL_PURCHASE_DATA", db, adOpenKeyset, adLockOptimistic
While critical_pur_data.EOF <> True
updata_item_master.Open "select * from Item_master where Itemtype='" & critical_pur_data.Fields(3).Value & "' and Item_name='" & critical_pur_data.Fields(4).Value & "'", db, adOpenKeyset, adLockOptimistic
updata_item_master.Fields(3).Value = updata_item_master.Fields(3).Value - VAL(critical_pur_data.Fields(5).Value)
updata_item_master.Update
updata_item_master.Close
critical_pur_data.MoveNext
Wend
Dim del_unpaid As New ADODB.Recordset
del_unpaid.Open "select * from AMT_UNPAID_REMIND where PARTY_NAME='" & Combo3.Text & "' and INVOICE_NO='" & Text1(0).Text & "' AND TRAN_TYPE='PURCHASE'", db, adOpenKeyset, adLockOptimistic
If del_unpaid.RecordCount > 0 Then
del_unpaid.Delete
End If
del_unpaid.Close
db.Execute "DELETE FROM EXPENSE WHERE INVOICE_NO='" & Text1(0).Text & "' AND EXPENSE_TYPE='Discounted Amount(Purchase)'"
db.Execute "DELETE FROM INCOME WHERE INVOICE_NUMBER='" & Text1(0).Text & "' AND INCOME_TYPE='Discounted Amount(Purchase)'"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -