23 Replies - 1343 Views - Last Post: 14 October 2012 - 01:04 PM
#1
custom home project
Posted 11 October 2012 - 03:49 PM
A construction company is considering building homes. The company has asked you to develop a GUI application that provides a materials list estimation. The materials list estimation will contain a table with a grand total at the bottom. The user will be allowed to enter the item description, order quantity, and unit price. The application will display a column containing the estimated cost (order quantity multiplied by unit price) time and display it to the user. At the bottom of the list the application should display a total estimated cost to build the home.
• Clear button at any time to clear the table and begin a new materials list.
• Save button to save the information to a file.
• Calculate button to display the total estimated cost.
I have to build my Gui and will be back. I have no idea how to code a "Save button" or how to store this information. I do have a pdf of an example if you wish to see this....
Replies To: custom home project
#2
Re: custom home project
Posted 11 October 2012 - 04:38 PM
#3
Re: custom home project
Posted 11 October 2012 - 04:46 PM
#4
Re: custom home project
Posted 11 October 2012 - 04:53 PM
#5
Re: custom home project
Posted 11 October 2012 - 04:56 PM
The user will be allowed to enter the item description, order quantity, and unit price. The application will display a column containing the estimated cost (order quantity multiplied by unit price) time and display it to the user.
A. Time: I think I did see something somewhere along the line that will enter a time, but I think it would be cool to have the current time so when my teacher runs the program it will enter that date.
B. Should I use a ListBox for item description, order quantity and text boxes for unit prices? What would be the best way to set this Gui up? Is there a way I can list everything in a list box and the person click on individual items and they string to seperate list that allows them to enter price and quantity?
C. A PO number that coincides with a persons last name? How will you reference what you have saved...There should be a po (purchase order) number and if you don't remember that you can reference with a name?
Mod, have any good videos or tutorials in your mind you can share?
modi123_1, on 11 October 2012 - 06:53 PM, said:
This post has been edited by charyl: 11 October 2012 - 04:58 PM
#6
Re: custom home project
Posted 11 October 2012 - 04:56 PM
You should use a listbox for the item number.. and that loads up the description, price, and unit.
#7
Re: custom home project
Posted 11 October 2012 - 07:27 PM
I found your streamWriter and I'm useing a strip menu. I've never used this tool before and it's a bit different. Do I click on it and put in New, Open, Exit?
modi123_1, on 11 October 2012 - 06:53 PM, said:
#8
Re: custom home project
Posted 11 October 2012 - 07:33 PM
This post has been edited by charyl: 11 October 2012 - 07:34 PM
#9
Re: custom home project
Posted 11 October 2012 - 07:59 PM
A. There's a blue line under my closefile()...close file is not declared it may be inaccessable due to it's protection level. I named my close file on my menustrip: CloseToolStripMenuItem but It looks like it means to close the file so the user can create more files. I have more code to add so maybe it will adjust itself
B. There's a blue line under "FormWindowState.Forms." and it says Forms is not a member of "Systems.Windows.Forms.FormWindowState" I named my form Create Accounts, but I'm not sure that's the problem. Here's my code thus far.
Maybe you know what it's saying?
'Program that creates a text file of account information
Imports System.IO
Public Class CreateAccount
' Writes data totext file
Dim fileWriter As StreamWriter
'Create a new file in which accounts can be stored
Private Sub MenuStrip1_ItemClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClick
'ensure that any prior file is closed
CloseFile()
Dim result As DialogResult 'Stores result of Save dialog
Dim fileName As String 'Name of file to save data
'Display dialog so user can choose the name of the file to save
Using fileChooser As New SaveFileDialog()
result = fileChooser.ShowDialog()
fileName = fileChooser.FileName 'get specified file name
End Using 'Automatica call to fileCooser.Dispose() occureshere
' if user did not click Cancel
If result <> FormWindowState.Forms.DialogResult.Cancel Then
Try
'open or create file for writing
fileWriter = New StreamWriter(fileName, True)
'enable controls
ExistingEstimateToolStripMenuItem.Enabled = True
CloseToolStripMenuItem.Enabled = True
addAccountButton.Enabled = True
PONumberTextBox.Enabled = True
firstNameTextBox.Enabled = True
lastNameTextBox.Enabled = True
estimatedCostTextBox.Enabled = True
Catch ex As IOException
MessageBox.Show("Error Opening File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
End Class
#10
Re: custom home project
Posted 11 October 2012 - 09:10 PM
If result <> Windows.Forms.DialogResult.Cancel Then
And nope, there doesn't appear to be a procedure called CloseFile…
#11
Re: custom home project
Posted 11 October 2012 - 09:16 PM
Thanks that worked for that. I'm on line 81 and I've just reached the CloseToolStripMenuItem, we'll see... Hard to believe this is the easy part...OMGosh...I'm so screwed.
This is only the part to save the estimate. I have not even started on the work to preform the estimate and I will have little or no code to go on...I'll try using past projects. One thing I'm not sure of when I get there I need to string the total estimate cost to this that I'm working on now. I have not figured out the TryParse yet. DimitriV if you have a second look up Duplicate Elimination I posted on this week and tell me if there's coding you can figure out to use the TryParse. Just so I can try it on an old project instead of messing a new one up first. If you don't have time...I completely understand! Good to see you. Loved your pic. Love Spiderman too
This post has been edited by charyl: 11 October 2012 - 09:21 PM
#12
Re: custom home project
Posted 11 October 2012 - 09:41 PM
This post has been edited by charyl: 11 October 2012 - 09:42 PM
#13
Re: custom home project
Posted 11 October 2012 - 10:06 PM
charyl, on 12 October 2012 - 10:11 AM, said:
I would suggest you to go through this link on file closing. Hope this helps
regards,
Raghav
#14
Re: custom home project
Posted 11 October 2012 - 10:17 PM
Invalid Account #, no matter what I typed into the account number box, tried 1, 100, 900?
'Program that creates a text file of account information
Imports System.IO
Public Class CreateAccount
' Writes data totext file
Dim fileWriter As StreamWriter
Private Sub ExistingEstimateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExistingEstimateToolStripMenuItem.Click
Dim result As DialogResult
Dim fileName As String 'Name of file to save data
'Dim lblPONumber As String
Using fileChooser As New OpenFileDialog()
result = fileChooser.ShowDialog()
fileName = fileChooser.FileName
End Using
End Sub
'Create a new file in which accounts can be stored
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
'ensure that any prior file is closed
'CloseFile()
Dim result As DialogResult 'Stores result of Save dialog
Dim fileName As String 'Name of file to save data
'Dim PONumberTextBox As String
'Display dialog so user can choose the name of the file to save
Using fileChooser As New SaveFileDialog()
result = fileChooser.ShowDialog()
fileName = fileChooser.FileName 'get specified file name
End Using 'Automatica call to fileCooser.Dispose() occureshere
' if user did not click Cancel
If result <> Windows.Forms.DialogResult.Cancel Then
Try
'open or create file for writing
fileWriter = New StreamWriter(fileName, True)
'enable controls
ExistingEstimateToolStripMenuItem.Enabled = True
CloseToolStripMenuItem.Enabled = True
addAccountButton.Enabled = True
PONumberTextBox.Enabled = True
firstNameTextBox.Enabled = True
lastNameTextBox.Enabled = True
estimatedCostTextBox.Enabled = True
Catch ex As IOException
MessageBox.Show("Error Opening File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Private Sub addAccountButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addAccountButton.Click
'determine whether TextBox account field is empty
If PONumberTextBox.Text <> String.Empty Then
'Try to store record to file
Try
Dim PONumberTextBox As Integer = Convert.ToInt32(PONumberTextBox) 'gets account number
If PONumberTextBox > 0 Then 'Valid account number?
'wtite record data to file separatingfields by commas
fileWriter.WriteLine(PONumberTextBox & "," &
firstNameTextBox.Text & "," &
lastNameTextBox.Text & "," &
Convert.ToDecimal(estimatedCostTextBox))
Else
MessageBox.Show("Invalid Account Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As IOException
MessageBox.Show("ErrorToString Writing to File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ex As FormatException
MessageBox.Show("Invalid Account Number", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
PONumberTextBox.Clear()
firstNameTextBox.Clear()
lastNameTextBox.Clear()
estimatedCostTextBox.Clear()
PONumberTextBox.Focus()
End Sub 'addNewAccountButton_Click
Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
'CloseFile() ' Closes currently open file
CloseToolStripMenuItem.Enabled = False
addAccountButton.Enabled = False
PONumberTextBox.Enabled = False
firstNameTextBox.Enabled = False
lastNameTextBox.Enabled = False
estimatedCostTextBox.Enabled = False
End Sub 'CloseToolStripMenuItem_Click
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
' Exit the application
'SubCloseFile()
If fileWriter IsNot Nothing Then
Try
fileWriter.Close() 'close StreamWriter
Catch ex As IOException
MessageBox.Show("Error closing file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End Try
End If
End Sub
End Class
Also I would like to string my PONumber to a lable off to the side so it shows up 2times on the form.
#15
Re: custom home project
Posted 12 October 2012 - 07:23 AM
Quote
This made zero sense.
Quote
Seriously - take a break and look at what you are doing and what objects you are dealing with.
If PONumberTextBox > 0 Then 'Valid account number?
What is PONumberTextBox ? It's a textbox object. It is part graphical UI and an amalgamation of functions and properties. It is *NOT* a number. If you would try and get the .TEXT value of out of it that would be closer - because that would hold the STRING VALUE that was typed in the box.
Then you should stop and think - should I start comparing strings with a number 0? No.. a string is an array of characters that *COULD* contain a character that is a number and that presents a problem. You would need to CAST or CONVERT your string into a number type (probably integer) and then do the comparison. You may go even a step further and use the ISNUMERIC function with the string first and see if it can possibly be converted to a number.
In recap.
1. Know what objects you are using.
2. A textbox object is not something you should use to compare with a number
3. Read the MSDN topics on the objects you are using. Become familiar with the ways to get user input and data out of them and what those properties data types are
4. Understand why you cannot compare a STRING to an INTEGER
5. Understand how to CAST one data type to another.
6. Utilize precheck functions like "ISNUMERIC"
|
|

New Topic/Question
Reply



MultiQuote







|