Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Error Handling Pin
Tom Deketelaere21-Jul-09 22:38
professionalTom Deketelaere21-Jul-09 22:38 
AnswerRe: Error Handling Pin
Vimalsoft(Pty) Ltd22-Jul-09 0:06
professionalVimalsoft(Pty) Ltd22-Jul-09 0:06 
AnswerRe: Error Handling Pin
Luc Pattyn22-Jul-09 1:27
sitebuilderLuc Pattyn22-Jul-09 1:27 
QuestionBeep Duration Pin
gwithey21-Jul-09 22:22
gwithey21-Jul-09 22:22 
AnswerRe: Beep Duration Pin
Nagy Vilmos21-Jul-09 23:17
professionalNagy Vilmos21-Jul-09 23:17 
GeneralRe: Beep Duration Pin
gwithey21-Jul-09 23:53
gwithey21-Jul-09 23:53 
AnswerRe: Beep Duration Pin
Luc Pattyn22-Jul-09 1:28
sitebuilderLuc Pattyn22-Jul-09 1:28 
QuestionTotal Sum Value of columns as header row by ID in gridview Pin
vanillaET21-Jul-09 21:56
vanillaET21-Jul-09 21:56 
The GridView columns are as follow:
      <Columns>
                        <asp:BoundField HeaderText="ID No." DataField="NRIC" />
                        <asp:BoundField HeaderText="Name" DataField="LabourName" />
                        <asp:BoundField HeaderText="Event Name/Duty Roster" DataField="EventName/DutyRoster" />
                        <asp:BoundField HeaderText="Working Date" DataField="WorkingDate" />
                        <asp:BoundField HeaderText="Normal(hr)" DataField="NormalHour" />
                        <asp:BoundField HeaderText="Amt(N)" DataField="NormalRate" />
                        <asp:BoundField HeaderText="Extra(hr)" DataField="ExtraHour" />
                        <asp:BoundField HeaderText="Amt(E)" DataField="ExtraRate" />
                        <asp:BoundField HeaderText="Weekend(hr)" DataField="WeekEndHour" />
                        <asp:BoundField HeaderText="Amt(W)" DataField="WeekEndRate" />
                        <asp:BoundField HeaderText="Holiday(hr)" DataField="HolidayHour" />
                        <asp:BoundField HeaderText="Amt(H)" DataField="HolidayRate" />
                        <asp:BoundField HeaderText="Allowance" DataField="Allowance" />
                        <asp:BoundField HeaderText="Total $" DataField="Total" />
                        <asp:BoundField DataField="Type" HeaderText="Type" Visible="False" />
                  </Columns>

The result must be:
------------|-------|---------------|-----------------|--------------|--------|---|------
LabourID|Name|Event Name|Working Date|Normal(Hr)|Amt(N)|...|Total
------------|-------|---------------|-----------------|--------------|--------|---|------
009         |ET      | All            | All                  | 5            | 35.0 |...|95.0
------------|-------|---------------|-----------------|--------------|--------|---|------
               |         | Meeting      | 10 Jul 09      | 2            | 20.0 |...|60.0
------------|-------|---------------|-----------------|--------------|--------|---|------
               |         | Seminar      | 13 Jul 09      | 3            | 15.0 |...|35.0
------------|-------|---------------|-----------------|--------------|--------|---|------
002         |Sue   | All            | All                  | 6               | 18.0 |...|40.0
------------|-------|---------------|-----------------|--------------|--------|---|------
               |         | Promotion | 23 Jul 09      | 6            | 18.0 |...|40.0
------------|-------|---------------|-----------------|--------------|--------|---|------


I'm writing the code as follow:

