473,387 Members | 1,435 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,387 software developers and data experts.

add or subtract Datagrid Dataset?

ROW Accountnr Amount
1 1001 12.00
2 1001 -12.00
3 1002 40.00
4 1002 -12.00
5 1002 -28.00
6 1003 30.00
7 1003 -30.00
8 ???? ......
Hello NG

I have a datagrid whit a dataset.
If the user down into the datagrid whit the mouse or the curser
i set in the new line (Row) the new accountnr manually.
datagrid(x,y) = accountnr

The problem is the amount column.
I must check the when the same accountnr is 0.
For example accountnr 1002 (40.00 - 12.00 -28.00) = 0

The problem is when the amount = 0
Accountnr = Accountnr +1
and my problem is to find out when the amount is 0.
It is possible i can add or subtract from my dataset whitout a new database
connection?

If yes ..hmm...have you a small few code for me that i can see as I could
realize that?

Thanks Michael

PS: I work whit C# Windows Application
Nov 15 '05 #1
3 2312
Hi Michael,

Your email is not very clear ,what I understand from it is that you want to
know which accounts have amount 0
if that is the case then is better not using the datagrid but the source
dataset

What first come into my mind is using a hashtable, being the key the
accountnr and the value the current amount, what you do is more or less like
this:
Hashtable table = new Hashtable();
foreach( DataRow row in dataset.Tables["table"].Rows )
if ( table.Contains( row["accountnr"] )
table[ row["accountnr"] ] = (double) table[ row["accountnr"] ] +
row["Amount"] ;
else
table.Add ( row["accountnr"], row["Amount"] );

then later you can iterate in the table searching for those with amount 0.

If this is not what you want post back, also remember that the code above
is not tested and may not be the best solution.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Michael Schindler" <NO**********************@naviti.ch> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
ROW Accountnr Amount
1 1001 12.00
2 1001 -12.00
3 1002 40.00
4 1002 -12.00
5 1002 -28.00
6 1003 30.00
7 1003 -30.00
8 ???? ......
Hello NG

I have a datagrid whit a dataset.
If the user down into the datagrid whit the mouse or the curser
i set in the new line (Row) the new accountnr manually.
datagrid(x,y) = accountnr

The problem is the amount column.
I must check the when the same accountnr is 0.
For example accountnr 1002 (40.00 - 12.00 -28.00) = 0

The problem is when the amount = 0
Accountnr = Accountnr +1
and my problem is to find out when the amount is 0.
It is possible i can add or subtract from my dataset whitout a new database connection?

If yes ..hmm...have you a small few code for me that i can see as I could
realize that?

Thanks Michael

PS: I work whit C# Windows Application

Nov 15 '05 #2
Hello Ignacio

Thanks for your answer.

But i dont understand what this code to do.
If you have time please send me a few description thank you.

My problem is only the in the correct time the Accountnr to increase.

Present to you: The user give line vor line manually different datas into my
datagrid.
And this function is a work easement if the user go manually to line(row)
[8] the programm must check if Amount = 0
If Yes = the Accountnr +1
If No = the Accountnr variabel remains the same
that's all.
Hashtable table = new Hashtable();
foreach( DataRow row in dataset.Tables["table"].Rows )
if ( table.Contains( row["accountnr"] )
table[ row["accountnr"] ] = (double) table[ row["accountnr"] ] +
row["Amount"] ;
else
table.Add ( row["accountnr"], row["Amount"] );

then later you can iterate in the table searching for those with amount 0.

If this is not what you want post back, also remember that the code above
is not tested and may not be the best solution.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Michael Schindler" <NO**********************@naviti.ch> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
ROW Accountnr Amount
1 1001 12.00
2 1001 -12.00
3 1002 40.00
4 1002 -12.00
5 1002 -28.00
6 1003 30.00
7 1003 -30.00
8 ???? ......
Hello NG

I have a datagrid whit a dataset.
If the user down into the datagrid whit the mouse or the curser
i set in the new line (Row) the new accountnr manually.
datagrid(x,y) = accountnr

The problem is the amount column.
I must check the when the same accountnr is 0.
For example accountnr 1002 (40.00 - 12.00 -28.00) = 0

The problem is when the amount = 0
Accountnr = Accountnr +1
and my problem is to find out when the amount is 0.
It is possible i can add or subtract from my dataset whitout a new

database
connection?

If yes ..hmm...have you a small few code for me that i can see as I could realize that?

Thanks Michael

PS: I work whit C# Windows Application


Nov 15 '05 #3
Hi Michael,

Well I think that I do understand you now :) , your first post was not clear
enough ,
the code I gave you is not useful for this.

What you can do is keep a variable in the form where the grid is located
that keeps the current value , when the user add a row you update this
variable, if the value is 0 then you create a new account number.

I hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Michael Schindler" <NO**********************@naviti.ch> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
Hello Ignacio

Thanks for your answer.

But i dont understand what this code to do.
If you have time please send me a few description thank you.

My problem is only the in the correct time the Accountnr to increase.

Present to you: The user give line vor line manually different datas into my datagrid.
And this function is a work easement if the user go manually to line(row)
[8] the programm must check if Amount = 0
If Yes = the Accountnr +1
If No = the Accountnr variabel remains the same
that's all.
Hashtable table = new Hashtable();
foreach( DataRow row in dataset.Tables["table"].Rows )
if ( table.Contains( row["accountnr"] )
table[ row["accountnr"] ] = (double) table[ row["accountnr"] ] +
row["Amount"] ;
else
table.Add ( row["accountnr"], row["Amount"] );

then later you can iterate in the table searching for those with amount 0.
If this is not what you want post back, also remember that the code above is not tested and may not be the best solution.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Michael Schindler" <NO**********************@naviti.ch> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
ROW Accountnr Amount
1 1001 12.00
2 1001 -12.00
3 1002 40.00
4 1002 -12.00
5 1002 -28.00
6 1003 30.00
7 1003 -30.00
8 ???? ......
Hello NG

I have a datagrid whit a dataset.
If the user down into the datagrid whit the mouse or the curser
i set in the new line (Row) the new accountnr manually.
datagrid(x,y) = accountnr

The problem is the amount column.
I must check the when the same accountnr is 0.
For example accountnr 1002 (40.00 - 12.00 -28.00) = 0

The problem is when the amount = 0
Accountnr = Accountnr +1
and my problem is to find out when the amount is 0.
It is possible i can add or subtract from my dataset whitout a new

database
connection?

If yes ..hmm...have you a small few code for me that i can see as I

could realize that?

Thanks Michael

PS: I work whit C# Windows Application



Nov 15 '05 #4

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

Similar topics

0
by: Frosty | last post by:
Hi I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Rod | last post by:
I posted a message to this group yesterday asking how to pass parameters to a web form that is the source of an IFrame on a parent web form. I've gotten my answer, and it works. Thanks! Now I...
3
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.