Solved

vb 2005 sales form

Posted on 2009-04-09
40
339 Views
Last Modified: 2013-12-26
hello i have make a sales form in vb 2005 the form is linked with ms access 2003.The  problem is i have three fields Units in stock ,Reorder level and units in order.ok for each product i enter manually the numbers for how many i  unit i have in stock  reorder level and etc.I WANT  when a product sold to a customer the product minus -1 -2 depend how many products a customer buy. when the  units in stock go to 0 reorder level  sent me a msg that need to refil it.
0
Comment
Question by:demoniumz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 25
  • 8
  • 5
40 Comments
 
LVL 5

Accepted Solution

by:
srinivasbn earned 250 total points
ID: 24114803
Hi demoniumz,

You can have multiple solutions for this.

1. Before you enter into selling form please check the quantity. If it is 0 then reset it and then enter into the form.

2. Else when the user selects the quantity get the no.of items and if the no is exceeding the existing quantity then dont allow the user to buy.

Regards,
Srinivas.B.N
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24133627
explain me more details  please
0
 
LVL 5

Expert Comment

by:srinivasbn
ID: 24134342
Hi demoniumz,

Here is the detailed explonation

1. Before entering into the selling form means, when you are trying to load the selling form from another form, Check the quantity from the database. If the quantity is 0 then display a message to the user or else load the form.

2. You can do the quantity check after entering into the form also. When the user selects quantity option then you can check it from the database. If it is 0 then give a message to the user.

If you didn't understand it please send me your sample forms so that i can do it and send it to you.

Srinivas.B.N
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 1

Author Comment

by:demoniumz
ID: 24199964
ok soon we comunicate
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24469408
soon  we comunicate 1-2 days
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24477903
Srinivasbn i need your  help i update here the mini project and the database in order to  help me  is ok is little big is any problem let me know.If You need only samples let me know that sumples You need please

my forms is

Bonus card aplication
Suppliers
Employeees
Products
Ctegories
Orders(sales)
purchase(from employees)
Ncallendar
Nemail
NInfos
NicolaouLogin
and etc  


Thnks for help

Regards demoniumz
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24480679
How do you save the order? Can you show us the code for saving order. It is a multistep process. When the user adds a product to the order, you need to verify that there is enough quantity in stock to fulfil the order. Then once the order is saved, you need to subtract the quantity sold from the quantity available. And if the remaining quantity is below reorder level then show a message. This all depends on how your form works and how do you do database bits.
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24488818
save  the order ok is multistep there are to  buttons orders and order details button in order to save it because it save data for 2 table:)

Next  When the user adds a product to the order, you need to verify that there is enough quantity in stock to fulfil the order. Then once the order is saved, you need to subtract the quantity sold from the quantity available. And if the remaining quantity is below reorder level then show a message.


Yes Code cruiser you imagine what is my need:)  can u  help with  the code  and explain in me a little?

bellow is the save codes

Regards
demoniumz
 Private Sub OrdersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.OrdersBindingSource.EndEdit()
        Me.OrdersTableAdapter.Update(Me.NicolaouDBDataSet.Orders)
    End Sub
 Private Sub 
 
OrdersDetailsBindingSourceBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.OrdersDetailsBindingSource.EndEdit()
        Me.OrdersDetailsTableAdapter.Update(Me.NicolaouDBDataSet.OrdersDetails)
        Me.OrdersDetailsDataGridView.Refresh()
        TotalSum()

Open in new window

0
 
LVL 1

Author Comment

by:demoniumz
ID: 24491773
hello again to  is time to fix these problem  code cruiser can  u  provide any code in  order to help me?
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24499371
codecruiserSrinivasbn anyone here?
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24500800
Hello experts i am trying to add a code  but is wrong can anyone help me to full fit the requirement i need as  above i asked pls>?

