By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Need help!

P: 1
I need help writing some code for this procedure:
Inventory – Add to Item Listing menu item (15 points). Application users will use this menu as part of the process of entering inventory information. The steps for entering inventory information are: (1) select an existing inventory item from the Select Item ComboBox control, (2) enter the wholesale cost of the item and quantity in stock, (3) click the Inventory menu, Add to Item Listing sub menu.



Because menu items do not have a CausesValidation property and do not properly trigger ErrorProvider errors, you will take a different approach to validating data for the form. The Click event for this menu item must call a function named ValidData that validates the following business rules. The ValidData function code is given to you here. It validates three business rules and if a business rule is violated, displays an appropriate message box. The data must not be processed if a business rule is violated.

* Business rule #1: An inventory item type has been selected from the itemComboBox control.
* Business rule #2: The wholesaleCostTextBox control contains a numeric value greater than zero.
* Business rule #3: The quantityTextBox control contains a numeric value greater than zero.



Private Function ValidData() As Boolean

'Validate the business rules—assume the data is not valid initially.

ValidData = False



If Me.itemComboBox.SelectedIndex = -1 Then

'Violates business rule #1

MessageBox.Show("You must select an inventory item.", "Item Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

Me.itemComboBox.Focus()



ElseIf IsNumeric(Me.wholesaleCostTextBox.Text) = False OrElse _

Decimal.Parse(Me.wholesaleCostTextBox.Text) <= 0 Then

'Violates business rule #2

MessageBox.Show("Price must be a number greater than zero.", "Price Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

Me.wholesaleCostTextBox.Focus()

Me.wholesaleCostTextBox.SelectAll()



ElseIf IsNumeric(Me.quantityTextBox.Text) = False OrElse _

Integer.Parse(Me.quantityTextBox.Text) <= 0 Then

'Violates business rule #3

MessageBox.Show("Quantity must be a number greater than zero.", "Quantity Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

Me.quantityTextBox.Focus()

Me.quantityTextBox.SelectAll()



Else

'Data is valid, return a true.

ValidData = True

End If

End Function



* Your code must properly call the ValidData function and if the data is valid, complete these additional computing tasks.

* Calculate the Item Value (quantity times price) and store this value to a decimal variable.
* Display (Add) a string consisting of the Item (from the ComboBox) + Item Value (not the wholesale cost) as a string item to the itemListBox control as illustrated in the figure of the form shown earlier.
* Accumulate (Add) the Item Value to a module-level variable that will store the total inventory value of all items counted during an inventory session, and then update the display of the running total inventory value to the Total Inventory Value TextBox control at the bottom of the form. Note that an inventory counting session almost always consist of counting more than one item. Also, the same type of item may be stored in more than one location in the store so the same item may appear more than once in the itemListBox.
* Clear the text property for each of the itemComboBox, wholesaleCostTextBox, and quantityTextBox controls. Unselect the itemComboBox item. Set the focus to the itemComboBox.
* Items listed in the itemListBox control should NOT be sorted.
Apr 14 '08 #1
Share this Question
Share on Google+
2 Replies


daniel aristidou
100+
P: 491
im confused is the code above code you have been provided with or your own attempt?
Apr 14 '08 #2

lotus18
100+
P: 866
Use code tags for ease of viewing. And post your question just one by one.

Rey Sean
Apr 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.