Click here to Skip to main content
15,899,313 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to compare password from notepad with in the textbox Pin
Christian Graus27-Mar-07 5:42
protectorChristian Graus27-Mar-07 5:42 
GeneralRe: How to compare password from notepad with in the textbox Pin
Not Active27-Mar-07 5:43
mentorNot Active27-Mar-07 5:43 
GeneralRe: How to compare password from notepad with in the textbox Pin
Khoramdin27-Mar-07 5:53
Khoramdin27-Mar-07 5:53 
GeneralRe: How to compare password from notepad with in the textbox Pin
krajah1027-Mar-07 6:03
krajah1027-Mar-07 6:03 
GeneralRe: How to compare password from notepad with in the textbox Pin
Khoramdin27-Mar-07 6:28
Khoramdin27-Mar-07 6:28 
QuestionNew workspace window Pin
sinosoidal27-Mar-07 4:15
sinosoidal27-Mar-07 4:15 
AnswerRe: New workspace window Pin
Christian Graus27-Mar-07 4:22
protectorChristian Graus27-Mar-07 4:22 
Questionconnect Dataset with reportviewer Pin
FrankBoonen27-Mar-07 4:10
FrankBoonen27-Mar-07 4:10 
Hi,

I'm trying to find out how I can connect the reportviewer to a Datatable I created through the program.

my code:

DataTable DataForReport = new DataTable("DataForReport");
DataColumn Number = new DataColumn(); // function number
Number.DataType = System.Type.GetType("System.String");
Number.ColumnName = "NUMBER";
DataForReport.Columns.Add(Number);

DataColumn Descriptor = new DataColumn(); // function caption
Descriptor.DataType = System.Type.GetType("System.String");
Descriptor.ColumnName = "DESCRIPTOR";
DataForReport.Columns.Add(Descriptor);

DataColumn Quantity = new DataColumn(); // quantity sold
Quantity.DataType = System.Type.GetType("System.Decimal");
Quantity.ColumnName = "QUANTITY";
Quantity.DefaultValue = 0;
DataForReport.Columns.Add(Quantity);

DataColumn Sales = new DataColumn(); // gross sales amount
Sales.DataType = System.Type.GetType("System.Decimal");
Sales.ColumnName = "SALES";
Sales.DefaultValue = 0;
DataForReport.Columns.Add(Sales);

DataColumn Discount = new DataColumn(); // discount amount
Discount.DataType = System.Type.GetType("System.Decimal");
Discount.ColumnName = "DISCOUNT";
Discount.DefaultValue = 0;
DataForReport.Columns.Add(Discount);

DataColumn Net = new DataColumn(); // net amount
Net.DataType = System.Type.GetType("System.Decimal");
Net.ColumnName = "NET";
Net.DefaultValue = 0;
DataForReport.Columns.Add(Net);

DataColumn Cost = new DataColumn(); // cost price
Cost.DataType = System.Type.GetType("System.Decimal");
Cost.ColumnName = "COST";
Cost.DefaultValue = 0;
DataForReport.Columns.Add(Cost);

DataColumn Margin = new DataColumn(); // net amount
Margin.DataType = System.Type.GetType("System.Decimal");
Margin.ColumnName = "MARGIN";
Margin.DefaultValue = 0;
DataForReport.Columns.Add(Margin);

//make number the primary key in the table

DataColumn[] DataForReportKey = new DataColumn[1];
DataForReportKey[0] = DataForReport.Columns["NUMBER"];
DataForReport.PrimaryKey = DataForReportKey;

DataRow row;
row = DataForReport.NewRow();
for (int cnt = 0; cnt <= foundRows.GetUpperBound(0); cnt++)
{
string number = Convert.ToString(foundRows[cnt].ItemArray[10]);
string caption = Convert.ToString(foundRows[cnt].ItemArray[9]);
Decimal quantity = Convert.ToDecimal(foundRows[cnt].ItemArray[11]);
Decimal sales = Convert.ToDecimal(foundRows[cnt].ItemArray[12]);
Decimal discount = Convert.ToDecimal(foundRows[cnt].ItemArray[21]);
Decimal net = sales-discount;
Decimal cost = Convert.ToDecimal(foundRows[cnt].ItemArray[20]);
Decimal margin = net - cost;

DataRow rowfind = DataForReport.Rows.Find(number);
//does the table already contain the same?
if (rowfind == null)
{
//if not then add the record to the table
DataForReport.Rows.Add(number, caption, quantity, sales, discount, net, cost,margin);
}
else
{
//if the record exists then add the sales counters and store the new values
Int32 index = Convert.ToInt32(number) - 1;
DataForReport.Rows[index]["quantity"]
= quantity + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[2]));
DataForReport.Rows[index]["sales"]
= sales + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[3]));
DataForReport.Rows[index]["discount"]
= discount + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[4]));
DataForReport.Rows[index]["net"]
= net + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[5]));
DataForReport.Rows[index]["cost"]
= cost + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[6]));
DataForReport.Rows[index]["margin"]
= margin + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[7]));
}
}
return DataForReport.Rows.Count; //return the number of records

now I want the reportviewer to display the data as stored in the datatable DataForReports. How can I accomplish that?

hope someone can help me out

rgds

Frank
QuestionHow can i rename a file?? Pin
Test27030727-Mar-07 4:10
Test27030727-Mar-07 4:10 
AnswerRe: How can i rename a file?? Pin
Martin#27-Mar-07 4:19
Martin#27-Mar-07 4:19 
QuestionEvent and EventHandler for communication required Pin
Starzfighter27-Mar-07 3:56
Starzfighter27-Mar-07 3:56 
AnswerRe: Event and EventHandler for communication required Pin
Not Active27-Mar-07 5:21
mentorNot Active27-Mar-07 5:21 
QuestionPassing Recordset from C# COM to VBScript Pin
rahvyn627-Mar-07 3:49
rahvyn627-Mar-07 3:49 
Questionend (break) Pin
SVb.net27-Mar-07 3:46
SVb.net27-Mar-07 3:46 
AnswerRe: end (break) Pin
Christian Graus27-Mar-07 3:48
protectorChristian Graus27-Mar-07 3:48 
GeneralI rarely say this Pin
Ennis Ray Lynch, Jr.27-Mar-07 5:13
Ennis Ray Lynch, Jr.27-Mar-07 5:13 
GeneralRe: end (break) Pin
SVb.net28-Mar-07 6:38
SVb.net28-Mar-07 6:38 
QuestionHow could i dispose a windows form. Pin
Test27030727-Mar-07 3:40
Test27030727-Mar-07 3:40 
AnswerRe: How could i dispose a windows form. Pin
Martin#27-Mar-07 3:44
Martin#27-Mar-07 3:44 
GeneralRe: How could i dispose a windows form. Pin
Test27030727-Mar-07 3:53
Test27030727-Mar-07 3:53 
AnswerRe: How could i dispose a windows form. Pin
Christian Graus27-Mar-07 3:48
protectorChristian Graus27-Mar-07 3:48 
GeneralRe: How could i dispose a windows form. Pin
Test27030727-Mar-07 4:06
Test27030727-Mar-07 4:06 
GeneralRe: How could i dispose a windows form. Pin
Christian Graus27-Mar-07 4:23
protectorChristian Graus27-Mar-07 4:23 
GeneralSending UDP packets Pin
V.27-Mar-07 3:40
professionalV.27-Mar-07 3:40 
QuestionWindows Forms Pin
7127-Mar-07 3:22
7127-Mar-07 3:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.