Solved

vb 2005 sales form

Posted on 2009-04-09
40
323 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now