void GetDataTable(DataTable tempDT)
            {
                  DataTable dt_FromDB = tempDT;
                  DataTable dt_Grid = Grid_Table;
      //         DataRow adr = new DataRow();
     
                  decimal nHour=0;
                  decimal nRate=0;
                  decimal eHour=0;
                  decimal eRate=0;
                  decimal hHour=0;
                  decimal hRate=0;
                  decimal wHour=0;
                  decimal wRate=0;
                  decimal allow=0;
                  decimal total=0;
     
                  string labourNRIC = "";
                  string checkLabourNRIC = "";
                 
     
                  foreach (DataRow dr_FromDB in dt_FromDB.Rows)
                  {
                        //string NRIC=dr_FromDB["NRIC"].ToString();
                        //while(dt_FromDB.Select("NRIC="+NRIC))
                        //{
                        if(dr_FromDB["NRIC"].ToString()==labourNRIC || labourNRIC=="")
                        {
                              nHour += Convert.ToDecimal(dr_FromDB["NormalHour"].ToString());
                              nRate += Convert.ToDecimal(dr_FromDB["NormalRate"].ToString());
                              eHour += Convert.ToDecimal(dr_FromDB["ExtraHour"].ToString());
                              eRate += Convert.ToDecimal(dr_FromDB["ExtraRate"].ToString());
                              hHour += Convert.ToDecimal(dr_FromDB["HolidayHour"].ToString());
                              hRate += Convert.ToDecimal(dr_FromDB["HolidayRate"].ToString());
                              wHour += Convert.ToDecimal(dr_FromDB["WeekEndHour"].ToString());
                              wRate += Convert.ToDecimal(dr_FromDB["WeekEndRate"].ToString());
                              allow += Convert.ToDecimal(dr_FromDB["Allowance"].ToString());
                              total += Convert.ToDecimal(dr_FromDB["Total"].ToString());
                        }
     
                        if (dr_FromDB["NRIC"].ToString() != checkLabourNRIC)
                        {
                              labourNRIC = dr_FromDB["NRIC"].ToString();
     
                              DataRow dr_Grid = dt_Grid.NewRow();
                              dr_Grid["NRIC"] = dr_FromDB["NRIC"].ToString();
                              dr_Grid["LabourName"] = dr_FromDB["LabourName"].ToString();
                              dr_Grid["EventNameOrDutyRoster"] = "All";
                              dr_Grid["WorkingDate"] = "All";
                              dr_Grid["NormalHour"] = nHour;
                              dr_Grid["NormalRate"] = nRate;
                              dr_Grid["ExtraHour"] = eHour;
                              dr_Grid["ExtraRate"] = eRate;
                              dr_Grid["HolidayHour"] = hHour;
                              dr_Grid["HolidayRate"] = hRate;
                              dr_Grid["WeekEndHour"] = wHour;
                              dr_Grid["WeekEndRate"] = wRate;
                              dr_Grid["Allowance"] = allow;
                              dr_Grid["Total"] = total;
                              dt_Grid.Rows.Add(dr_Grid);
                              ViewState["Grid"] = dt_Grid;
                        }
     
                        if (dr_FromDB["NRIC"].ToString() == labourNRIC)
                        {
                              DataRow dr_Grid = dt_Grid.NewRow();
                              dr_Grid["EventNameOrDutyRoster"] = dr_FromDB["EventNameOrDutyRoster"].ToString();
                              dr_Grid["WorkingDate"] = dr_FromDB["WorkingDate"].ToString();
                              dr_Grid["NormalHour"] = dr_FromDB["NormalHour"].ToString();
                              dr_Grid["NormalRate"] = dr_FromDB["NormalRate"].ToString();
                              dr_Grid["ExtraHour"] = dr_FromDB["ExtraHour"].ToString();
                              dr_Grid["ExtraRate"] = dr_FromDB["ExtraRate"].ToString();
                              dr_Grid["HolidayHour"] = dr_FromDB["HolidayHour"].ToString();
                              dr_Grid["HolidayRate"] = dr_FromDB["HolidayRate"].ToString();
                              dr_Grid["WeekEndHour"] = dr_FromDB["WeekEndHour"].ToString();
                              dr_Grid["WeekEndRate"] = dr_FromDB["WeekEndRate"].ToString();
                              dr_Grid["Allowance"] = dr_FromDB["Allowance"].ToString();
                              dr_Grid["Total"] = dr_FromDB["Total"].ToString();
                              dr_Grid["Type"] = dr_FromDB["Type"].ToString();
                              dt_Grid.Rows.Add(dr_Grid);
                              ViewState["Grid"] = dt_Grid;
     
                              checkLabourNRIC = labourNRIC;
                        }
     
                  }


*How shall I continue this code?
*Thanks for your help.

Su
AnswerRe: Total Sum Value of columns as header row by ID in gridview Pin
Nagy Vilmos21-Jul-09 22:12
professionalNagy Vilmos21-Jul-09 22:12 
GeneralRe: Total Sum Value of columns as header row by ID in gridview Pin
vanillaET22-Jul-09 0:30
vanillaET22-Jul-09 0:30 
GeneralRe: Total Sum Value of columns as header row by ID in gridview Pin
Nagy Vilmos22-Jul-09 1:32
professionalNagy Vilmos22-Jul-09 1:32 
GeneralRe: Total Sum Value of columns as header row by ID in gridview Pin
vanillaET22-Jul-09 23:10
vanillaET22-Jul-09 23:10 
QuestionNeed Guidance Pin
Mogamboo_Khush_Hua21-Jul-09 21:25
Mogamboo_Khush_Hua21-Jul-09 21:25 
AnswerRe: Need Guidance Pin
MumbleB22-Jul-09 0:20
MumbleB22-Jul-09 0:20 
QuestionHow to display table data in table format uzing zedgraph Pin
Nitin K21-Jul-09 20:55
Nitin K21-Jul-09 20:55 
AnswerRe: How to display table data in table format uzing zedgraph Pin
stancrm21-Jul-09 21:09
stancrm21-Jul-09 21:09 
GeneralRe: How to display table data in table format uzing zedgraph Pin
Nitin K21-Jul-09 23:46
Nitin K21-Jul-09 23:46 
GeneralRe: How to display table data in table format uzing zedgraph Pin
stancrm22-Jul-09 1:22
stancrm22-Jul-09 1:22 
QuestionSkip the Outlook Web Access login window Pin
mohanroy21-Jul-09 20:55
mohanroy21-Jul-09 20:55 
AnswerRe: Skip the Outlook Web Access login window Pin
Adam Maras21-Jul-09 21:07
Adam Maras21-Jul-09 21:07 
Questionconversion of webcam image in 16 bit Pin
shekhar25839521-Jul-09 20:49
shekhar25839521-Jul-09 20:49 
QuestionWOW! axWindowsMediaPlayer1 is a joke! Pin
AKC_pico21-Jul-09 20:39
AKC_pico21-Jul-09 20:39 
AnswerRe: WOW! axWindowsMediaPlayer1 is a joke! Pin
Christian Graus21-Jul-09 20:43
protectorChristian Graus21-Jul-09 20:43 
GeneralRe: WOW! axWindowsMediaPlayer1 is a joke! Pin
AKC_pico21-Jul-09 20:48
AKC_pico21-Jul-09 20:48 
GeneralRe: WOW! axWindowsMediaPlayer1 is a joke! Pin
Christian Graus21-Jul-09 21:21
protectorChristian Graus21-Jul-09 21:21 

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.