Point of Sale Tutorial Part 7 - Code in Supplier Add Entry and Product Add Entry
Code in frmProductAE
'CODE FOR COMMAND BUTTON ADD CATEGORYCode in frmSupplierAE
Private Sub cmdAddCat_Click()
frmPCategoryAE.Show
End Sub
'CODE FOR COMMAND BUTTON ADD SUPPLIER
Private Sub cmdAddSupp_Click()
frmSupplierAE.Show
End Sub
'CODE FOR COMMAND BUTTON CLEAR
Private Sub cmdClear_Click()
ClearTextBox frmProductAE
cboCategory.Text = ""
cboSupplier.Text = ""
End Sub
'CODE FOR COMMAND BUTTON EXIT
Private Sub cmdExit_Click()
Unload Me
End Sub
'CODE FOR COMMAND BUTTON NEW
Private Sub cmdNew_Click()
txtProduct.Enabled = True
txtDescription.Enabled = True
cboCategory.Enabled = True
cboSupplier.Enabled = True
txtRemarks.Enabled = True
txtQty.Enabled = True
txtUnitPrice.Enabled = True
txtSellingPrice.Enabled = True
txtAmount.Enabled = True
txtProduct.SetFocus
Set rs = New ADODB.Recordset
rs.Open "Select * from StockIn ORDER BY BarCode ASC", cn, adOpenDynamic, adLockOptimistic
If rs.BOF = True Then
txtBarcode.Text = "640500947"
Else
rs.MoveLast
txtBarcode.Text = "6405" + Format(Val(Right(rs!BarCode, 5)) + 1, "0#####")
End If
rs.Close
Set rs = Nothing
End Sub
'CODE FOR COMMAND BUTTON SAVE
Private Sub cmdSave_Click()
If cboCategory.Text = vbNullString _
Or txtProduct.Text = vbNullString _
Or txtDescription.Text = vbNullString _
Or cboCategory.Text = vbNullString _
Or cboSupplier.Text = vbNullString _
Or txtQty.Text = vbNullString _
Or txtUnitPrice.Text = vbNullString _
Or txtSellingPrice.Text = vbNullString _
Or txtAmount.Text = vbNullString Then
MsgBox "Please fill all the text field.", vbCritical, "Error"
Exit Sub
Else
Set rs = New ADODB.Recordset
rs.Open "Select * from StockIn", cn, adOpenKeyset, adLockPessimistic
With rs
.AddNew
.Fields("BarCode") = txtBarcode.Text
.Fields("Product") = txtProduct.Text
.Fields("Supplier") = cboSupplier.Text
.Fields("Description") = txtDescription.Text
.Fields("Category") = cboCategory.Text
.Fields("Qty") = txtQty.Text
.Fields("UnitPrice") = txtUnitPrice.Text
.Fields("SellingPrice") = txtSellingPrice.Text
.Fields("Amount") = txtAmount.Text
.Fields("DateIn") = Date
.Fields("Remarks") = txtRemarks.Text
.Update
.Close
End With
Set rs = Nothing
MsgBox "Record Successfully Saved!", vbInformation, "Success Saved!"
cboCategory.Text = vbNullString
cboSupplier.Text = vbNullString
ClearTextBox frmProductAE
End If
End Sub
'CODE FOR LOADING FORM
Private Sub Form_Load()
Call Module2.Connect
Call PopulateCategory
Call PopulateSupplier
txtBarcode.Enabled = False
txtProduct.Enabled = False
txtDescription.Enabled = False
cboCategory.Enabled = False
cboSupplier.Enabled = False
txtRemarks.Enabled = False
txtQty.Enabled = False
txtUnitPrice.Enabled = False
txtSellingPrice.Enabled = False
txtAmount.Enabled = False
End Sub
'CODE FOR TEXTBOX PRODUCT KEYPRESS
Private Sub txtProduct_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
End Sub
'CODE FOR TEXTBOX SELLING PRICE LOSTFOCUS
Private Sub txtSellingPrice_LostFocus()
txtSellingPrice.Text = Format(txtSellingPrice, "###,#0.00")
End Sub
'CODE FOR TEXTBOX UNIT PRICE CHANGE
Private Sub txtUnitPrice_Change()
If pFlag = True Then
txtAmount.Text = txtQty.Text
ElseIf pFlag = False Then
txtAmount.Text = Format((Val(txtQty.Text) * (Val(txtUnitPrice.Text))), "###,#0.00")
End If
End Sub
'CODE FOR TEXTBOX UNIT PRICE LOST FOCUS
Private Sub txtUnitPrice_LostFocus()
txtUnitPrice.Text = Format(txtUnitPrice, "###,#0.00")
End Sub
Private Sub cmdClear_Click()
ClearTextBox frmSupplierAE
DTStart.Value = Date
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdNew_Click()
txtSupplier.Enabled = True
txtDescription.Enabled = True
txtAddress.Enabled = True
DTStart.Value = Date
cboStatus.Enabled = True
txtContact.Enabled = True
txtTelNo.Enabled = True
txtEmail.Enabled = True
txtTelfaxNo.Enabled = True
txtMobile.Enabled = True
DTStart.Enabled = True
txtSupplier.SetFocus
Set rs = New ADODB.Recordset
rs.Open "Select * from Supplier ORDER BY SupplierCode ASC", cn, adOpenDynamic, adLockOptimistic
If rs.BOF = True Then
txtSuppCode.Text = "SUPP000001"
Else
rs.MoveLast
txtSuppCode.Text = "SUPP" + Format(Val(Right(rs!SupplierCode, 6)) + 1, "0#####")
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub cmdSave_Click()
If txtSupplier.Text = vbNullString _
Or txtDescription.Text = vbNullString _
Or txtAddress.Text = vbNullString _
Or cboStatus.Text = vbNullString _
Or txtContact.Text = vbNullString _
Or txtTelNo.Text = vbNullString _
Or txtEmail.Text = vbNullString _
Or txtTelfaxNo.Text = vbNullString _
Or txtMobile.Text = vbNullString Then
MsgBox "Please fill all the text field.", vbCritical, "Error"
Exit Sub
Else
Set rs = New ADODB.Recordset
rs.Open "Select * from Supplier", cn, adOpenKeyset, adLockPessimistic
With rs
rs.Find " SupplierName= '" & txtSupplier.Text & "'"
If .EOF = True Then
.AddNew
.Fields("SupplierCode") = txtSuppCode.Text
.Fields("SupplierName") = txtSupplier.Text
.Fields("Description") = txtDescription.Text
.Fields("Address") = txtAddress.Text
.Fields("DateStart") = DTStart.Value
.Fields("Status") = cboStatus.Text
.Fields("ContactPerson") = txtContact.Text
.Fields("TelNo") = txtTelNo.Text
.Fields("Email") = txtEmail.Text
.Fields("Telefax") = txtTelfaxNo.Text
.Fields("Mobile") = txtMobile.Text
.Update
MsgBox "Record Successfully Saved!", vbInformation, "Success Saved!"
.Close
Set Record = Nothing
ClearTextBox frmSupplierAE
cboStatus.Text = ""
DTStart.Value = Date
txtSupplier.Enabled = False
txtDescription.Enabled = False
txtAddress.Enabled = False
DTStart.Enabled = False
cboStatus.Enabled = False
txtContact.Enabled = False
txtTelNo.Enabled = False
txtEmail.Enabled = False
txtTelfaxNo.Enabled = False
txtMobile.Enabled = False
Exit Sub
Else
MsgBox "Record already exist!", vbExclamation, "Warning"
Exit Sub
End If
End With
Exit Sub
End If
End Sub
Private Sub Form_Load()
txtSuppCode.Enabled = False
txtSupplier.Enabled = False
txtDescription.Enabled = False
txtAddress.Enabled = False
DTStart.Enabled = False
cboStatus.Enabled = False
txtContact.Enabled = False
txtTelNo.Enabled = False
txtEmail.Enabled = False
txtTelfaxNo.Enabled = False
txtMobile.Enabled = False
cboStatus.AddItem "ACTIVE"
cboStatus.AddItem "INACTIVE"
Call Module2.Connect
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set rs = Nothing
Set frmSupplierAE = Nothing
End Sub
Private Sub txtAddress_LostFocus()
txtAddress.Text = StrConv(txtAddress.Text, vbProperCase)
End Sub
Private Sub txtContact_LostFocus()
txtContact.Text = StrConv(txtContact.Text, vbProperCase)
End Sub
Private Sub txtSupplier_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
End Sub
Point of Sale Tutorial Part 7 - Code in Supplier Add Entry and Product Add Entry
Reviewed by code-dev
on
10:43 AM
Rating:
No comments: