/// <summary> /// Deprecated Method for adding a new object to the ClientWeeks EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToClientWeeks(ClientWeek clientWeek) { base.AddObject("ClientWeeks", clientWeek); }
/// <summary> /// Create a new ClientWeek object. /// </summary> /// <param name="clientWeekId">Initial value of the ClientWeekId property.</param> /// <param name="clientWeekGuid">Initial value of the ClientWeekGuid property.</param> /// <param name="weekId">Initial value of the WeekId property.</param> /// <param name="clientId">Initial value of the ClientId property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="dateModified">Initial value of the DateModified property.</param> /// <param name="createdBy">Initial value of the CreatedBy property.</param> /// <param name="modifiedBy">Initial value of the ModifiedBy property.</param> /// <param name="clientApproved">Initial value of the ClientApproved property.</param> /// <param name="approved">Initial value of the Approved property.</param> public static ClientWeek CreateClientWeek(global::System.Int32 clientWeekId, global::System.Guid clientWeekGuid, global::System.Int32 weekId, global::System.Int32 clientId, global::System.DateTime dateCreated, global::System.DateTime dateModified, global::System.String createdBy, global::System.String modifiedBy, global::System.Boolean clientApproved, global::System.Boolean approved) { ClientWeek clientWeek = new ClientWeek(); clientWeek.ClientWeekId = clientWeekId; clientWeek.ClientWeekGuid = clientWeekGuid; clientWeek.WeekId = weekId; clientWeek.ClientId = clientId; clientWeek.DateCreated = dateCreated; clientWeek.DateModified = dateModified; clientWeek.CreatedBy = createdBy; clientWeek.ModifiedBy = modifiedBy; clientWeek.ClientApproved = clientApproved; clientWeek.Approved = approved; return clientWeek; }
private void setupStudent(string studentGuid,ClientWeek clientWeek) { Guid g = Guid.Parse(studentGuid); Student s = t.Students.Single(f => f.StudentGuid == g); litEmployeeName.Text = string.Format("{0}, {1}", s.LastName, s.FirstName); hidEmployeeID.Value = s.StudentId.ToString(); tdEmployeeSearch.Visible = false; tdEmployeeSelected.Visible = true; List<Time> studentWeek = t.Times.Where(f=>f.StudentId==s.StudentId&&f.ClientWeekId==clientWeek.ClientWeekId).ToList<Time>(); if(studentWeek.Count>0) { tbHoursMonday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==1)).HoursWorked.ToString(); tbHoursTuesday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==2)).HoursWorked.ToString(); tbHoursWednesday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==3)).HoursWorked.ToString(); tbHoursThursday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==4)).HoursWorked.ToString(); tbHoursFriday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==5)).HoursWorked.ToString(); tbHoursSaturday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==6)).HoursWorked.ToString(); tbHoursSunday.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==7)).HoursWorked.ToString(); tbPayRate.Text=(studentWeek.SingleOrDefault(f=>f.DayOfWeek==1)).PayRate.ToString(); } }
private void setupSummary(ClientWeek cw) { litHeaderMonday.Text = cw.Week.WeekEnding.AddDays(-6).ToString("MM/dd"); litHeaderTuesday.Text = cw.Week.WeekEnding.AddDays(-5).ToString("MM/dd"); litHeaderWednesday.Text = cw.Week.WeekEnding.AddDays(-4).ToString("MM/dd"); litHeaderThursday.Text = cw.Week.WeekEnding.AddDays(-3).ToString("MM/dd"); litHeaderFriday.Text = cw.Week.WeekEnding.AddDays(-2).ToString("MM/dd"); litHeaderSaturday.Text = cw.Week.WeekEnding.AddDays(-1).ToString("MM/dd"); litHeaderSunday.Text = cw.Week.WeekEnding.ToString("MM/dd"); List<Result> dataset = new List<Result>(); var stuff = from stu in t.Students join mon in t.Times on new { key1 = stu.StudentId, key2 = 1, key3 = cw.ClientWeekId } equals new { key1 = mon.StudentId, key2 = mon.DayOfWeek.Value, key3 = mon.ClientWeekId } join tue in t.Times on new { key1 = stu.StudentId, key2 = 2, key3 = cw.ClientWeekId } equals new { key1 = tue.StudentId, key2 = tue.DayOfWeek.Value, key3 = tue.ClientWeekId } join wed in t.Times on new { key1 = stu.StudentId, key2 = 3, key3 = cw.ClientWeekId } equals new { key1 = wed.StudentId, key2 = wed.DayOfWeek.Value, key3 = wed.ClientWeekId } join thur in t.Times on new { key1 = stu.StudentId, key2 = 4, key3 = cw.ClientWeekId } equals new { key1 = thur.StudentId, key2 = thur.DayOfWeek.Value, key3 = thur.ClientWeekId } join fri in t.Times on new { key1 = stu.StudentId, key2 = 5, key3 = cw.ClientWeekId } equals new { key1 = fri.StudentId, key2 = fri.DayOfWeek.Value, key3 = fri.ClientWeekId } join sat in t.Times on new { key1 = stu.StudentId, key2 = 6, key3 = cw.ClientWeekId } equals new { key1 = sat.StudentId, key2 = sat.DayOfWeek.Value, key3 = sat.ClientWeekId } join sun in t.Times on new { key1 = stu.StudentId, key2 = 7, key3 = cw.ClientWeekId } equals new { key1 = sun.StudentId, key2 = sun.DayOfWeek.Value, key3 = sun.ClientWeekId } select new {stu.StudentId, stu.StudentGuid, stu.LastName, stu.FirstName, stu.LastFour, mon.PayRate, monday = mon.HoursWorked, tuesday = tue.HoursWorked, wednesday = wed.HoursWorked, thursday = thur.HoursWorked, friday = fri.HoursWorked, saturday = sat.HoursWorked, sunday = sun.HoursWorked}; foreach (var s in stuff) dataset.Add(new Result(s.StudentId, cw.ClientWeekId, s.StudentGuid, string.Format("{0}, {1}",s.LastName,s.FirstName), s.LastFour, s.PayRate, s.monday, s.tuesday, s.wednesday, s.thursday, s.friday, s.saturday, s.sunday)); rptTimeSheet.DataSource = dataset.OrderBy(f=>f.EmployeeName); rptTimeSheet.DataBind(); }
private void setupClientWeek(Client cl, Week wk) { cw = t.ClientWeeks.SingleOrDefault(f => f.ClientId == cl.ClientId && f.WeekId == wk.WeekId); if (cw == default(ClientWeek)) { cw = new ClientWeek(); cw.ClientId = cl.ClientId; cw.WeekId = wk.WeekId; cw.CreatedBy = "davide"; cw.ModifiedBy = "davide"; cw.DateModified = DateTime.Now; cw.DateCreated = DateTime.Now; cw.ClientWeekGuid = Guid.NewGuid(); t.ClientWeeks.AddObject(cw); } setupClientWeek(cw, false); }
private void setupClientWeek(ClientWeek cw, bool checkStudent) { foreach (ListItem li in ddlClients.Items) if (li.Value == cw.ClientId.ToString()) li.Selected = true; litClientName.Text = cw.Client.ClientName; hidClientID.Value = cw.ClientId.ToString(); tdClientSearch.Visible = false; tdClientSelected.Visible = true; tbWeekEnding.Text = cw.Week.WeekEnding.ToString("MM/dd/yyyy"); setupSummary(cw); if (Request.QueryString.AllKeys.Contains("Student")) setupStudent(Request.QueryString["Student"], cw); }
private void removeOldTimes(int employeeId, ClientWeek clientWeek) { List<Time> forDeletion = t.Times.Where(f => f.StudentId == employeeId && f.ClientWeekId == clientWeek.ClientWeekId).ToList<Time>(); foreach (var del in forDeletion) t.DeleteObject(del); }
protected void Page_Load(object sender, EventArgs e) { t = new TugboatDBEntities(); if (Request.QueryString.AllKeys.Contains("ClientWeek")) { Guid g = Guid.Parse(Request.QueryString["ClientWeek"]); cw = t.ClientWeeks.Single(f => f.ClientWeekGuid == g); } else cw = new ClientWeek(); if (!Page.IsPostBack) { initClients(); initWeek(); initSearch(); if (Request.QueryString.AllKeys.Contains("ClientWeek")) setupClientWeek(cw,true); } }
protected void btnSave_Click(object sender, EventArgs e) { DateTime weekEnding = DateTime.Parse(tbWeekEnding.Text); int studentId = int.Parse(hidEmployeeID.Value); int clientId = int.Parse(hidClientID.Value); Client cl; Week wk; if (cw.ClientId != clientId) { cl = t.Clients.Single(f => f.ClientId == clientId); wk = setupWeek(weekEnding); setupClientWeek(cl, wk); removeOldTimes(studentId, cw); } else if (Request.QueryString.AllKeys.Contains("ClientWeek")) { Guid cwGuid = Guid.Parse(Request.QueryString["ClientWeek"]); cw = t.ClientWeeks.Single(f => f.ClientWeekGuid == cwGuid); cl = cw.Client; wk = cw.Week; } else { wk = setupWeek(weekEnding); int selectedClientId = int.Parse(hidClientID.Value); cl = t.Clients.Single(f => f.ClientId == selectedClientId); setupClientWeek(cl, wk); } decimal payRate = 0.0m; decimal.TryParse(tbPayRate.Text, out payRate); Time mon = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 1); if (mon == default(Time)) { mon = new Time(); mon.ClientWeekId = cw.ClientWeekId; mon.CreatedBy = "davide"; mon.ModifiedBy = "davide"; mon.DateModified = DateTime.Now; mon.DateCreated = DateTime.Now; mon.StudentId = studentId; mon.TimeDate = weekEnding.AddDays(-6); mon.DayOfWeek = 1; mon.TimeGuid = Guid.NewGuid(); t.Times.AddObject(mon); } decimal hoursMonday = 0.0m; decimal.TryParse(tbHoursMonday.Text, out hoursMonday); mon.HoursWorked = hoursMonday; mon.PayRate = payRate; Time tue = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 2); if (tue == default(Time)) { tue = new Time(); tue.ClientWeekId = cw.ClientWeekId; tue.CreatedBy = "davide"; tue.ModifiedBy = "davide"; tue.DateModified = DateTime.Now; tue.DateCreated = DateTime.Now; tue.StudentId = studentId; tue.TimeDate = weekEnding.AddDays(-5); tue.DayOfWeek = 2; tue.TimeGuid = Guid.NewGuid(); t.Times.AddObject(tue); } decimal hoursTuesday = 0.0m; decimal.TryParse(tbHoursTuesday.Text, out hoursTuesday); tue.HoursWorked = hoursTuesday; tue.PayRate = payRate; Time wed = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 3); if (wed == default(Time)) { wed = new Time(); wed.ClientWeekId = cw.ClientWeekId; wed.CreatedBy = "davide"; wed.ModifiedBy = "davide"; wed.DateModified = DateTime.Now; wed.DateCreated = DateTime.Now; wed.StudentId = studentId; wed.TimeDate = weekEnding.AddDays(-4); wed.DayOfWeek = 3; wed.TimeGuid = Guid.NewGuid(); t.Times.AddObject(wed); } decimal hoursWednesday = 0.0m; decimal.TryParse(tbHoursWednesday.Text, out hoursWednesday); wed.HoursWorked = hoursWednesday; wed.PayRate = payRate; Time thur = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 4); if (thur == default(Time)) { thur = new Time(); thur.ClientWeekId = cw.ClientWeekId; thur.CreatedBy = "davide"; thur.ModifiedBy = "davide"; thur.DateModified = DateTime.Now; thur.DateCreated = DateTime.Now; thur.StudentId = studentId; thur.TimeDate = weekEnding.AddDays(-3); thur.DayOfWeek = 4; thur.TimeGuid = Guid.NewGuid(); t.Times.AddObject(thur); } decimal hoursThursday = 0.0m; decimal.TryParse(tbHoursThursday.Text, out hoursThursday); thur.HoursWorked = hoursThursday; thur.PayRate = payRate; Time fri = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 5); if (fri == default(Time)) { fri = new Time(); fri.ClientWeekId = cw.ClientWeekId; fri.CreatedBy = "davide"; fri.ModifiedBy = "davide"; fri.DateModified = DateTime.Now; fri.DateCreated = DateTime.Now; fri.StudentId = studentId; fri.TimeDate = weekEnding.AddDays(-2); fri.DayOfWeek = 5; fri.TimeGuid = Guid.NewGuid(); t.Times.AddObject(fri); } decimal hoursFriday = 0.0m; decimal.TryParse(tbHoursFriday.Text, out hoursFriday); fri.HoursWorked = hoursFriday; fri.PayRate = payRate; Time sat = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 6); if (sat == default(Time)) { sat = new Time(); sat.ClientWeekId = cw.ClientWeekId; sat.CreatedBy = "davide"; sat.ModifiedBy = "davide"; sat.DateModified = DateTime.Now; sat.DateCreated = DateTime.Now; sat.StudentId = studentId; sat.TimeDate = weekEnding.AddDays(-1); sat.DayOfWeek = 6; sat.TimeGuid = Guid.NewGuid(); t.Times.AddObject(sat); } decimal hoursSaturday = 0.0m; decimal.TryParse(tbHoursSaturday.Text, out hoursSaturday); sat.HoursWorked = hoursSaturday; sat.PayRate = payRate; Time sun = t.Times.SingleOrDefault(f => f.ClientWeekId == cw.ClientWeekId && f.StudentId == studentId && f.DayOfWeek == 7); if (sun == default(Time)) { sun = new Time(); sun.ClientWeekId = cw.ClientWeekId; sun.CreatedBy = "davide"; sun.ModifiedBy = "davide"; sun.DateModified = DateTime.Now; sun.DateCreated = DateTime.Now; sun.StudentId = studentId; sun.TimeDate = weekEnding; sun.DayOfWeek = 7; sun.TimeGuid = Guid.NewGuid(); t.Times.AddObject(sun); } decimal hoursSunday = 0.0m; decimal.TryParse(tbHoursSunday.Text, out hoursSunday); sun.HoursWorked = hoursSunday; sun.PayRate = payRate; t.SaveChanges(); initSearch(); initTimes(); Response.Redirect(string.Format("TimeSheetEntry.aspx?ClientWeek={0}", cw.ClientWeekGuid),false); }