Hey, Iam designing a inventory software, and I need to make a table
that shows the item number, description and price of each item. Iam not
using any databases, just want to store all the info in 1 file. Whats
the best way I can do this in C#
Ok, I have another question: If Iam going to use XML in a datagrid then how can I access only the last column of the table so I can add up all the values
For example, if I have item description, item price, quantity and then the total in the last column how can make it so after entering in the price of the item and the quantity, the last column (total) is automatically generates the total (price * quantity) and also how can I add all the totals from each row to generate a final total
First of all, thanks to everyone that his helping me, its been really helpful from all the information you guys have shared.
And secondly, this XML thing as really taken care of my inventory
problem. Now another part of this business project that Iam doing is
the Invoicing part. I designed a simple form with a datagrid, but
this time I want to make the datagrid READONLY, and if the user wants
to add items to the order, then they have to use the "add" button,
where another form shows up where I can select the item and the
quantity and then just click OK, and it will add a row to the datagrid
table. and then the user can select rows and remove the item to modifiy
the table. So I dont want the user to enter things on the actual
datagrid, but another form.. Is there a way where I can send the data
from the child form, to the datagrid table
I know Iam asking for a lot here, but Iam not very good at C#
I am not sure about your definition of 'table' ... whether that be a HTML Table, DataTable ... etc. But I would suggest using XML for data storage. If you could give more specifics on what you are having trouble with, I am sure more people could help.
I just want a table that shows all the items in a file. Its for a
accounting/invoicing software that Iam designing, and I want to
show all the inventory in a windows form.
This is exactly what Iam trying to create. A table that Ican select the
entire row and delete it or add more items too it. Check this
image. Any ideas how I can get this done in C#
xml is flexible tool that you can use , you can save your data on it as your database but you have to design your dataset very carefully , anyway as soon as you load it to your dataset, you don't care about the xml file at all you keep following your data in your dataset till you save it back again ,
also you can open xml file as xmldocument and go through parseing issue
i guess the absolute biggener vedio serious have a good example about that i guess in lesson 9 or 10 i don't remember
I don't like the MSN idea because I have very little time lately 4 programming and I don't like to be bothered every minute (don't take it personal ;) ).
The fact that you haven't used xml before is no problem :)
I hadn't done anything before this myself with it (people who have might have noticed that already in the code). You just have to see it as a blackbox that saves your data and retrieves it. How it does that and if it uses xml at all shouldn't bother you (unless you really want to understand what's going on).
That's the great thing about it :)
Just use the XmlDataDocument.Load(filename) method to load and the .Save method to save.
If you want to know what is actually saved, just open the file create :)
If you have further problems just post the problems and I'm sure "the community" (sounds great doesn't it :D) will try to help you out :)
Looks like a DataGrid to me. Depends on where your data comes from and how you store it, but IMO the easiest way would be to bind a DataTable to a DataGrid.
there are two ways .... the hard way and the easy way .... The easy way is to simply load the data from the file using a dataadapter (ODBC or etc.) into a DATASET and then binding the table in the data set to dataGRID Control You will place on ur Windows form.
xyzdataGrid1.DataSource(xyzdataset);
can send u a complete sample app. if u need..
and the hardway is pretty hard i.e. maually generating controls etc. maybe you won't need to do that so I am not gonna waste your time telling u that :).
TakeItEasy, thanks for the code, most of it I understand, but I have
never done XML before. I just a need to create a simple app that
will store all inventory information and load it when the app starts
up.
The code seems clear enough, I will try it for sure, but I may need more of your help
would you mind help me using MSN, cause it will be alot faster that way
How do I create a simple table in C#
Peter R. Fletcher
For example, if I have item description, item price, quantity and then the total in the last column how can make it so after entering in the price of the item and the quantity, the last column (total) is automatically generates the total (price * quantity) and also how can I add all the totals from each row to generate a final total
Alan Hebert - MSFT
I guess this is what you need :
create a windows app and place 2 buttons and a datagridview on it.
The first button to load the second to save.
You also need a dataset and a XmlDataDocument (don't forget to put "using System.Xml" in you file.
So insert :
private DataSet dsInventory; private XmlDataDocument XmlLayouts;In the load of your form place :
dsInventory =
new DataSet("Inventory"); DataTable dtInventory = new DataTable("Inventory");dtInventory.Columns.Add(
"ID",Type.GetType("System.Int64"));dtInventory.Columns.Add(
"DescrBaseLanguage");dtInventory.Columns.Add(
"Stock", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Reserved", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Ordered", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Backorder", Type.GetType("System.Double"));dsInventory.Tables.Add(dtInventory);
dataGridView1.DataSource = dsInventory;
dataGridView1.DataMember =
"Inventory";XmlLayouts =
new XmlDataDocument(dsInventory);In the Click of your save button place :
XmlLayouts.Save(
@"C:\TEMP\Inventory.xml");in the click of the load button place :
XmlLayouts.Load(
@"C:\TEMP\Inventory.xml");This is just some rough code that needs a lot of pollishing, but I hope it will draw the picture of how you can do it.
Hope this helped :)
deadeye
And secondly, this XML thing as really taken care of my inventory problem. Now another part of this business project that Iam doing is the Invoicing part. I designed a simple form with a datagrid, but this time I want to make the datagrid READONLY, and if the user wants to add items to the order, then they have to use the "add" button, where another form shows up where I can select the item and the quantity and then just click OK, and it will add a row to the datagrid table. and then the user can select rows and remove the item to modifiy the table. So I dont want the user to enter things on the actual datagrid, but another form.. Is there a way where I can send the data from the child form, to the datagrid table
I know Iam asking for a lot here, but Iam not very good at C#
MGray
Larry Kyrala
---------------------------------------------------------
Item # | Item Description | Item Price
---------------------------------------------------------
75645 | Gloves | $4.30
75623 | Baseball hat | $5.60
Something like that, in a windows form......instead of using textboxs or labels....
ShinjiFei
Will McAfee
hi xcalibur
xml is flexible tool that you can use , you can save your data on it as your database but you have to design your dataset very carefully , anyway as soon as you load it to your dataset, you don't care about the xml file at all you keep following your data in your dataset till you save it back again ,
also you can open xml file as xmldocument and go through parseing issue
i guess the absolute biggener vedio serious have a good example about that i guess in lesson 9 or 10 i don't remember
best regards
cran7465
XCalibur,
I'm glad it helped (at least a bit ;) ).
I don't like the MSN idea because I have very little time lately 4 programming and I don't like to be bothered every minute (don't take it personal ;) ).
The fact that you haven't used xml before is no problem :)
I hadn't done anything before this myself with it (people who have might have noticed that already in the code). You just have to see it as a blackbox that saves your data and retrieves it. How it does that and if it uses xml at all shouldn't bother you (unless you really want to understand what's going on).
That's the great thing about it :)
Just use the XmlDataDocument.Load(filename) method to load and the .Save method to save.
If you want to know what is actually saved, just open the file create :)
If you have further problems just post the problems and I'm sure "the community" (sounds great doesn't it :D) will try to help you out :)
mrdomiscoding
Carmen Zlateff MSN
there are two ways .... the hard way and the easy way ....
The easy way is to simply load the data from the file using a dataadapter (ODBC or etc.) into a DATASET and then binding the table in the data set to dataGRID Control You will place on ur Windows form.
xyzdataGrid1.DataSource(xyzdataset);
can send u a complete sample app. if u need..
and the hardway is pretty hard i.e. maually generating controls etc. maybe you won't need to do that so I am not gonna waste your time telling u that :).
luisfdlr
hi,
you can make a table as what TakeItEasy said
2) creat a dataset as field in your class, Dataset ds = new dataset;
3) add the table to the dataset ds.tables.add(yourtable);
4) bind your datagridview to your dataset directly or by useing bindingsource
5) in your loadbutton you can add ds.readxml("thepathto your file or your filename .xml);
6) in your save button you can add ds.writexml("the path to your file or your file.xml)
hope this helps
Don Shaw
The code seems clear enough, I will try it for sure, but I may need more of your help
would you mind help me using MSN, cause it will be alot faster that way
Thanks
ASharif
Sorry for the late response :$
Here is what you can do :
dsInventory =
new DataSet("Inventory"); DataTable dtInventory = new DataTable("Inventory");dtInventory.Columns.Add(
"ID",Type.GetType("System.Int64"));dtInventory.Columns.Add(
"DescrBaseLanguage");dtInventory.Columns.Add(
"Stock", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Reserved", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Ordered", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Backorder", Type.GetType("System.Double"));dtInventory.Columns.Add(
"Stock * 2", Type.GetType("System.Double"),"Stock * 2");It's the last line that's important.