public void ProcessRequest(HttpContext context) { int eventID; if (int.TryParse(context.Request.Form["id"], out eventID)) { IEncrypt encrypt = UtilFactory.GetEncryptProvider(EncryptType.DES); string strUserID = encrypt.Decrypt(UtilFactory.Helpers.CookieHelper.Get(encrypt.Encrypt("LoginUserID"))); if (string.IsNullOrEmpty(strUserID)) { context.Response.Write("0"); } int userID = int.Parse(strUserID); EventEntity entity = new EventsApplication().GetEventInfo(eventID); if (entity == null || entity.CreatedBy != userID) { context.Response.Write("0"); } if (new EventsApplication().Delete(eventID, entity.FromDay.Date)) { context.Response.Write("1"); } else { context.Response.Write("0"); } } else { context.Response.Write("0"); } }
private void ProcessCalendar(HttpContext context) { int parsedInt; int?year = null; int?month = null; int projectID = -1; if (int.TryParse(context.Request.QueryString["year"], out parsedInt)) { year = parsedInt; } if (int.TryParse(context.Request.QueryString["month"], out parsedInt)) { month = parsedInt; } if (!string.IsNullOrEmpty(context.Request.QueryString["projectID"])) { projectID = int.Parse(context.Request.QueryString["projectID"]); } DateTime monthToDisplay; if (month == null && year == null) { monthToDisplay = DateTime.Now; } else { monthToDisplay = DateTime.Parse(month + "/" + "1" + "/" + year); } EventsApplication eventsApplication = new EventsApplication(); List <EventCalendar> list = new List <EventCalendar>(); list = eventsApplication.GetEventCalendar(monthToDisplay, UserID, UserInfo.Role, projectID); bool isOwner = false; if (UserID == 0) { context.Response.Write("0"); context.Response.End(); } isOwner = UserID == UserID; //判断当前选择的user是不是 当前登陆的user,返回一个bool值. Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("list", list); result.Add("isOwner", isOwner); context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); context.Response.End(); }
protected void Page_Load(object sender, EventArgs e) { userApp = new UserApplication(); eventsApp = new EventsApplication(); if (!IsPostBack) { InitControl(); SetControlsStatus(); } }
protected void Page_Load(object sender, EventArgs e) { projApp = new ProjectApplication(); if (!Page.IsPostBack) { int id = QS("ID", 0); int canEdit = QS("c", 0); if (canEdit == 2) { trBtns.Visible = false; ltrlControlTitle.Text = "View Event"; } EventEntity eventEntity = new EventsApplication().GetEventInfo(id); txtName.Text = eventEntity.Name; txtDetails.Text = eventEntity.Details; txtWhere.Text = eventEntity.Where; chkAllDay.Checked = eventEntity.AllDay; if (chkAllDay.Checked) { txtFromTime.Style.Add("display", "none"); selectFromType.Style.Add("display", "none"); txtToTime.Style.Add("display", "none"); selectToType.Style.Add("display", "none"); } txtFrom.Text = eventEntity.FromDay.ToString("MM/dd/yyyy"); txtFromTime.Text = eventEntity.FromTime; selectFromType.SelectedValue = eventEntity.FromTimeType.ToString(); txtTo.Text = eventEntity.ToDay.ToString("MM/dd/yyyy"); txtToTime.Text = eventEntity.ToTime; selectToType.SelectedValue = eventEntity.ToTimeType.ToString(); ddlAlert.SelectedValue = ((int)eventEntity.Alert).ToString(); imgIcon.ImageUrl = eventEntity.IconPath; projApp.GetUserProjects(UserInfo).BindDropdown <ProjectDetailDTO>(ddlProjects, "Title", "ProjectID", "Please select...", "-1"); ddlProjects.SelectedValue = eventEntity.ProjectID.ToString(); } else { if (chkAllDay.Checked) { txtFromTime.Style.Add("display", "none"); selectFromType.Style.Add("display", "none"); txtToTime.Style.Add("display", "none"); selectToType.Style.Add("display", "none"); } else { txtFromTime.Style.Add("display", ""); selectFromType.Style.Add("display", ""); txtToTime.Style.Add("display", ""); selectToType.Style.Add("display", ""); } } }
public void btnDelete_Click(object sender, EventArgs e) { int id = QS("ID", 0); EventEntity entity = new EventsApplication().GetEventInfo(id); if (entity == null || entity.CreatedBy != UserInfo.UserID) { return; } if (new EventsApplication().Delete(id)) { ShowSuccessMessageToClient("The event has been deleted.", true, true, "350", "50"); } else { ShowFailMessageToClient("Delete fail.", "350", "50"); } }
protected void Page_Load(object sender, EventArgs e) { projApp = new ProjectApplication(); eventApp = new EventsApplication(); if (!Page.IsPostBack) { NotEnoughPTOHour = CurrentPTOHoursNotEnough(); DateTime eventDate = QS("Date", DateTime.Now); txtFrom.Text = eventDate.ToString("MM/dd/yyyy"); txtTo.Text = eventDate.ToString("MM/dd/yyyy"); txtEndDate.Text = eventDate.ToString("MM/dd/yyyy"); List <ProjectDetailDTO> projectList = projApp.GetUserProjectsForCreateObject(UserInfo); EventEntity eventNewest = eventApp.GetEventByCreateId(UserInfo.UserID); switch (UserInfo.Role) { case RolesEnum.Leader: case RolesEnum.DEV: case RolesEnum.QA: projectList = projectList.FindAll(r => r.CompanyID == Config.SunnetCompany); break; } if (eventNewest != null) { var projectNewest = projectList.FirstOrDefault(c => c.ProjectID == eventNewest.ProjectID); if (projectNewest != null) { projectList.Remove(projectNewest); projectList.Insert(0, projectNewest); } projectList.BindDropdown <ProjectDetailDTO>(ddlProjects, "Title", "ProjectID"); ddlProjects.Items.FindByValue(eventNewest.ProjectID.ToString()).Selected = true; } else { projectList.BindDropdown <ProjectDetailDTO>(ddlProjects, "Title", "ProjectID", "Please select...", ""); } userName.Text = UserInfo.FirstName; int searchedProjectID = QS("pid", -1); ddlProjects.SelectedValue = searchedProjectID.ToString(); ((Pop)(this.Master)).Width = 780; } }
protected void Page_Load(object sender, EventArgs e) { userApp = new UserApplication(); eventsApp = new EventsApplication(); int id = QS("id", 0); if (id == 0) { this.ShowArgumentErrorMessageToClient(); return; } userToEditID = id; UserToEdit = userApp.GetUser(id); if (!IsPostBack) { InitControl(); SetControlsStatus(); } InitWorkScheDule(); }
public void ProcessRequest(HttpContext context) { int projectID = -1; if (!string.IsNullOrEmpty(context.Request.QueryString["projectID"])) { projectID = int.Parse(context.Request.QueryString["projectID"]); } UpcomingEvent todayEvent = new UpcomingEvent(); List <UpcomingEvent> upcomingEvents = new EventsApplication().GetEventList(DateTime.Now, UserID, projectID, 10); int itemCount = 0; StringBuilder stringBuilder = new StringBuilder(); if (upcomingEvents.Count > 0 && upcomingEvents[0].Day == DateTime.Now.Date) { todayEvent = upcomingEvents[0]; stringBuilder.AppendFormat("<div class=\"contentTitle cdtitleeventlist\"> {0}</div>", "Today") .Append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"table-advance\">") .Append(" <thead><tr><th width=\"110\">Name</th><th>Title</th></tr></thead>") .Append("<tbody>"); for (int i = 0; i < todayEvent.list.Count; i++) { itemCount++; SunNet.PMNew.Entity.EventModel.ListView item = todayEvent.list[i]; stringBuilder.AppendFormat("<tr {0} class=\"{1}\">", ShowEditEvent(item.ID), i % 2 == 0 ? "" : "whiterow") .AppendFormat("<td width=\"40%\" notAction><img src=\"/images/clock.png\" style=\"vertical-align: middle;\"> {0}</td>", item.Time) .AppendFormat("<td width=\"60%\">{0}</td>", item.Name) .Append("</tr>"); } stringBuilder.Append("</tbody></table>"); } if (itemCount == 0) { stringBuilder.Append("<div class=\"mainowConbox\" style=\"min-height: 80px;\">") .Append("<div class=\"ownothingText\" style=\"color:red\">No scheduled event.</div>") .Append("</div>"); } context.Response.Write(stringBuilder.ToString()); context.Response.End(); }
public void btnSave_Click(object sender, EventArgs e) { int id = QS("ID", 0); EventEntity eventEntity = new EventsApplication().GetEventInfo(id); EventsView model = ConstructEventsView(eventEntity); if (eventEntity.CreatedBy != UserInfo.UserID) { return; } model.CreatedBy = UserInfo.UserID; //model.FamilyID = familyID; //if (new EventsApplication().UpdateEvent(model, eventEntity)) //{ // imgIcon.ImageUrl = model.IconPath; // ShowSuccessMessageToClient("The change has been saved.", true, true, "350", "50"); //} //else //{ // ShowFailMessageToClient("Edit event fail.", "350", "50"); //} }
public void btnDeleteAll_Click(object sender, EventArgs e) { int id = QS("ID", 0); EventEntity entity = new EventsApplication().GetEventInfo(id); if (entity == null || entity.CreatedBy != UserInfo.UserID) { return; } DataSet updatingEntities = new EventsApplication().GetUpdateAndDeleteEvents(entity.CreatedBy, entity.CreatedOn, entity.FromDay); if (new EventsApplication().DeleteAll(entity.CreatedBy, entity.CreatedOn, entity.FromDay.Date)) { //删除Event所对应的TimeSheet DeleteTimeSheets(updatingEntities); Redirect(EmptyPopPageUrl, false, true); } else { ShowFailMessageToClient("Delete fail."); } }
public void ProcessRequest(HttpContext context) { int projectID = -1; if (!string.IsNullOrEmpty(context.Request.QueryString["projectID"])) { projectID = int.Parse(context.Request.QueryString["projectID"]); } List <UpcomingEvent> upcomingEvents = new EventsApplication().GetEventList(DateTime.Now, UserID, projectID, 10); StringBuilder stringBuilder = new StringBuilder(); int itemCount = 0; foreach (SunNet.PMNew.Entity.EventModel.UpcomingEvent upcomingEvent in upcomingEvents) { stringBuilder.AppendFormat("<div class=\"pdlistTop\"> {0}</div>", upcomingEvent.Date) .Append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"listtwo\">") .Append("<tbody>"); for (int i = 0; i < upcomingEvent.list.Count; i++) { itemCount++; SunNet.PMNew.Entity.EventModel.ListView item = upcomingEvent.list[i]; stringBuilder.AppendFormat("<tr {0} class=\"{1}\">", ShowEditEvent(item.ID), i % 2 == 0 ? "listrowone" : "listrowtwo") .AppendFormat("<td width=\"40%\" notAction><img src=\"/images/clock.png\" style=\"vertical-align: middle;\"> {0}</td>", item.Time) .AppendFormat("<td width=\"60%\">{0}</td>", item.Name) .Append("</tr>"); } stringBuilder.Append("</tbody></table>"); } if (itemCount == 0) { stringBuilder.Append("<div class=\"mainowConbox\" style=\"min-height: 80px;\">") .Append("<div class=\"ownothingText\">Nothing was scheduled.</div>") .Append("</div>"); } context.Response.Write(stringBuilder.ToString()); context.Response.End(); }
public void btnDelete_Click(object sender, EventArgs e) { int id = QS("ID", 0); EventEntity entity = new EventsApplication().GetEventInfo(id); if (entity == null || entity.CreatedBy != UserInfo.UserID) { return; } List <EventInviteEntity> list = GetInviteData(entity, true); if (new EventsApplication().Delete(id, entity.FromDay.Date)) { EventsView eventView = new EventsView(); eventView.Name = entity.Name; eventView.Where = entity.Where; eventView.Details = entity.Details; eventView.ProjectID = entity.ProjectID; eventView.FromDay = entity.FromDay; eventView.FromTime = entity.FromTime; eventView.FromTimeType = entity.FromTimeType; eventView.ToDay = entity.ToDay; eventView.ToTime = entity.ToTime; eventView.ToTimeType = entity.ToTimeType; eventView.AllDay = entity.AllDay; SendEamil(list, eventView, false, true); Redirect(Request.RawUrl, false, true); } else { ShowFailMessageToClient("Delete fail."); } }
public static List <PtoView> ReGeneratePtos(int ProId, DateTime StartDate, DateTime EndDate, int UserId = 0, string OrderBy = "ProjectTitle", string OrderDirection = "ASC", string DefaultOrderBy = "ProjectTitle") { EventsApplication _eventsApplication = new EventsApplication(); DataTable ptoDt = _eventsApplication.QueryReportDetailsByProject( ProId, UserId, StartDate, EndDate, OrderBy == "Hours" || OrderBy == "Remaining" ? DefaultOrderBy : OrderBy, OrderDirection); List <PtoView> ptoViews = new List <PtoView>(); if (ptoDt.Rows.Count > 0) { IList <EventPtoView> eventPtolist = ModelConvertHelper <EventPtoView> .ConvertToModel(ptoDt); var s = eventPtolist.GroupBy(c => c.CreatedBy).ToList(); foreach (var t in s) { PtoView ptoView = new PtoView { ProjectID = t.FirstOrDefault().ProjectID, FirstName = t.FirstOrDefault().FirstName, LastName = t.FirstOrDefault().LastName, UserID = t.FirstOrDefault().CreatedBy, Title = t.FirstOrDefault().Title, PTOHoursOfYear = t.FirstOrDefault().PTOHoursOfYear }; double hours = 0; foreach (var m in t) { if (m.Office == "CN") { #region if (m.AllDay) { if (m.ToDay.Date == m.FromDay.Date) { hours += 8; } else { var days = m.ToDay.Day - m.FromDay.Day + 1; hours = hours + days * 8; } } if (!m.AllDay) { var fromTime = m.FromTime.Split(':'); var toTime = m.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "HH:mm"; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(m.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(m.ToTime, dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (m.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(m.FromTime, dtFormat).AddHours(12); } } if (m.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (m.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(m.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } } #endregion } else { var workTimes = _eventsApplication.GetWorkTime(m.UserID); var worksViews = workTimes.Select(e => new WorkTimeView { FromTime = e.FromTime, ToTime = e.ToTime, FromTimeType = e.FromTimeType, ToTimeType = e.ToTimeType }).OrderBy(c => c.FromDate).ToList(); #region if (!worksViews.Any()) { #region if (m.AllDay) { if (m.ToDay.Date == m.FromDay.Date) { hours += 8; } else { var days = m.ToDay.Day - m.FromDay.Day + 1; hours = hours + days * 8; } } else { var fromTime = m.FromTime.Split(':'); var toTime = m.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo { ShortDatePattern = "HH:mm" }; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(m.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(m.ToTime, dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (m.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(m.FromTime, dtFormat).AddHours(12); } } if (m.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (m.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(m.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } } #endregion } else { if (m.AllDay) { #region if (m.ToDay.Date == m.FromDay.Date) { hours += 8; } else { var days = m.ToDay.Day - m.FromDay.Day + 1; hours = hours + days * 8; } #endregion } else { DateTimeFormatInfo dtFormat = new DateTimeFormatInfo { ShortDatePattern = "HH:mm" }; var fromTime = m.FromTime.Split(':'); var toTime = m.ToTime.Split(':'); var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = new DateTime(); var toTimeDate = new DateTime(); foreach (var g in worksViews) { var workTime = g.FromDate; var closeTime = g.ToDate; switch (m.FromTimeType) { case 1: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime("00:" + fromtimeMinutes, dtFormat) : Convert.ToDateTime(m.FromTime, dtFormat); break; case 2: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime(m.FromTime, dtFormat) : Convert.ToDateTime(m.FromTime, dtFormat).AddHours(12); break; } switch (m.ToTimeType) { case 1: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime("00:" + toTimeMinutes, dtFormat) : Convert.ToDateTime(m.ToTime, dtFormat); break; case 2: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime(m.ToTime, dtFormat) : Convert.ToDateTime(m.ToTime, dtFormat).AddHours(12); break; } if (fromTimeDate <= workTime && closeTime <= toTimeDate) { if ((closeTime - workTime).TotalHours < 0) { continue; } hours = hours + (closeTime - workTime).TotalHours; } if (fromTimeDate <= workTime && closeTime > toTimeDate) { if ((toTimeDate - workTime).TotalHours < 0) { continue; } hours = hours + (toTimeDate - workTime).TotalHours; } if (fromTimeDate > workTime && closeTime <= toTimeDate) { if ((closeTime - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (closeTime - fromTimeDate).TotalHours; } if (fromTimeDate > workTime && closeTime > toTimeDate) { if ((toTimeDate - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (toTimeDate - fromTimeDate).TotalHours; } } } } #endregion } } ptoView.Hours = hours; ptoViews.Add(ptoView); } } return(ptoViews); }
/// <summary> /// 批量保存时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveAll_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == string.Empty) { ShowFailMessageToClient("Please enter title."); return; } int id = QS("ID", 0); EventEntity eventEntity = new EventsApplication().GetEventInfo(id); EventsView model = ConstructEventsView(eventEntity); if (eventEntity.CreatedBy != UserInfo.UserID) { return; } model.CreatedBy = UserInfo.UserID; List <EventInviteEntity> inviteList = BuilderInvite(model); DataSet updatingEntities = new EventsApplication().GetUpdateAndDeleteEvents(eventEntity.CreatedBy, eventEntity.CreatedOn, eventEntity.FromDay); //如果改变了From ToDay if (model.ToDay > model.FromDay || model.FromDay != eventEntity.FromDay.Date) { //删除从选中的日期以后的相关Event if (new EventsApplication().DeleteAll(eventEntity.CreatedBy, eventEntity.CreatedOn, eventEntity.FromDay.Date)) { //删除Event所对应的TimeSheet DeleteTimeSheets(updatingEntities); } else { ShowFailMessageToClient("Edit event fail."); } List <EventEntity> eventList = new List <EventEntity>(); model.Repeat = RepeatType.Every_Day; model.End = EndType.on_date; model.EndDate = model.ToDay; new EventsApplication().AddEvents(model, inviteList, out eventList); Redirect(Request.RawUrl, false, true); } DataRowCollection dr = null; if (updatingEntities != null) { if (updatingEntities.Tables.Count > 0) { if (updatingEntities.Tables[0].Rows.Count > 0) { dr = updatingEntities.Tables[0].Rows; } } } if (dr != null) //循环更新成相同的Event { foreach (DataRow item in dr) { List <EventInviteEntity> newInvite = inviteList; //每次都传递要修改的EventInvite集合 int eventId = int.Parse(item[0].ToString()); if (eventId != id) { EventEntity newEventEntity = new EventsApplication().GetEventInfo(eventId); model.ID = eventId; model.FromDay = newEventEntity.FromDay; //FromDay和ToDay应保持原来的值 model.ToDay = newEventEntity.ToDay; eventEntity.IsOff = newEventEntity.IsOff; //保持原来的Event的IsOff选项,用于处理Timesheets } if (new EventsApplication().UpdateEvent(model, eventEntity, newInvite)) { if (!model.AllDay) { model.FromDay = DateTime.Parse(string.Format("{0}/{1}/{2} {3} {4}" , model.FromDay.Month, model.FromDay.Day, model.FromDay.Year, model.FromTime, model.FromTimeType == 1 ? "AM" : "PM")); } SendEamil(inviteList, model, false); } else { ShowFailMessageToClient("Edit event fail."); } } Redirect(Request.RawUrl, false, true); } else { ShowFailMessageToClient("Edit event fail."); } }
public void btnSave_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == string.Empty) { ShowFailMessageToClient("Please enter title."); return; } int id = QS("ID", 0); EventEntity eventEntity = new EventsApplication().GetEventInfo(id); EventsView model = ConstructEventsView(eventEntity); if (eventEntity.CreatedBy != UserInfo.UserID) { return; } model.CreatedBy = UserInfo.UserID; List <EventInviteEntity> inviteList = BuilderInvite(model); DateTime fromDay = model.FromDay; DateTime toDay = model.ToDay; model.ToDay = model.FromDay; if (new EventsApplication().UpdateEvent(model, eventEntity, BuilderInvite(model))) { if (!model.AllDay) { model.FromDay = DateTime.Parse(string.Format("{0}/{1}/{2} {3} {4}" , model.FromDay.Month, model.FromDay.Day, model.FromDay.Year, model.FromTime, model.FromTimeType == 1 ? "AM" : "PM")); } if (model.FromDay != eventEntity.FromDay) //修改even时,有修改它的fromdate 时,要发邮件通知邀请的人 { SendEamil(inviteList, model, true); } else { SendEamil(inviteList, model, false); } //如果改变了ToDay if (toDay > fromDay) { new EventsApplication().Delete(eventEntity.ID, eventEntity.FromDay); List <EventEntity> eventList = new List <EventEntity>(); model.ToDay = toDay; model.Repeat = RepeatType.Every_Day; model.End = EndType.on_date; model.EndDate = model.ToDay; new EventsApplication().AddEvents(model, inviteList, out eventList); } Redirect(Request.RawUrl, false, true); } else { ShowFailMessageToClient("Edit event fail."); } }
protected void Page_Load(object sender, EventArgs e) { projApp = new ProjectApplication(); if (!Page.IsPostBack) { NotEnoughPTOHour = CurrentPTOHoursNotEnough(); int id = QS("ID", 0); EventEntity eventEntity = new EventsApplication().GetEventInfo(id); if (eventEntity != null) { FromDay = eventEntity.FromDay; var projectEntity = new ProjectApplication().Get(eventEntity.ProjectID); if (eventEntity.CreatedBy != UserInfo.UserID && projectEntity.Title != "0_PTO") { OnlyRead = true; Response.Redirect("/Event/View.aspx?ID=" + eventEntity.ID); } var ptoAdmin = Config.PtoAdmin; if (ptoAdmin == null) { if (projectEntity.Title == "0_PTO" && eventEntity.FromDay < DateTime.Now && eventEntity.CreatedBy == UserInfo.UserID) { OnlyRead = true; Response.Redirect("/Event/View.aspx?ID=" + eventEntity.ID); } } else { var ptoAdmins = ptoAdmin.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (!ptoAdmins.Contains(UserInfo.UserName)) { if (projectEntity.Title == "0_PTO" && eventEntity.FromDay < DateTime.Now && eventEntity.CreatedBy == UserInfo.UserID) { OnlyRead = true; Response.Redirect("/Event/View.aspx?ID=" + eventEntity.ID); } if (projectEntity.Title == "0_PTO" && eventEntity.CreatedBy != UserInfo.UserID) { OnlyRead = true; Response.Redirect("/Event/View.aspx?ID=" + eventEntity.ID); } } } Times = eventEntity.Times; txtName.Text = eventEntity.Name; //txtName.Enabled = projectEntity.ProjectCode != "PTO";取消不能编辑pto txtDetails.Text = eventEntity.Details; txtWhere.Text = eventEntity.Where; chkAllDay.Checked = eventEntity.AllDay; if (chkAllDay.Checked) { txtFromTime.Style.Add("display", "none"); txtToTime.Style.Add("display", "none"); } txtFrom.Enabled = eventEntity.FromDay >= DateTime.Today ? true : false; txtFrom.Text = eventEntity.FromDay.ToString("MM/dd/yyyy"); TxtFromHide.Text = DateTime.Now.ToString("MM/dd/yyyy"); txtFromTime.Text = eventEntity.FromTime + (eventEntity.FromTimeType == 1 ? "am" : "pm"); txtTo.Enabled = eventEntity.ToDay >= DateTime.Today ? true : false; txtTo.Text = eventEntity.ToDay.ToString("MM/dd/yyyy"); txtToTime.Text = eventEntity.ToTime + (eventEntity.ToTimeType == 1 ? "am" : "pm"); ddlAlert.SelectedValue = ((int)eventEntity.Alert).ToString(); imgIcon.ImageUrl = eventEntity.IconPath; List <ProjectDetailDTO> projectList = projApp.GetUserProjectsForCreateObject(UserInfo, eventEntity.ProjectID); switch (UserInfo.Role) { case RolesEnum.Leader: case RolesEnum.DEV: case RolesEnum.QA: projectList = projectList.FindAll(r => r.CompanyID == Config.SunnetCompany); break; } List <EventInviteEntity> list = GetInviteData(eventEntity); rptInviteUser.DataSource = list.FindAll(r => r.UserID > 0).OrderBy(r => r.LastName); rptInviteUser.DataBind(); if (rptInviteUser.Items.Count == 0) { rptInviteUser.Visible = false; litNoUser.Text = " <li>No Users</li>"; } if (eventEntity.ProjectID.ToString() == Config.HRProjectID) { chkOff.Checked = eventEntity.IsOff; } else { div_off.Attributes.Add("style", "display:none"); } rptOtherUser.DataSource = list.FindAll(r => r.UserID == 0).OrderBy(r => r.FirstName).OrderBy(r => r.LastName); rptOtherUser.DataBind(); } } else { if (chkAllDay.Checked) { txtFromTime.Style.Add("display", "none"); txtToTime.Style.Add("display", "none"); } else { txtFromTime.Style.Add("display", ""); txtToTime.Style.Add("display", ""); } } ((Pop)(this.Master)).Width = 780; }
/// <summary> /// Client portal Dashboard 界面调用 /// </summary> /// <param name="context"></param> private void ProcessDashBoardCalendar(HttpContext context) { int?t = null; int tmp; int dataCount = 4; if (context.Request.QueryString["dashboard"] + "" != string.Empty) { dataCount = 2; } if (int.TryParse(context.Request.QueryString["t"], out tmp)) { t = tmp; } int?y = null; if (int.TryParse(context.Request.QueryString["y"], out tmp)) { y = tmp; } DateTime?d = null; DateTime tmpDate; if (DateTime.TryParse(context.Request.QueryString["d"], out tmpDate)) { d = tmpDate; } int projectID = -1; if (!int.TryParse(context.Request.QueryString["projectID"], out projectID)) { projectID = -1; } int userId = 0; if (!int.TryParse(context.Request.QueryString["userId"], out userId)) { context.Response.Write("[]"); context.Response.End(); return; } string allUsers = string.Empty; if (userId == 0) { allUsers = context.Request.QueryString["alluser"] + ""; allUsers = allUsers.Trim(); if (allUsers == string.Empty) { context.Response.Write("[]"); context.Response.End(); return; } } EventsApplication eventsApplication = new EventsApplication(); List <EventCalendar> list = new List <EventCalendar>(); if (d == null && t == null) { int year = 0; int month = 0; if (int.TryParse(context.Request.QueryString["year"] + "", out tmp)) { year = tmp; } else { year = DateTime.Now.Year; } if (int.TryParse(context.Request.QueryString["month"] + "", out tmp)) { month = tmp; } else { month = DateTime.Now.Month; } DateTime date = DateTime.Now; if (DateTime.TryParse(string.Format("{0}/1/{1}", month, year), out date) == false) { date = DateTime.Now; } list = eventsApplication.GetEventCalendar(UserInfo.UserID, date, userId, allUsers, UserInfo.Role, projectID, dataCount); } if (d != null && t != null) { DateTime date = (DateTime)d; if (t == 1) { if (y == null) { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddMonths(1), userId, allUsers, UserInfo.Role, projectID, dataCount); } else { if (y == 1)//year { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddYears(1), userId, allUsers, UserInfo.Role, projectID, dataCount); } else//month { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddMonths(1), userId, allUsers, UserInfo.Role, projectID, dataCount); } } } else if (t == 2) { if (y == null) { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddMonths(-1), userId, allUsers, UserInfo.Role, projectID, dataCount); } else { if (y == 1)//year { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddYears(-1), userId, allUsers, UserInfo.Role, projectID, dataCount); } else { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date.AddMonths(-1), userId, allUsers, UserInfo.Role, projectID, dataCount); } } } else { list = eventsApplication.GetEventCalendar(UserInfo.UserID, date, userId, allUsers, UserInfo.Role, projectID, 2); //刷新当前数据 } } if (UserID == 0) { context.Response.Write("0"); context.Response.End(); } //判断当前选择的user是不是 当前登陆的user,返回一个bool值. Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("list", list); result.Add("isOwner", true); context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); context.Response.End(); }
private void ProcessDashBoardCalendar(HttpContext context) { int?t = null; int tmp; if (int.TryParse(context.Request.QueryString["t"], out tmp)) { t = tmp; } int?y = null; if (int.TryParse(context.Request.QueryString["y"], out tmp)) { y = tmp; } DateTime?d = null; DateTime tmpDate; if (DateTime.TryParse(context.Request.QueryString["d"], out tmpDate)) { d = tmpDate; } int projectID = -1; if (int.TryParse(context.Request.QueryString["projectID"], out tmp)) { projectID = tmp; } EventsApplication eventsApplication = new EventsApplication(); List <EventCalendar> list = new List <EventCalendar>(); if (d == null && t == null) { list = eventsApplication.GetEventCalendar(DateTime.Now, UserID, UserInfo.Role, projectID); } if (d != null && t != null) { DateTime date = (DateTime)d; if (t == 1) { if (y == null) { list = eventsApplication.GetEventCalendar(date.AddMonths(1), UserID, UserInfo.Role, projectID); } else { if (y == 1)//year { list = eventsApplication.GetEventCalendar(date.AddYears(1), UserID, UserInfo.Role, projectID); } else//month { list = eventsApplication.GetEventCalendar(date.AddMonths(1), UserID, UserInfo.Role, projectID); } } } else if (t == 2) { if (y == null) { list = eventsApplication.GetEventCalendar(date.AddMonths(-1), UserID, UserInfo.Role, projectID); } else { if (y == 1)//year { list = eventsApplication.GetEventCalendar(date.AddYears(-1), UserID, UserInfo.Role, projectID); } else { list = eventsApplication.GetEventCalendar(date.AddMonths(-1), UserID, UserInfo.Role, projectID); } } } else { list = eventsApplication.GetEventCalendar(date, UserID, UserInfo.Role, projectID); //刷新当前数据 } } if (UserID == 0) { context.Response.Write("0"); context.Response.End(); } //判断当前选择的user是不是 当前登陆的user,返回一个bool值. Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("list", list); result.Add("isOwner", true); context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result)); context.Response.End(); }
protected void Page_Load(object sender, EventArgs e) { projApp = new ProjectApplication(); if (!Page.IsPostBack) { int id = QS("ID", 0); int canEdit = QS("c", 0); EventEntity eventEntity = new EventsApplication().GetEventInfo(id); ltrlName.Text = eventEntity.Name; ltrlDetail.Text = eventEntity.Details; ltrlWhere.Text = eventEntity.Where; chkAllDay.Checked = eventEntity.AllDay; chkAllDay.Enabled = false; string fromTime = string.Empty; string toTime = string.Empty; if (!chkAllDay.Checked) { fromTime = eventEntity.FromDayString + " " + eventEntity.FromTime + " " + (eventEntity.FromTimeType == 1 ? "AM" : "PM"); toTime = eventEntity.ToDayString + " " + eventEntity.ToTime + " " + (eventEntity.ToTimeType == 1 ? "AM" : "PM"); } else { fromTime = eventEntity.FromDayString; toTime = eventEntity.ToDayString; } ltrlFrom.Text = fromTime; ltrlTo.Text = toTime; ltrlAlert.Text = eventEntity.Alert.GetName <AlertType>(); imgIcon.ImageUrl = eventEntity.IconPath; if (eventEntity.ProjectID != -1) { ProjectsEntity projectsEntity = projApp.Get(eventEntity.ProjectID); ltrlProject.Text = projectsEntity.Title; } else { ltrlProject.Text = string.Empty; } litCreated.Text = new App.UserApplication().GetUser(eventEntity.CreatedBy).GetClientUserName(UserInfo); List <EventInviteEntity> list = new App.EventsApplication().GetEventInvites(eventEntity.ID); UsersEntity userEntity; foreach (EventInviteEntity tmpItem in list) { if (tmpItem.UserID > 0) { userEntity = new App.UserApplication().GetUser(tmpItem.UserID); tmpItem.FirstName = userEntity.FirstName; tmpItem.LastName = userEntity.LastName; } } if (eventEntity.ProjectID.ToString() == Config.HRProjectID) { chkOff.Checked = eventEntity.IsOff; } else { div_off.Attributes.Add("style", "display:none"); } rptInvite.DataSource = list.OrderBy(r => r.LastName); rptInvite.DataBind(); } ((Pop)(this.Master)).Width = 425; }
protected void Page_Load(object sender, EventArgs e) { int userID = QS("user", 0); int projectID = QS("project", 0); if (userID == 0 || projectID == 0) { this.Alert("Current Page get an error,please check your argument!", "/Pto/Pto.aspx?viewmodel=detailmodel"); } UserApplication userApp = new UserApplication(); this.SelectedUser = userApp.GetUser(userID); ProjectApplication projApp = new ProjectApplication(); this.SelectedProject = projApp.Get(projectID); //DateTime startDate = DateTime.MinValue; //DateTime endDate = DateTime.MinValue; //DateTime.TryParse(Request.QueryString["startdate"], out startDate); //DateTime.TryParse(Request.QueryString["enddate"], out endDate); DateTime StartDate; DateTime EndDate; if (!DateTime.TryParse(Request.QueryString["year"], out StartDate)) { StartDate = new DateTime(1753, 1, 1); EndDate = new DateTime(2200, 1, 1);; } else { EndDate = StartDate.AddYears(1).AddDays(-1); } _eventsApplication = new EventsApplication(); DataTable evdt = _eventsApplication.GetPtoByProjectUser(projectID, userID, StartDate, EndDate); IList <PtoUserView> eventPtolist = ModelConvertHelper <PtoUserView> .ConvertToModel(evdt); List <PtoUserDetailView> ptoUserDetailViews = new List <PtoUserDetailView>(); if (eventPtolist != null && eventPtolist.Count > 0) { foreach (var t in eventPtolist) { PtoUserDetailView ptoUserDetailView = new PtoUserDetailView { Title = t.Title, Name = t.Name, Details = t.Details }; double hours = 0; if (t.Office == "CN") { #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30); ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(17).AddMinutes(30); } if (!t.AllDay) { var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "HH:mm"; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (t.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); } } if (t.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (t.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } if (t.FromTimeType == 1) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes); } else { if (fromTimeHour <= 5) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); } } if (t.ToTimeType == 1) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes); } else { if (toTimeHour <= 5) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); } if (toTimeHour > 5 && toTimeHour < 12) { ptoUserDetailView.ToDay = closeTime; } if (toTimeHour == 12) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes); } } } #endregion } else { var workTimes = _eventsApplication.GetWorkTime(t.UserID); var worksViews = workTimes.Select(k => new WorkTimeView { FromTime = k.FromTime, ToTime = k.ToTime, FromTimeType = k.FromTimeType, ToTimeType = k.ToTimeType }).OrderBy(c => c.FromDate).ToList(); if (!worksViews.Any()) { #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30); ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(17).AddMinutes(30); } if (!t.AllDay) { var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "HH:mm"; var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); var workTime = Convert.ToDateTime("8:30", dtFormat); var restTimeBegin = Convert.ToDateTime("12:30", dtFormat); var restTimeEnd = Convert.ToDateTime("13:30", dtFormat); var closeTime = Convert.ToDateTime("17:30", dtFormat); if (t.FromTimeType == 2) { if (fromTimeHour <= 5) { fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); } } if (t.FromTimeType == 1) { if (fromTimeHour == 12) { fromTimeDate = workTime; } } if (t.ToTimeType == 2) { if (toTimeHour <= 5) { toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); } if (5 < toTimeHour && toTimeHour < 12) { toTimeDate = closeTime; } } if (toTimeDate < restTimeBegin) { hours = hours + (toTimeDate - fromTimeDate).TotalHours; } if (toTimeDate > restTimeEnd) { hours = hours + (restTimeBegin - fromTimeDate).TotalHours; hours = hours + (toTimeDate - restTimeEnd).TotalHours; } if (t.FromTimeType == 1) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes); } else { if (fromTimeHour <= 5) { ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); } } if (t.ToTimeType == 1) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes); } else { if (toTimeHour <= 5) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); } if (toTimeHour > 5 && toTimeHour < 12) { ptoUserDetailView.ToDay = closeTime; } if (toTimeHour == 12) { ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes); } } } #endregion } else { var mindate = worksViews.Min(x => x.FromDate); var maxdate = worksViews.Max(x => x.ToDate); #region if (t.AllDay) { if (t.ToDay.Date == t.FromDay.Date) { hours += 8; } else { var days = t.ToDay.Day - t.FromDay.Day + 1; hours = hours + days * 8; } ptoUserDetailView.FromDay = mindate; ptoUserDetailView.ToDay = maxdate; } else { #region DateTimeFormatInfo dtFormat = new DateTimeFormatInfo { ShortDatePattern = "HH:mm" }; var fromTime = t.FromTime.Split(':'); var toTime = t.ToTime.Split(':'); var fromTimeHour = Int32.Parse(fromTime[0]); var fromtimeMinutes = Int32.Parse(fromTime[1]); var toTimeHour = Int32.Parse(toTime[0]); var toTimeMinutes = Int32.Parse(toTime[1]); var fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat); var toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat); foreach (var g in worksViews) { var workTime = g.FromDate; var closeTime = g.ToDate; switch (t.FromTimeType) { case 1: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime("00:" + fromtimeMinutes, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat); break; case 2: fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime(t.FromTime, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12); break; } switch (t.ToTimeType) { case 1: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime("00:" + toTimeMinutes, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat); break; case 2: toTimeDate = toTimeHour == 12 ? Convert.ToDateTime(t.ToTime, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12); break; } if (fromTimeDate <= workTime && closeTime <= toTimeDate) { if ((closeTime - workTime).TotalHours < 0) { continue; } hours = hours + (closeTime - workTime).TotalHours; } if (fromTimeDate <= workTime && closeTime > toTimeDate) { if ((toTimeDate - workTime).TotalHours < 0) { continue; } hours = hours + (toTimeDate - workTime).TotalHours; } if (fromTimeDate > workTime && closeTime <= toTimeDate) { if ((closeTime - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (closeTime - fromTimeDate).TotalHours; } if (fromTimeDate > workTime && closeTime > toTimeDate) { if ((toTimeDate - fromTimeDate).TotalHours < 0) { continue; } hours = hours + (toTimeDate - fromTimeDate).TotalHours; } } ptoUserDetailView.FromDay = t.FromTimeType == 1 ? t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddMinutes(fromtimeMinutes) : t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes); ptoUserDetailView.ToDay = t.ToTimeType == 1 ? t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddMinutes(toTimeMinutes) : t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddHours(12).AddMinutes(toTimeMinutes); #endregion } #endregion } } ptoUserDetailView.Hours = hours; ptoUserDetailViews.Add(ptoUserDetailView); } this.ptoDetail.DataSource = ptoUserDetailViews; this.ptoDetail.DataBind(); } else { ShowFailMessageToClient("There is no records "); } litUserName.Text = SelectedUser.FirstName + " " + SelectedUser.LastName; if (ptoUserDetailViews.Any()) { foreach (var t in ptoUserDetailViews) { _totalHours += t.Hours; } } litTotalhours.Text = _totalHours.ToString("#0.00") + " h"; }