custom home project

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 2676 Views - Last Post: 14 October 2012 - 01:04 PM Rate Topic: -----

#1 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

custom home project

Posted 11 October 2012 - 03:49 PM

My project is as follows: (This is not my idea!) I realize it would be better in Excel or another program, but this is what I have to work with.

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....

Is This A Good Question/Topic? 0
  • +

Replies To: custom home project

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: custom home project

Posted 11 October 2012 - 04:38 PM

I would suggest saving it to a database.. or worst case scenario - a local xml file.
Was This Post Helpful? 1
  • +
  • -

#3 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 04:46 PM

Funny thing. We're in Chapter 8, we don't learn about DBMS until 13...I don't know if I will have enough time to read ahead that far. But this chapter deals with text pad files? Any information there?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: custom home project

Posted 11 October 2012 - 04:53 PM

streamreader and streamwriter will be your friend.. about three lines of code to setup/use each.. just shove strings into it.. they get written.. and you can pull them off as well with a while loop.
Was This Post Helpful? 1
  • +
  • -

#5 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 04:56 PM

Also in setting up my Gui I'm wondering: Given the following information

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?


View Postmodi123_1, on 11 October 2012 - 06:53 PM, said:

streamreader and streamwriter will be your friend.. about three lines of code to setup/use each.. just shove strings into it.. they get written.. and you can pull them off as well with a while loop.

This post has been edited by charyl: 11 October 2012 - 04:58 PM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: custom home project

Posted 11 October 2012 - 04:56 PM

Typically you save "time" when you write the record to a database or your flat file.

You should use a listbox for the item number.. and that loads up the description, price, and unit.
Was This Post Helpful? 0
  • +
  • -

#7 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 07:27 PM

Mod,

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?

View Postmodi123_1, on 11 October 2012 - 06:53 PM, said:

streamreader and streamwriter will be your friend.. about three lines of code to setup/use each.. just shove strings into it.. they get written.. and you can pull them off as well with a while loop.

Was This Post Helpful? 0
  • +
  • -

#8 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 07:33 PM

nevermind, I checked out a book in the library today and I'm watching a video, will probably need help with programming momentarily. I have most of my code writen, but will need help with 2 objects on the strip menu, maybe...(Probably)

This post has been edited by charyl: 11 October 2012 - 07:34 PM

Was This Post Helpful? 0
  • +
  • -

#9 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 07:59 PM

Ok, here's my first 2 questions, I will be looking for answers as well.

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



Was This Post Helpful? 0
  • +
  • -

#10 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 11 October 2012 - 09:10 PM

The second issue can be resolved by using:
If result <> Windows.Forms.DialogResult.Cancel Then

And nope, there doesn't appear to be a procedure called CloseFile…
Was This Post Helpful? 1
  • +
  • -

#11 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 09:16 PM

Well hello there stranger!
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

Was This Post Helpful? 0
  • +
  • -

#12 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 09:41 PM

Is there a possibility the the Imports System.IO is connectect to the CloseFile() and I have the properties set wrong in the properties import section or Reference section in the Microsoft.VisualBasic menu under the (Imported namespaces)? Is it apart of StreamWriter?

This post has been edited by charyl: 11 October 2012 - 09:42 PM

Was This Post Helpful? 0
  • +
  • -

#13 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: custom home project

Posted 11 October 2012 - 10:06 PM

View Postcharyl, on 12 October 2012 - 10:11 AM, said:

Is there a possibility the the Imports System.IO is connectect to the CloseFile() and I have the properties set wrong in the properties import section or Reference section in the Microsoft.VisualBasic menu under the (Imported namespaces)? Is it apart of StreamWriter?


I would suggest you to go through this link on file closing. Hope this helps :)

regards,
Raghav
Was This Post Helpful? 1
  • +
  • -

#14 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 11 October 2012 - 10:17 PM

When Debugging this is what was found:

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.
Was This Post Helpful? 0
  • +
  • -

#15 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: custom home project

Posted 12 October 2012 - 07:23 AM

Quote

Also I would like to string my PONumber to a lable off to the side so it shows up 2times on the form.

This made zero sense.

Quote

Invalid Account #, no matter what I typed into the account number box, tried 1, 100, 900?


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"
Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2