new to c#, any help?

nelnel Member Posts: 2,859 ■□□□□□□□□□
hi guys,

basically ive created a little app which basically stores IT equipment (just for learning purps). the app is just a single form with 3 txt boxes which display the pc make, its item ID and some installation notes.

ive created an one dimensional arraylist for each bit of information that goes in each of the text boxes(not sure this is the right way or whether a multi dimensional arraylist is better?) basicalli for each bit of kit in the app i want a pictures that piece of kit. does anyone know how i will add the pics to my app?

i would also like a search feature to search by either the item ID/number and/or by a keyword but im not sure how to do this.

any help would be good, or if anyone could point me in the right direction? would i be right in thinking there is something in the array class to use so i could search each array by either a string or int? or am i way off haha?

cheers

btw im using visual studio 2k3.
Xbox Live: Bring It On

Bsc (hons) Network Computing - 1st Class
WIP: Msc advanced networking

Comments

  • JDMurrayJDMurray Admin Posts: 13,101 Admin
    You are making an inventory application? You will want to store the inventory information in a SQL Server 2005 Express database. The data-aware controls in Visual Studio 2005 can then be linked to the database, making input, queries, and reports very easy to code.

    Many sample .NET/SQL Server applications are inventory apps. Have a look at the SQL Server 2005 walkthroughs at the MSDN Web site, like this one.

    SQL Server Express Infocenter
    Microsoft SQL Server Samples & Community Projects
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    hi, thanks for the reply JD.

    I have been thinking of doing an sql backend at some point but not yet. i just wanted to have a play with the basics first then move upto things like that.

    anyone any idea on how to search arraylists?
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    do you think it would be easier to save it all to an xml file and read/write it to there? because i cant seem to figure out how to search an arraylist by a keyword?
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • JDMurrayJDMurray Admin Posts: 13,101 Admin
    You need to explore the different data structure and storage objects available in .NET. Start with the Dictionary object: http://www.kirupa.com/net/dictionary_hashtable.htm
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    hi, thanks for the reply.

    ive setup my program so it can read from the xml file.
    i have a method which reads the xml but im getting an error on 2 of the four elements i require to be displayed in text boxes on the form.

    here is my c# code which points to the data in the xml file:
                          // called from constructor function
    			itemId = inventoryNode.Attributes["ItemId"].Value; // this works 
    			item = inventoryNode["Item"].InnerText; // returns error
    			notes = inventoryNode["Notes"].InnerText; //returns error
    			photoPath = inventoryNode["PhotoPath"].InnerText;// this works
    

    Now here is the structure of my XML file:


    <?xml version="1.0" encoding="utf-8" ?>

    <Inventory>
    <Inventory ItemId="01">
    <Item>Dell</Item>
    <Notes>Notes</Notes>
    <PhotoPath>../../Dell PC.jpg</PhotoPath>
    </Inventory>
    <Inventory ItemId="02">
    <Name>HP</Name>
    <Programme>Notes</Programme>
    <PhotoPath>../../HP PC.jpg</PhotoPath>
    </Inventory>

    Could anyone shed some light on this for me?

    cheers

    [/code]
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • dynamikdynamik Banned Posts: 12,312 ■■■■■■■■■□
    In your XML file, the second item uses "Name" and "Programme" instead of "Item" and "Notes"
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    OMG! cant believe i made that school boy error! my head is in bits at the moment. icon_redface.gif

    Thanks for the spot dynamik!
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    So for all you guru's out there, is it possible to enter the itemid, item and notes into 3 seperate textboxes and save them to the same xml file as above and save them in the same structure?

    Would you have to create the elements and append the data to it or something?(sorry for not being technical there, im still trying to learn my way!)
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
  • dynamikdynamik Banned Posts: 12,312 ■■■■■■■■■□
    This guide will probably help you out: http://www.developer.com/net/csharp/article.php/3489611

    You should really look at doing this with SQL though. I think you're making things much more complicated than they have to be.

    I'd check out this book if you haven't yet: http://www.wrox.com/WileyCDA/WroxTitle/productCd-047019135X.html
  • JDMurrayJDMurray Admin Posts: 13,101 Admin
    Yes, SQL would be the way to go. You can use SQL objects to import/export your recordset data as XML too.
  • nelnel Member Posts: 2,859 ■□□□□□□□□□
    thanks for the replies.

    Ive thought about sql backend but the course i follow at uni hasnt covered this yet and they want us to try and do it with only the things we have covered - and im finding it pretty frustrating most the time!
    Xbox Live: Bring It On

    Bsc (hons) Network Computing - 1st Class
    WIP: Msc advanced networking
Sign In or Register to comment.