Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
GeneralRe: Daylight saving end day Extra hour handling Pin
emiaj23-Jan-08 13:07
emiaj23-Jan-08 13:07 
GeneralRe: Daylight saving end day Extra hour handling Pin
PIEBALDconsult23-Jan-08 14:24
mvePIEBALDconsult23-Jan-08 14:24 
GeneralSending Error Message Pin
emiaj23-Jan-08 10:39
emiaj23-Jan-08 10:39 
GeneralTelnetting in C# Pin
Michael Fritzius23-Jan-08 10:31
professionalMichael Fritzius23-Jan-08 10:31 
Generalchange in dataset Pin
mehrdadov23-Jan-08 9:45
mehrdadov23-Jan-08 9:45 
AnswerRe: change in dataset Pin
Vikram A Punathambekar23-Jan-08 17:38
Vikram A Punathambekar23-Jan-08 17:38 
Questionhow to pick some records in datagrid ? Pin
E_Gold23-Jan-08 9:28
E_Gold23-Jan-08 9:28 
GeneralCorrectly Dispalying Data [modified] Pin
Skanless23-Jan-08 9:18
Skanless23-Jan-08 9:18 
Hi Guys, I've been trying for quite sometime to accomplish this task but now I am at my wits end so I turn to you "the professionals" for assistance. My problem is as follows: I have a method which executes a stored procedure with two select queries which return two tables of data which is rans accross the several databses to view individual store performace. This data is then available to the application in a data set. The first table (table[0]) returns the transactions details (i.e. ProductID, ProductName, Cost, Sales date) while the second table(table [1]) returns a summary of each stores sales activity. What I am hoping to is display the "Details"(Table[0]) the below those records display the summary of the stores activity. However, this query is ran over several databse (one per store) thus when the dataset is returned information for all the stores are in there hence it looks something like this:
Table[0]
StoreID   StoreName    Product     TotalSold  TotalIncome
0015      Joe's Store  SomeBeer     1000      $10,0000
0016      Mike's Store FoodItem     500       $2500
0017      Mary's Store Clothing     500       $2500

and so on...

Table[1]

StoreID   ProductName   Unitcost   UnitSold   Total

0015       SomeBeer1    $10.00      50        500.00
0015       SomeBeer2    $8.00       50        400.00
0015       SomeBeer3    $10.00      50        500.00
0015       SomeBeer4    $10.00      50        500.00
0016       SomeBeer1    $10.00      50        500.00
0016       SomeBeer2    $8.00       50        400.00
0016       SomeBeer3    $10.00      50        500.00
0016       SomeBeer4    $10.00      50        500.00
0017       SomeBeer1    $10.00      50        500.00
0017       SomeBeer2    $8.00       50        400.00
0017       SomeBeer3    $10.00      50        500.00
0017       SomeBeer4    $10.00      50        500.00
and so on....

What I need is:

Store 15
StoreID   ProductName   Unitcost   UnitSold   Total

0015       SomeBeer1    $10.00      50        500.00
0015       SomeBeer2    $8.00       50        400.00
0015       SomeBeer3    $10.00      50        500.00
0015       SomeBeer4    $10.00      50        500.00

StoreID   StoreName    Product     TotalSold  TotalIncome

0015      Joe's Store  SomeBeer     1000      $10,0000

Store 16
StoreID   ProductName   Unitcost   UnitSold   Total
0016       SomeBeer1    $10.00      50        500.00
0016       SomeBeer2    $8.00       50        400.00
0016       SomeBeer3    $10.00      50        500.00
0016       SomeBeer4    $10.00      50        500.00
StoreID   StoreName    Product     TotalSold  TotalIncome
0016      Mike's Store FoodItem     500       $2500


Store 17
StoreID   ProductName   Unitcost   UnitSold   Total
0017       SomeBeer1    $10.00      50        500.00
0017       SomeBeer2    $8.00       50        400.00
0017       SomeBeer3    $10.00      50        500.00
0017       SomeBeer4    $10.00      50        500.00
StoreID   StoreName    Product     TotalSold  TotalIncome
0017      Mary's Store Clothing     500       $2500


Here is the code that I am using to try to accomplish this:

public Table GetInfoTable(DataSet MyDS)
        {

            Table DisplayTable = new Table();

            
           
            try
            {


                 foreach (DataTable CurrentTable in MyDS.Tables)
                    {


                        foreach (DataRow CurrentRow1 in CurrentTable.Rows)
                        {
                            TableRow DisplayRow1 = new TableRow();
                            DisplayTable.Rows.Add(DisplayRow1);
                            foreach (DataColumn CurrentColumn1 in CurrentTable.Columns)
                            {
                                TableCell DisplayCell1 = new TableCell();
                                DisplayRow1.Cells.Add(DisplayCell1);
                                DisplayCell1.Text += CurrentColumn1.Caption;

                                foreach (DataRow CurrentRow in CurrentTable.Rows)
                                {
                                    TableRow DisplayRow = new TableRow();
                                    DisplayTable.Rows.Add(DisplayRow);

                                    string currentTableFIName = DisplayTable.Rows[0].ToString();

                                    foreach (DataColumn CurrentColumn in CurrentTable.Columns)
                                    {
                                        TableCell DisplayCell = new TableCell();
                                        DisplayRow.Cells.Add(DisplayCell);
                                        if (CurrentRow[CurrentColumn] != null)

                                            if (CurrentRow[CurrentColumn] != DBNull.Value)
                                            {
                                                DisplayCell.Text += CurrentRow[CurrentColumn].ToString();

                                            }
                                            else
                                            {

                                                DisplayCell.Text += string.Empty;
                                            }
                                    }
                                }
                            }
                        }
                    }
                }
                            
                

           catch
            {

           }

           this.DisplayTableDate = DisplayTable;

            
           return displayTable;
            
            
        }


Skan

If you knew it would not compile why didn't you tell me?!?!?!

modified on Wednesday, January 23, 2008 4:38:31 PM

GeneralRe: Correctly Dispalying Data Pin
pmarfleet23-Jan-08 10:45
pmarfleet23-Jan-08 10:45 
GeneralRe: Correctly Dispalying Data Pin
Skanless23-Jan-08 10:56
Skanless23-Jan-08 10:56 
Generalupdating parent form from child object Pin
shwaguy23-Jan-08 8:54
shwaguy23-Jan-08 8:54 
GeneralRe: updating parent form from child object Pin
Sean Michael Murphy23-Jan-08 9:17
Sean Michael Murphy23-Jan-08 9:17 
GeneralRe: updating parent form from child object Pin
shwaguy24-Jan-08 3:23
shwaguy24-Jan-08 3:23 
General[Message Deleted] Pin
Tahir Abbasi23-Jan-08 8:15
Tahir Abbasi23-Jan-08 8:15 
GeneralRe: how to block an ip address Pin
led mike23-Jan-08 8:25
led mike23-Jan-08 8:25 
GeneralI need to Create a Quiz Program. Pin
Alex50123-Jan-08 7:41
Alex50123-Jan-08 7:41 
GeneralRe: I need to Create a Quiz Program. Pin
Giorgi Dalakishvili23-Jan-08 7:52
mentorGiorgi Dalakishvili23-Jan-08 7:52 
GeneralRe: I need to Create a Quiz Program. Pin
Thomas Stockwell23-Jan-08 8:02
professionalThomas Stockwell23-Jan-08 8:02 
GeneralRe: I need to Create a Quiz Program. Pin
#realJSOP23-Jan-08 8:03
mve#realJSOP23-Jan-08 8:03 
GeneralRe: I need to Create a Quiz Program. Pin
Wes Aday23-Jan-08 9:18
professionalWes Aday23-Jan-08 9:18 
GeneralRe: I need to Create a Quiz Program. Pin
pmarfleet23-Jan-08 10:48
pmarfleet23-Jan-08 10:48 
GeneralRe: I need to Create a Quiz Program. Pin
Pete O'Hanlon23-Jan-08 11:15
mvePete O'Hanlon23-Jan-08 11:15 
Generaldll reference Pin
Peterson Luiz23-Jan-08 7:27
Peterson Luiz23-Jan-08 7:27 
GeneralRe: dll reference Pin
engsrini23-Jan-08 8:24
engsrini23-Jan-08 8:24 
GeneralRe: dll reference Pin
Peterson Luiz24-Jan-08 8:17
Peterson Luiz24-Jan-08 8:17 

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.