Private Sub QuantityTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles QuantityTextBox.KeyDown
        If Val(QuantityTextBox.Text) > Val(UnitsInStockTextBox.Text) Then
            MsgBox("YOU CROSS THE SALES STOCK LIMIT", 0 + 48, "Nicolaou s Information")
            QuantityTextBox.Focus()
            Exit Sub
        End If
        If ReorderLevelTextBox.Text = "" Then
            ReorderLevelTextBox.Focus()
            Exit Sub
        End If
        If QuantityTextBox.Text = "" Then
            QuantityTextBox.Focus()
            Exit Sub
        End If
 
        UnitsInStockTextBox.Text = CStr(Val(UnitsInStockTextBox.Text) - CDbl(QuantityTextBox.Text))
 
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501195
Experts?Is possible to  provide me a help in this situation here? I am  here to  learn  not to play.I  try a code is now working and  i need a second help.I  understand that is no time for all but fist be pepoles and after anything else.


Regards demoniumz
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 24501334
@demoniumz,
The trouble is that you are a (1)starter and (2) not very good at english. So its very difficult to communicate any help and also to suggest you anything. The way it works here at EE is that people are given hints and then they explore the hints and links and help themselves. I may not be able to give you exact code but i can give you seudocode steps.
1) When user presses Add Product button, you first validate the input to make sure that a product is selected and quantity entered among other things.
2) You then perform a check to see if the required quantity is available in stock. If not, display a messagebox and stop the further execution.
3) If the required quantity is available then add the product to the order.
4) When saving the order, go through each product in the order and subtract the order quantity from the stock available.

You are using bindingsources etc. I prefer manual handling of database stuff using commands, connections, datatables, datareaders etc.

Hope it helps you.
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501403
1) When user presses Add Product button, you first validate the input to make sure that a product is selected and quantity entered among other things

Can u explain in in more details
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501430
I may not be able to give you exact code but i can give you seudocode steps.(1) Is really my english  languages is not good and i am  starter.(2) Thanks for the  seudocode steps.I want to ask  you if you  have any simmilar example to these i want or something general about my problems.

