473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

dataset and group by

I've got a dataset on a datagridview: fileds are
code,descr,price,vatcode. I have to calculate the total amount of
vat.
Example:
first row = price 10$, vatcode 20
second row = price 50$, vatcode 10
third row = price 10$, vatcode 20
So, I have a SQL Table with vatcode and vat%, for example vatcode 20 =
20%, vatcode 10 = 10%
The goal is to group the rows of dataset (datagridview) by the vatcode
and calculate the total price for every different vatcode, for
example:
amount of 20$ (sum of first and third rows) with vatcode 20.
amount of 50 with vatcode 10 (the only one in the datagrid with that
vatcode).
After I have to calculate the entire amount of vat, so I have 20$ at
20% and 50$ at 10% and put it into a variable.
Thanks.
George

Feb 14 '07 #1
2 2802
Giminera,

Do you know the method to add columns to your datatable while using
expressions and to vertical sum while using compute.

http://msdn2.microsoft.com/en-gb/lib...e.compute.aspx

http://msdn2.microsoft.com/en-gb/lib...on(VS.80).aspx

As long as you don't force it, will those columns not come in your database.

Cor
"giminera" <gi******@libero.itschreef in bericht
news:11**********************@k78g2000cwa.googlegr oups.com...
I've got a dataset on a datagridview: fileds are
code,descr,price,vatcode. I have to calculate the total amount of
vat.
Example:
first row = price 10$, vatcode 20
second row = price 50$, vatcode 10
third row = price 10$, vatcode 20
So, I have a SQL Table with vatcode and vat%, for example vatcode 20 =
20%, vatcode 10 = 10%
The goal is to group the rows of dataset (datagridview) by the vatcode
and calculate the total price for every different vatcode, for
example:
amount of 20$ (sum of first and third rows) with vatcode 20.
amount of 50 with vatcode 10 (the only one in the datagrid with that
vatcode).
After I have to calculate the entire amount of vat, so I have 20$ at
20% and 50$ at 10% and put it into a variable.
Thanks.
George

Feb 15 '07 #2
On Feb 14, 10:10 pm, "giminera" <gimin...@libero.itwrote:
I've got a dataset on a datagridview: fileds are
code,descr,price,vatcode. I have to calculate the total amount of
vat.
Example:
first row = price 10$, vatcode 20
second row = price 50$, vatcode 10
third row = price 10$, vatcode 20
So, I have a SQL Table with vatcode and vat%, for example vatcode 20 =
20%, vatcode 10 = 10%
The goal is to group the rows of dataset (datagridview) by the vatcode
and calculate the total price for every different vatcode, for
example:
amount of 20$ (sum of first and third rows) with vatcode 20.
amount of 50 with vatcode 10 (the only one in the datagrid with that
vatcode).
After I have to calculate the entire amount of vat, so I have 20$ at
20% and 50$ at 10% and put it into a variable.
Thanks.
George
Maybe you can save the values in an array:

Dim myArr() As Integer
Dim vatcode As Integer
ReDim myArr(0)

For row As Integer = 0 To DataGridView1.Rows.Count - 2
vatcode = DataGridView1.Item("vatcode", row).Value
If myArr.Length < vatcode Then
ReDim Preserve myArr(vatcode)
End If
myArr(vatcode) += DataGridView1.Item("price", row).Value
Next

and now, for every vatcode you have a cell in the array containing the
price summary.

Feb 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Rogers | last post by:
How does one extract the attribute value from a dataset that has an XML file, such as the one in the bottom of this message, loaded into it? I need to use a dataset and the XMl file has to remain...
1
by: Ryan | last post by:
How can one extract the Attribute values from a Dataset that has been loaded with an XML file like the following at the bottom of the document. I have to use a dataset and the XML file must remain...
5
by: Amadelle | last post by:
Hi All and thanks in advance, I was wondering what is the best way of grouping data in a dataset. Like using a "Group By" clause in Sql statements. I was thinking of using XML but I don't even...
1
by: Rob via .NET 247 | last post by:
Ok, I'm new to .NET so I'm afraid I'm doing something stupidhere, but I'm trying to populate a DataSet manually from aDataReader, and its turning out to be ridiculously difficult. Yes, I could use...
7
by: kscdavefl | last post by:
I am running the following code to retrieve a DataSet: public DataView CreateGroupSource() { string groupConnect = Session.ToString(); string groupSelect = "Select grpname from Maxusergroups...
6
by: Fred | last post by:
I want to use a dataset so that I can obtain data from a number of sources and put it into one table. Using dataadaptors this seems to work well. Now I have a table (Forecast) in the dataset with...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
4
by: igotyourdotnet | last post by:
I want to group my data being returned from my dataset, the dataset looks like this: <bmw></bmw> <Lexus></Lexus> <ChevyTahoe></Chevy> <Mercedes></Mercedes> <ToyotaFourRunner></Toyota> If I...
7
by: SteveT | last post by:
Can someone point me in the right direction? Somewhere I read that you reference a strongly typed dataset as if it were a class structure. For example, <SomeTests> <TestsGroups> <Group>...
0
by: Adam Sandler | last post by:
Hello, Prior to posting I looked at http://groups.google.com/group/ microsoft.public.dotnet.framework.aspnet/browse_thread/thread/ d8d5ae243614085e/d4fd6c4a5aa56f75 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.