Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi all, for hrm project i'm working on web based timesheet. I'm able to create daily basis timesheet(
employeeid, projectid, hours, totaltime(entry date + hours ), weeknumber
), and also able to show weekly timesheet(filtered by select week) with features: editable row wise, grouping.
 
Now my client requirement is to fill timesheet on week bases(not daily). Same as the exel timesheets. add new row for diffeernt project just like(pivot table)
Project Name | Monday | Tuesday |... | Sunday 
Sample1          6         2
Sample2          2         8
...             ...       ...
Hours are bounded to textbox.
 
Thanks in advance
 
P.S. sorry for grammer mistakes.
Posted 5-Oct-12 0:07am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hey i m working on same...i also implemented it .i m giving u my code accrding u change ur query n also code..
 public void calculateWeek()
    {
        try
        {
            DateTime date = Convert.ToDateTime(txtenddate2.Text);
            DateTime startDate = date;
            DateTime lastdate = DateTime.Now;
            DateTime endDate = startDate.AddMonths(1).AddDays(-1);
            int i = 0;
            for (DateTime result = startDate; result <= endDate; result = lastdate.AddDays(1))
            {
                if (result.Day != 31)
                {
                    weeks[i, 0] = result.ToString();
                    if (result.AddDays(14) >= endDate)
                    {
                        weeks[i, 1] = endDate.ToString();
                        lastdate = result.AddDays(14);
                    }
                    else
                    {
                        weeks[i, 1] = result.AddDays(14).ToString();
                        lastdate = result.AddDays(14);
                    }
                }
                else
                {
                    weeks[i - 1, 1] = result.ToString();
                    lastdate = result.AddDays(14);
                }
                i++;
 
            }
 
            if (weeks.Length > 0)
            {
                Session["frt_1"] = Convert.ToDateTime(weeks[0, 0].ToString());
                Session["frt_2"] = Convert.ToDateTime(weeks[0, 1].ToString());
                Session["frt_3"] = Convert.ToDateTime(weeks[1, 0].ToString());
                Session["frt_4"] = Convert.ToDateTime(weeks[1, 1].ToString());
            }
 
        }
        catch (Exception ex)
        {
 
        }
    }
//Response.Redirect("~/report1.aspx?dt=" + date + "&job=" + DropJob.SelectedValue + "&comp=" + ViewState["compid"].ToString() + "&pagename=WeekwiseJob");
                string str = "select s.StaffName,isnull(t.HourlyCharges,0) as HourlyCharges,isnull(sum(convert(float,TotalTime)),0)as TotalTime, " +
                " isnull((isnull(sum(convert(float,TotalTime)),0)* t.HourlyCharges),0)as Charges,isnull(sum(OpeAmt),0)as OpeAmt,dbo.TotalTime(isnull(sum(convert(float,TotalTime)),0)) as mints,convert(varchar(50),dbo.TotalTime(isnull(sum(convert(float,TotalTime)),0))/60) + '.' + convert(varchar(50),dbo.TotalTime(isnull(sum(convert(float,TotalTime)),0))%60) as timet " +
                " from   dbo.Staff_Master as s right join dbo.Job_Staff_Table as j on s.StaffCode=j.StaffCode " +
                " left join  dbo.TimeSheet_Table as t on  t.JobId=j.JobId and t.StaffCode=j.StaffCode  and  t.Date>='" + Convert.ToDateTime(weeks[0, 0].ToString()) + "' " +
                " and t.Date <='" + Convert.ToDateTime(weeks[1, 1].ToString()) + "' where  j.JobId='" + DropJob.SelectedValue + "' and t.CLTId='" + DropClient.SelectedValue + "' group by s.StaffName,t.HourlyCharges";
                DataTable dt = db.GetDataTable(str);
 

 
  Permalink  
Comments
sysandeepkumar at 5-Oct-12 8:41am
   
if you are working on same kind of project.. then can we share code via team viewer..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

thanks for reply...
Calculating week isn't a problem... I'm able to fetch data according to week by parameter
@WeekStartDate and @WeekEndDate or @Weeknumber
..
select * from (select e.AccountProjectId, dbo.GetWeekDayNameOfDate(e.totaltime) as weekd, e.Hours from AccountEmployeeTimeEntry e where CONVERT(date, StartTime)= @start and CONVERT(date, EndTime)=@end and AccountEmployeeId =@AccountEmployeeId) P pivot (
dbo.sumFunction(hours) for weekd in([Monday], [Tuesday], [Wednesday], [thursday], [Friday], [Saturday], [Sunday] ) ) as pvt 
 
i want to insert and update in weekly format(not in daily format) ... please provide info regarding insert n update in week format
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100