Regards demoniumz
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501434
Did you try the Dry Cleaners software example that i provided you in another question?
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501466
Nop so  much  i am  going to  try it again
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501480
can  u  give me again the address please again
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501494
check it in you questions. on your profile.
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501515
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501620
i think this is what is needed to do  about each thing i add in the datagrid view?My problem is that  if i add a word in the quantity textbox is not accepted but the msg box is  appear only if add a number i can  move somewhere else inside the form  why?
Private Sub QuantityTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Click
        Dim quantity As String
        Try
            quantity = CStr(Me.QuantityTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501626
i think this is what is needed to do  about each thing i add in the datagrid view?My problem is that  if i add a word in the quantity textbox is not accepted (but the message box is NOT APPEAR) only if add a number i can  move somewhere else inside the form  why?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501631
Quantity is not expressed in WORDS. It is supposed to be a number so when its not a number, you get the error message. If you mean you are unable to move to somewhere else on form, then look for QuantityTexBox.Focus statement and comment it out.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501636
Change the code to this



Private Sub QuantityTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Click
        Dim quantity As integer
        Try
            quantity = Integer.parse(Me.QuantityTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501644
working thnks i  understand:) codecruiser:)
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501647
so i must  validate all the  values that i add in   the datagrid view  first
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501685
Off course. You do not want the user to enter "blablabla" in the quantity textbox do you?
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501718
check  if  is ok these validation and apologize sometime i  make problem when  they problem is not exists:
 Private Sub QuantityTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Click
        Dim quantity As Char
        Try
            quantity = Char.Parse(Me.QuantityTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    Private Sub ProductNameTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductNameTextBox1.Click
        Dim productname As Integer
        Try
            productname = Integer.Parse(Me.ProductNameTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    Private Sub ProductIDComboBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductIDComboBox.Click
        Dim productid As Integer
        Try
            productid = Integer.Parse(Me.ProductIDComboBox.SelectedValue)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    
 
   
 
    Private Sub DescriptionTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DescriptionTextBox.Click
        Dim Description As Char
        Try
            Description = Char.Parse(Me.DescriptionTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
 
    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
 
    End Sub
 
    Private Sub DiscountTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DiscountTextBox.Click
        Dim Discount As Integer
        Try
            Discount = Integer.Parse(Me.DiscountTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
   
 
    Private Sub UnitPriceTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UnitPriceTextBox.Click
        Dim Unitprice As Integer
        Try
            Unitprice = Integer.Parse(Me.UnitPriceTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub

Open in new window

0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501729
sorry i miss something here is  the corected
 Private Sub QuantityTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Click
        Dim quantity As Integer
        Try
            quantity = Integer.Parse(Me.QuantityTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    Private Sub ProductNameTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductNameTextBox1.Click
        Dim productname As Char
        Try
            productname = Char.Parse(Me.ProductNameTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    Private Sub ProductIDComboBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductIDComboBox.Click
        Dim productid As Integer
        Try
            productid = Integer.Parse(Me.ProductIDComboBox.SelectedValue)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    
 
   
 
    Private Sub DescriptionTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DescriptionTextBox.Click
        Dim Description As Char
        Try
            Description = Char.Parse(Me.DescriptionTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
 
    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
 
    End Sub
 
    Private Sub DiscountTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DiscountTextBox.Click
        Dim Discount As Integer
        Try
            Discount = Integer.Parse(Me.DiscountTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
   
 
    Private Sub UnitPriceTextBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UnitPriceTextBox.Click
        Dim Unitprice As Integer
        Try
            Unitprice = Integer.Parse(Me.UnitPriceTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub
 
    
End Class

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24501767
I am sorry mate but it appears to me that i have to teach you each and every thing and i do not have time for that. I suggest you buy some book or look for tutorials on the internet (Google is a developer's best companion).
Problems in code above.
1) Click is not the best event to do this validation.
2) Productname is not validated even if it is then its string not char
...

I wish you good luck on your journey to learning VB.NET.
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24501807
1.which  event is the best for validation
2. error parse is not member of string

i know that is not char  but string is not accepted codecruiser

 Private Sub ProductNameTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ProductNameTextBox1.Click
        Dim productname As String
        Try
            productname = String.Parse(Me.ProductNameTextBox.Text)
        Catch ex As FormatException
            MsgBox("The value you entered is not valid" & _
            vbCrLf & "Please try again")
        End Try
    End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:srinivasbn
ID: 24507556
Hi demoniumz,

Due to i am out of station its delayed.

I hope codecruiser gave good suggestion. Here is the some easy code that can perform while entering the values by the user in the text box.

    Private Sub QuantityTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles QuantityTextBox.KeyPress
        If (Asc(e.KeyChar) >= 47 And Asc(e.KeyChar) <= 57) Or (Asc(e.KeyChar) = 13) Or (Asc(e.KeyChar) = 8) Then
            If Trim(QuantityTextBox.Text) = String.Empty Then
                Label1.Text = ""
                Exit Sub
            End If
            If IsNumeric(QuantityTextBox.Text) Then
                Label1.Text = "Valid"
            Else
                Label1.Text = "Not Valid"
            End If
        Else
            e.Handled = True
        End If
    End Sub



Try this code. Instead of doing parser and catching in Try..Catch blocks it will perform the best for the end user also. It will restrict the end user at the entry level only. So that the user can enter only valid values.

Try this code.
Srinivas.B.N
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24508309
4) When saving the order, go through each product in the order and subtract the order quantity from the stock available.
 
what  about these  srinivasbn
0
 
LVL 5

Expert Comment

by:srinivasbn
ID: 24508349
i think this is not required. Because you are subtracting the stock directly in the dataset and then you are updating the dataset to the database. So you dont need to check the each order and subtracting the stock.

Srinivas.B.N
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24508363
where i subtracting the stock directly in the dataset and then you are updating the dataset to the database. ?
0
 
LVL 1

Author Comment

by:demoniumz
ID: 24508476
Srinivas.B.N you mean that?
 
UnitsInStockTextBox.Text = CStr(Val(UnitsInStockTextBox.Text) - CDbl(QuantityTextBox.Text))
     
0
 
LVL 5

Expert Comment

by:srinivasbn
ID: 24508826
Its all depends on your application designed. If you directly binding the dataset to the text box then if you are updating the text box means it will directly updates in the dataset.

Srinivas.B.N
0
 
LVL 1

Author Closing Comment

by:demoniumz
ID: 31568436
excelent forms is now finish
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question