protected void Page_Load(object sender, EventArgs e) { context = new serverDBEntities(); departmentBehavior = new Department(context); currentScheduleBehavior = new CurrentSchedule(context); groupBehavior = new Group(context); weekBehavior = new Week(context); semesterBehavior = new Semester(context); List <Department> departments = departmentBehavior.GetList(); List <Week> weeksForSemester = weekBehavior.GetListForSemester(semesterBehavior.GetActiveSemester()); var weekBoxItemsSource = from week in weeksForSemester select new { WeekID = week.ID, DateSpan = week.START_DATE.Date.ToShortDateString() + " - " + week.END_DATE.Date.ToShortDateString() }; foreach (Department department in departments) { LinkButton label = new LinkButton(); label.Text = department.NAME; label.CssClass = "departmentLinktButton"; label.Click += label_Click; label.CommandArgument = department.ID.ToString(); departmentsPanel.Controls.Add(label); departmentsButtons.Add(label); } if (!this.IsPostBack) { if (departmentsButtons.Count != 0) { label_Click(departmentsButtons[0], new EventArgs()); } DropDownList1.DataSource = weekBoxItemsSource.ToList(); DropDownList1.DataTextField = "DateSpan"; DropDownList1.DataValueField = "WeekID"; DropDownList1.DataBind(); Week currentWeek = weekBehavior.GetCurrentWeek(); if (currentWeek != null) { DropDownList1.SelectedValue = currentWeek.ID.ToString(); } } if (treeViewGroups.SelectedNode != null) { buttonPdf.Visible = true; buttonPng.Visible = true; Label1.Visible = true; DropDownList1.Visible = true; } else { buttonPdf.Visible = false; buttonPng.Visible = false; Label1.Visible = false; DropDownList1.Visible = false; } }
/// <summary> /// Confirms if the user wants to delete the given schedule. /// </summary> /// <param name="itemToDelete"></param> private void confirmDeleteSchedule(CurrentSchedule itemToDelete) { if (itemToDelete != null) { string startString = itemToDelete.BlockStartTime.ToShortDateString() + " " + itemToDelete.BlockStartTime.ToShortTimeString(); string endString = itemToDelete.BlockEndTime.ToShortDateString() + " " + itemToDelete.BlockEndTime.ToShortTimeString(); string displayMessage = "Are you sure you want to delete: \n" + startString + " : " + endString + "?"; MessageBoxResult result = MessageBox.Show(displayMessage, "Alert", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: //remove the object from entity framework db.CurrentSchedule.Remove(itemToDelete); db.SaveChanges(); MessageBox.Show("Schedule Deleted."); loadEmployeeData(SelectedStaff); break; case MessageBoxResult.No: break; } } }
public CurrentSchedule thisSchedule; //the schedule, if it exists. public ScheduleItem(CurrentAvailabilities ta, CurrentSchedule ts = null) { thisAvailability = ta; thisSchedule = ts; availableStartTime = thisAvailability.BlockStartTime; availableEndTime = thisAvailability.BlockEndTime; //if sst is null, set is null, and vice versa if (ts != null) { scheduleStartTime = thisSchedule.BlockStartTime; scheduleEndTime = (DateTime)thisSchedule.BlockEndTime; scheduleString = scheduleStartTime.ToShortTimeString() + " - " + scheduleEndTime.ToShortTimeString(); } else { scheduleStartTime = new DateTime(); scheduleEndTime = new DateTime(); scheduleString = ""; } availabilityString = availableStartTime.ToShortTimeString() + " - " + availableEndTime.ToShortTimeString(); }
async void GetSchedule() { try { // Get the schedule asychronously osVodigiWS.osVodigiServiceSoapClient ws = new osVodigiWS.osVodigiServiceSoapClient(); ws.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(PlayerConfiguration.configVodigiWebserviceURL)); osVodigiWS.Player_GetCurrentScheduleResponse scheduleResponse = await ws.Player_GetCurrentScheduleAsync(PlayerConfiguration.configPlayerID); string xml = scheduleResponse.Body.Player_GetCurrentScheduleResult; if (xml.StartsWith("<xml><Error>")) { throw new Exception("Error"); } ScheduleFile.SaveScheduleFile(xml); CurrentSchedule.ClearSchedule(); CurrentSchedule.LastScheduleXML = xml; CurrentSchedule.ParseScheduleXml(xml); // Also copies the PlayerSettings to Helpers.PlayerSettings // At this point, the schedule has been retrieved, so go to the Download control FadeOut(); } catch { DisplayErrorCondition(); } }
/// <summary> /// the user sets a new schedule end time /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewSchedETCB_SelectionChanged(object sender, SelectionChangedEventArgs e) { displayTimeItem chosenDisplayTimeItem = (displayTimeItem)NewSchedETCB.SelectedItem; DateTime chosenTime = chosenDisplayTimeItem.thisDateTime; //if a new schedule item doesn't exist, make it. if (newScheduleItem == null) { newScheduleItem = new CurrentSchedule(); } newScheduleItem.BlockEndTime = chosenTime; }
protected void buttonPng_Click(object sender, EventArgs e) { int groupID = (int)choosenGroupID; int weekID = Int32.Parse(DropDownList1.SelectedValue); Group gg = groupBehavior.GetGroupById(groupID); CurrentSchedule currentSchedule = currentScheduleBehavior.GetCurrentSchedule(groupID, weekID); Response.ContentType = "application/png"; Response.AppendHeader("Content-Disposition", "inline; filename=\"" + gg.NAME + " " + DropDownList1.SelectedItem.Text + ".png\""); Response.AddHeader("content-length", currentSchedule.SCHEDULE_PNG.Length.ToString()); Response.BinaryWrite(currentSchedule.SCHEDULE_PNG); }
protected void buttonPdf_Click(object sender, EventArgs e) { int groupID = Int32.Parse(treeViewGroups.SelectedValue); int weekID = Int32.Parse(DropDownList1.SelectedValue); Group gg = groupBehavior.GetGroupById(groupID); CurrentSchedule currentSchedule = currentScheduleBehavior.GetCurrentSchedule(groupID, weekID); Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", "inline; filename=" + gg.NAME.Replace(' ', '_') + ".pdf"); Response.AddHeader("content-length", currentSchedule.SCHEDULE_PDF.Length.ToString()); Response.BinaryWrite(currentSchedule.SCHEDULE_PDF); }
private void UseLastClicked() { try { string xml = ScheduleFile.ReadScheduleFile(); if (String.IsNullOrEmpty(xml)) { MessageBox.Show("Unable to load previous schedule. Please use the 'Retry' button.", "No Previous Schedule", MessageBoxButton.OK, MessageBoxImage.Error); return; } CurrentSchedule.ParseScheduleXml(xml); FadeOut(); } catch { } }
/// <summary> /// Returns true if the schedule is uniqe and doesn't overlap any others. /// </summary> /// <param name="thisSchedule"></param> /// <returns></returns> private bool uniqueSchedule(CurrentSchedule thisSchedule) { //check for existing availabilities that overlap with the start time of the new one int startTimeOverlap = db.CurrentSchedule .Where(CA => thisSchedule.BlockStartTime >= CA.BlockStartTime) .Where(CA => thisSchedule.BlockStartTime <= CA.BlockEndTime) .Count(); if (startTimeOverlap != 0) { return(false); } else { //check fo existing availabilities that overlap iwth the end time of the new one. int endTimeOverlap = db.CurrentSchedule .Where(CA => thisSchedule.BlockEndTime >= CA.BlockStartTime) .Where(CA => thisSchedule.BlockEndTime <= CA.BlockEndTime) .Count(); if (endTimeOverlap != 0) { return(false); } else { //check for existing availabilities that occur within the start and end times of the new one. int newEncompassesOld = db.CurrentSchedule .Where(CA => thisSchedule.BlockStartTime <= CA.BlockStartTime) .Where(CA => thisSchedule.BlockEndTime >= CA.BlockEndTime) .Count(); if (newEncompassesOld != 0) { return(false); } else { return(true); } } } }
/// <summary> /// Handles the user deleting an scheudle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteSchedule_Click(object sender, RoutedEventArgs e) { writeDebug("Deleting Schedule"); //Get the MenuItem var menuItem = (MenuItem)sender; //Get the ContextMenu to which the menuItem belongs var contextMenu = (ContextMenu)menuItem.Parent; //Find the item that was right clicked. var item = (DataGrid)contextMenu.PlacementTarget; //get the cells (the row) that was selected. ScheduleItem ScheduleItemToDelete = (ScheduleItem)item.SelectedCells[0].Item; CurrentSchedule scheduleToDelete = ScheduleItemToDelete.thisSchedule; confirmDeleteSchedule(scheduleToDelete); }
public void SetOptions(IEnumerable <ScheduleDisplayOption> options) { if (options == null) { return; } bsTypes.DataSource = options; IEnumerator <ScheduleDisplayOption> enumerator = options.GetEnumerator(); ScheduleDisplayOption toSet = null; for (int i = 0; enumerator.MoveNext(); i++) { if (i == 0) { toSet = enumerator.Current; } if (CurrentSchedule != null && enumerator.Current.ScheduleType == CurrentSchedule.GetType()) { toSet = enumerator.Current; break; } } if (CurrentSchedule == null) { CreateSchedule(toSet); } else { _typeComboCanCreate = false; cboType.SelectedItem = toSet; _typeComboCanCreate = true; RebuildUI(toSet); } }
/// <summary> /// Ensure the schedule falls within it's availabilities time block /// </summary> /// <param name="currentSchedule"></param> /// <returns></returns> private bool validSchedule(CurrentSchedule thisSchedule) { string schedStart = thisSchedule.BlockStartTime.ToShortTimeString(); string schedEnd = thisSchedule.BlockEndTime.ToShortTimeString(); string availStart = thisSchedule.Availability.BlockStartTime.ToShortTimeString(); string availEnd = thisSchedule.Availability.BlockEndTime.ToShortTimeString(); System.Diagnostics.Debug.WriteLine("Sched: " + schedStart + " : " + schedEnd); System.Diagnostics.Debug.WriteLine("Avail: " + availStart + " : " + availEnd); bool withinAnAvailability = thisSchedule.BlockStartTime >= thisSchedule.Availability.BlockStartTime && thisSchedule.BlockEndTime <= thisSchedule.Availability.BlockEndTime; bool validSchedule = thisSchedule.BlockStartTime < thisSchedule.BlockEndTime; if (withinAnAvailability && validSchedule) { return(true); //the schedule is valid } else { return(false); //the schedule is not valid. } }
protected void Page_Load(object sender, EventArgs e) { context = new serverDBEntities(); departmentBehavior = new Department(context); currentScheduleBehavior = new CurrentSchedule(context); groupBehavior = new Group(context); weekBehavior = new Week(context); semesterBehavior = new Semester(context); List <Department> departments = departmentBehavior.GetList(); foreach (Department department in departments) { HtmlGenericControl listItem = createListTextItem(department.NAME, null); menuList.Controls.Add(listItem); populateTreeView(department, listItem); } if (!this.IsPostBack) { List <Week> weeksForSemester = weekBehavior.GetListForSemester(semesterBehavior.GetActiveSemester()); var weekBoxItemsSource = from week in weeksForSemester select new { WeekID = week.ID, DateSpan = week.START_DATE.Date.ToShortDateString() + " - " + week.END_DATE.Date.ToShortDateString() }; DropDownList1.DataSource = weekBoxItemsSource.ToList(); DropDownList1.DataTextField = "DateSpan"; DropDownList1.DataValueField = "WeekID"; DropDownList1.DataBind(); Week currentWeek = weekBehavior.GetCurrentWeek(); if (currentWeek != null) { DropDownList1.SelectedValue = currentWeek.ID.ToString(); } } if (Request.QueryString["group"] != null) { if (currentScheduleBehavior.HasCurrentSchedule(Int32.Parse(Request.QueryString["group"]))) { choosenGroupID = Int32.Parse(Request.QueryString["group"]); label.InnerText = groupBehavior.GetGroupById((int)choosenGroupID).NAME; DropDownList1.Visible = true; buttonPdf.Visible = true; buttonPng.Visible = true; } else { label.InnerText = "Brak aktualnego planu dla grupy "; choosenGroupID = Int32.Parse(Request.QueryString["group"]); label.InnerText += groupBehavior.GetGroupById((int)choosenGroupID).NAME; } } else { choosenGroupID = null; label.InnerText = "Aby rozpocząć, wybierz grupę z menu..."; DropDownList1.Visible = false; buttonPdf.Visible = false; buttonPng.Visible = false; } }