Académique Documents
Professionnel Documents
Culture Documents
If toNumber(txtCT.Text) = 0 Then
MsgBox "Cash Tendered should greater than zero value.Please check it!",
vbExclamation
Exit Sub
End If
CN.BeginTrans
With Grid
For lngrow1 = .FixedRows To .Rows - 1
Set RSPartUpdate = New ADODB.Recordset
RSPartUpdate.Open "SELECT Spare_Parts.* FROM Spare_Parts WHERE
PartID ='" & .TextMatrix(lngrow1, 1) & "'", CN, adOpenDynamic, adLockOptimistic
RSPartUpdate![Inventory] = RSPartUpdate![Inventory] -
toNumber(.TextMatrix(lngrow1, 3))
RSPartUpdate![LastDateModified] = Now
RSPartUpdate![ModifiedBy] = ACTIVE_USER.USERNAME
RSPartUpdate.Update
Next lngrow1
End With
Else
RS.Fields("LastDateModified") = Now
RS.Fields("ModifiedBy") = ACTIVE_USER.USERNAME
With Grid2
For lngrow2 = .FixedRows To .Rows - 1
If .TextMatrix(lngrow2, 1) = "" Then
'DO NOTHING
Else
Set RSPartUpdate = New ADODB.Recordset
RSPartUpdate.Open "SELECT Spare_Parts.* FROM Spare_Parts WHERE
PartID ='" & .TextMatrix(lngrow2, 1) & "'", CN, adOpenDynamic, adLockOptimistic
RSPartUpdate![Inventory] = RSPartUpdate![Inventory] +
toNumber(.TextMatrix(lngrow2, 3))
RSPartUpdate![LastDateModified] = Now
RSPartUpdate![ModifiedBy] = ACTIVE_USER.USERNAME
RSPartUpdate.Update
End If
Next lngrow2
End With
End If
With RS
.Fields("CustomerID") = NSCustomer.Text
.Fields("CustomerName") = txtEntry(4).Text
.Fields("Address") = txtEntry(1).Text
.Fields("TelNo") = txtEntry(2).Text
.Fields("Date") = DTDP.Value
.Fields("SInstruction") = txtEntry(5).Text
.Fields("Salesman") = ACTIVE_USER.FULLNAME
.Fields("Remarks") = txtRemarks.Text
.Fields("FOP") = cmbFP.Text
.Fields("Gross") = txtGrossAmount.Text
.Fields("Discount") = txtDesc.Text
.Fields("TaxBase") = txtTaxBase.Text
.Fields("VAT") = txtVat.Text
.Fields("NetAmount") = txtNetAmount.Text
.Fields("CT") = txtCT.Text
.Fields("CA") = txtCA.Text
.Fields("StatusID") = NSStatus.Text
.Fields("StatusDesc") = txtEntry(6).Text
.Update
End With
DeleteItems
Dim c As Integer
With Grid
For c = 1 To cIRowCount
.Row = c
If State = AddStateMode Then
AddNew:
Dim RSSalesDetail As New Recordset
RSSalesDetail.AddNew
RSSalesDetail![SalesOrderID] = PK
RSSalesDetail![CustomerID] = NSCustomer.Text
RSSalesDetail![PartID] = .TextMatrix(c, 1)
RSSalesDetail![PartDescription] = .TextMatrix(c, 2)
RSSalesDetail![Qty] = toNumber(.TextMatrix(c, 3))
RSSalesDetail![UnitPrice] = toMoney(.TextMatrix(c, 4))
RSSalesDetail![GrossAmount] = toMoney(.TextMatrix(c, 5))
RSSalesDetail.Update
End If
Next c
End With
'Clear variables
c = 0
ResetEntry
CN.CommitTrans
HaveAction = True
cmdPrintPreview_Click
Unload Me
Else
MsgBox "Changes in record has been successfully saved.", vbInformation
Unload Me
End If
Exit Sub
err:
CN.RollbackTrans
MsgBox "Error: " & err.Description, vbExclamation
Exit Sub
If err.Number = -2147217887 Then Resume Next
End Sub