Lio Liov

Lio Liov

  • NA
  • 44
  • 6.2k

Problem with duplicated rows

Feb 12 2014 11:55 AM
I have this data





And I need to transfer it in this




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {

            DataTable dt = new DataTable();
            dt.Columns.Add("EmpID");
            dt.Columns.Add("fName");
            dt.Columns.Add("sName");
            dt.Columns.Add("WorkDay", typeof(DateTime));
            dt.Columns.Add("HoursWorked", typeof(decimal));
            // mix them up a bit
            dt.Rows.Add("Emp1", "First1", "Second1", "2014-02-06", 3.2);
            dt.Rows.Add("Emp2", "First2", "Second2", "2014-02-06", 3.4);
            dt.Rows.Add("Emp1", "First1", "Second1", "2014-02-07", 3.2);
            dt.Rows.Add("Emp2", "First2", "Second2", "2014-02-04", 3.2);
            dt.Rows.Add("Emp2", "First2", "Second2", "2014-02-03", 3.2);
            dt.Rows.Add("Emp1", "First1", "Second1", "2014-01-06", 3.2);


            DataTable dw = new DataTable();
            dw.Columns.Add("EmpID");

            dw.Columns.Add("Mon", typeof(decimal));
            dw.Columns.Add("Tue", typeof(decimal));
            dw.Columns.Add("Wed", typeof(decimal));
            dw.Columns.Add("Thu", typeof(decimal));
            dw.Columns.Add("Fri", typeof(decimal));
            dw.Columns.Add("Sat", typeof(decimal));
            dw.Columns.Add("Sun", typeof(decimal));

            DateTime inputDate = Convert.ToDateTime("2014-02-06");
            DateTime firstDayOfTheWeek = inputDate.AddDays(0 - (inputDate).DayOfWeek.GetHashCode());
           


        }
    }
}



Answers (32)