private void buttonSave_Click(object sender, RoutedEventArgs e) { if (dateTimeEditEndTime.SelectedDateTime != null && dateTimeEditStartTime.SelectedDateTime != null && !EmployeeTimesheet.IsOverlapping(_dataModel.Id, _dataModel.GetEmployeeId(), dateTimeEditStartTime.SelectedDateTime.Value, dateTimeEditEndTime.SelectedDateTime.Value)) { FormattedListBoxItem item = listBoxJobs.SelectedItem as FormattedListBoxItem; if (item != null) { EmployeeJob job = item.ReferenceObject as EmployeeJob; if (job != null) { _dataModel.SetJobId(job.Id); _dataModel.StartTime = dateTimeEditStartTime.SelectedDateTime.Value; _dataModel.EndTime = dateTimeEditEndTime.SelectedDateTime.Value; _dataModel.DeclaredTipAmount = _tipsDeclared; _dataModel.DriverCompensation = _driverComp; } } IsModelUpdated = true; Window.GetWindow(this).Close(); } else { PosDialogWindow.ShowDialog( Strings.TheTimesSpecifiedWouldOverlapAnExistingShift, Strings.ValidationError); } }
private void UpdateOption() { bool isNew = (listBoxOptions.SelectedItem == null); if (!editorControl.HasValidationError()) { editorControl.Update(); if (isNew) { FormattedListBoxItem item = new FormattedListBoxItem( editorControl.ActiveItemOption, editorControl.ActiveItemOption.Name, true); listBoxOptions.Items.Add(item); listBoxOptions.UpdateLayout(); listBoxOptions.SelectedItem = item; listBoxOptions.ScrollIntoView(item); } else { FormattedListBoxItem listItem = listBoxOptions.SelectedItem as FormattedListBoxItem; if (listItem != null) { listItem.Set(editorControl.ActiveItemOption, editorControl.ActiveItemOption.Name); } } SetEditMode(false); } }
private void listBoxSelectedCategories_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count <= 0) { return; } if (listBoxSelectedCategories.SelectedItem != null) { FormattedListBoxItem currentItem = (FormattedListBoxItem)e.AddedItems[0]; FormattedListBoxItem existingItem = null; foreach (FormattedListBoxItem item in listBoxAllCategories.Items) { if (item.Id == currentItem.Id) { existingItem = item; } } listBoxAllCategories.SelectedItem = existingItem; buttonRemove.IsEnabled = true; buttonAdd.IsEnabled = false; } else { buttonRemove.IsEnabled = false; } SetViewable(); }
private void buttonRemove_Click(object sender, RoutedEventArgs e) { FormattedListBoxItem selectedItem = listBoxItemIngredients.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { return; } DialogButton result = PosDialogWindow.ShowDialog( Types.Strings.IngredientEditorConfirmRemove, Types.Strings.Confirmation, DialogButtons.YesNo); if (result != DialogButton.Yes) { return; } RemoveIngredientSet(selectedItem.Id); listBoxItemIngredients.SelectedItem = null; ResetYieldIfEmpty(); InitializeFields(); DoValueChangedEvent(); }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { FormattedListBoxItem selectedItem = listBox.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { return; } PosDialogWindow window = IngredientAmountControl.CreateInDefaultWindow(Strings.ItemEditorIngredientAmount); IngredientAmountControl control = window.DockedControl as IngredientAmountControl; PosDialogWindow parent = Window.GetWindow(this) as PosDialogWindow; Ingredient ingredient = Ingredient.Get(selectedItem.Id); control.Amount = 0; control.MeasurementUnit = ingredient.MeasurementUnit; window.ShowDialog(parent); if (!window.ClosedByUser && (control.Amount > 0)) { _itemIngredientsAdded.Add( ItemIngredient.Add(0, selectedItem.Id, control.Amount, control.MeasurementUnit)); InitializeFields(); DoValueChangedEvent(); } }
private void buttonEditQuantity_Click(object sender, RoutedEventArgs e) { FormattedListBoxItem selectedItem = listBoxIncludedItems.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { return; } ItemGroup itemGroup = selectedItem.ReferenceObject as ItemGroup; if (itemGroup == null) { return; } int?newQuantity = PosDialogWindow.PromptNumber(Strings.ItemEditorEditQuantity, null); if (newQuantity.HasValue) { itemGroup.SetTargetItemQuantity(newQuantity.Value); if (EditQuantityNeedsUpdating(itemGroup)) { _itemGroupsNeedingUpdate.Add(itemGroup); } InitializeListBoxes(); DoValueChangedEvent(); } }
private void DeleteOption() { FormattedListBoxItem item = listBoxOptions.SelectedItem as FormattedListBoxItem; if (item == null || (item.ReferenceObject == null)) { return; } if (PosDialogWindow.ShowDialog( Strings.ItemSetupConfirmDeleteItemOption, Strings.Confirmation, DialogButtons.YesNo) != DialogButton.Yes) { return; } ItemOption option = item.ReferenceObject as ItemOption; if (option == null) { return; } option.Discontinue(); listBoxOptions.Items.Remove(item); buttonDelete.IsEnabled = false; editorControl.IsEnabled = false; editorControl.ActiveItemOption = null; }
private void Delete() { bool confirmed = false; if (listBox1.SelectedItem == null) { return; } FormattedListBoxItem selectedItem = listBox1.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { return; } if (ViewMode == SeatingViewMode.Rooms) { string message = (buttonEditToggle.IsEnabled ? Strings.AreYouSureYouWantToDeleteTheSelectedRoomAndAllItsSeatings : Strings.AreYouSureYouWantToDeleteTheSelectedRoom); if (PosDialogWindow.ShowDialog( message, Strings.ConfirmDeletion, DialogButtons.OkCancel) == DialogButton.Ok) { Room room = selectedItem.ReferenceObject as Room; if (room != null) { SeatingManager.DeleteRoom(room.Id); SeatingManager.DeleteAllSeating(room.Id); } buttonEditToggle.IsEnabled = false; roomEditorControl.IsEnabled = false; SelectedRoom = null; SelectedSeating = null; confirmed = true; } } else if (ViewMode == SeatingViewMode.Seating) { if (PosDialogWindow.ShowDialog( Strings.AreYouSureYouWantToDeleteTheSelectedSeating, Strings.ConfirmDeletion, DialogButtons.OkCancel) == DialogButton.Ok) { Seating seating = selectedItem.ReferenceObject as Seating; if (seating != null) { SeatingManager.DeleteSeating(seating.Id); } seatingEditorControl.IsEnabled = false; SelectedSeating = null; confirmed = true; } } if (confirmed) { listBox1.Items.Remove(selectedItem); listBox1.SelectedItem = null; buttonDelete.IsEnabled = false; } }
private void InitializeListbox(bool retainSelection) { CrashIncident[] incidents = CrashIncident.GetAll(); FormattedListBoxItem selectedItem = (retainSelection ? listBox.SelectedItem : null) as FormattedListBoxItem; CrashIncident selectedIncident = ((selectedItem != null) ? selectedItem.ReferenceObject : null) as CrashIncident; selectedItem = null; listBox.Items.Clear(); foreach (CrashIncident incident in incidents) { Customer customer = Customer.Get(incident.CustomerId); FormattedListBoxItem listItem = new FormattedListBoxItem(incident, customer.BusinessName + Environment.NewLine + incident.When, true); if ((selectedIncident != null) && (selectedIncident.Id == incident.Id)) { selectedItem = listItem; } listBox.Items.Add(listItem); } if (selectedItem != null) { selectedItem.IsSelected = true; listBox.SelectedItem = selectedItem; } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { FormattedListBoxItem selectedItem = listBox.SelectedItem as FormattedListBoxItem; if (selectedItem == null) { buttonDeleteIncident.IsEnabled = false; return; } buttonDeleteIncident.IsEnabled = true; ClearException(); CrashIncident crashIncident = selectedItem.ReferenceObject as CrashIncident; CrashReport crashReport = CrashReport.Get(crashIncident.TopLevelCrashReportId); while (crashReport != null) { PrintCrashReport(crashReport); PrintLine(""); if (crashReport.InnerExceptionCrashReportId == null) { break; } crashReport = CrashReport.Get(crashReport.InnerExceptionCrashReportId.Value); } }
private void InitializeRooms() { Room[] rooms = SeatingManager.GetAllRoom(); FormattedListBoxItem selectedItem = null; SelectedRoom = GetUsersPreviouslyUsedRoom(); if (rooms == null) { return; // Failed, not setup } if ((SelectedRoom == null) && (rooms.Length > 0)) { SelectedRoom = rooms[0]; } foreach (Room room in rooms) { var listItem = new FormattedListBoxItem(room.Id, room.Description, true); if (SelectedRoom != null && room.Id == SelectedRoom.Id) { selectedItem = listItem; listItem.IsSelected = true; } listBoxRooms.Items.Add(listItem); } listBoxRooms.SelectedItem = selectedItem; }
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((e.AddedItems == null) || (e.AddedItems.Count == 0)) { if (listBox1.SelectedItem == null) { buttonDelete.IsEnabled = false; } return; } if (ViewMode == SeatingViewMode.Rooms) { FormattedListBoxItem item = listBox1.SelectedItem as FormattedListBoxItem; if (item != null) { SelectedRoom = item.ReferenceObject as Room; } roomEditorControl.IsEnabled = true; } else if (ViewMode == SeatingViewMode.Seating) { FormattedListBoxItem item = listBox1.SelectedItem as FormattedListBoxItem; if (item != null) { SelectedSeating = item.ReferenceObject as Seating; } seatingEditorControl.IsEnabled = true; } buttonDelete.IsEnabled = true; SetEditMode(false); }
private void AddJob() { if (listBoxAllJobs.SelectedItem == null) { return; } double?payRate = PosDialogWindow.PromptCurrency(Strings.EmployeeJobEditorPayRate, 0.0); if (payRate == null) { return; } FormattedListBoxItem item = listBoxAllJobs.SelectedItem as FormattedListBoxItem; if (item != null) { EmployeeJob job = item.ReferenceObject as EmployeeJob; if (job != null) { EmployeePayRate rate = EmployeePayRate.Add(SelectedEmployee.Id, job.Id, payRate.Value, 0); listBoxAllJobs.Items.Remove(listBoxAllJobs.SelectedItem); item = GetJobListBoxItem(job, rate); listBoxSelectedJobs.Items.Add(item); listBoxSelectedJobs.SelectedItem = item; listBoxSelectedJobs.ScrollToEnd(); } } buttonAdd.IsEnabled = false; buttonRemove.IsEnabled = true; }
private void RemoveTicket() { if (!LockCheckPass(true, false, Types.Strings.TheSelectedTicketCanNotBeRemovedBecauseItAlreadyOpenedSomewhereElse)) { return; } FormattedListBoxItem selected = (FormattedListBoxItem)listboxSourceTicket.SelectedItem; if (selected == null) { return; } if (TicketItem.GetAll(selected.ReferenceObject as YearId).Any()) { // Remove the ticket TicketManager.Delete(selected.ReferenceObject as YearId); listboxSourceTicket.Items.Remove(listboxSourceTicket.SelectedItem); } else { PosDialogWindow.ShowDialog( Types.Strings.YouCanNotRemoveATicketThatHasItemsOnItFirstTransferThoseItemsToADifferentTicket, Types.Strings.TicketNotEmpty); } }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { FormattedListBoxItem selectedIngredient = (FormattedListBoxItem) listBoxAvailableIngredients.SelectedItem; PosDialogWindow window = IngredientAmountControl.CreateInDefaultWindow(Types.Strings.IngredientEditorAddIngredient); IngredientAmountControl control = window.DockedControl as IngredientAmountControl; PosDialogWindow parent = Window.GetWindow(this) as PosDialogWindow; Ingredient ingredient = Ingredient.Get(selectedIngredient.Id); control.Amount = 0; control.MeasurementUnit = ingredient.MeasurementUnit; window.ShowDialog(parent); if (window.ClosedByUser || (!(control.Amount > 0))) { return; } _ingredientSetsAdded.Add( IngredientSet.Add(0, selectedIngredient.Id, control.Amount, control.MeasurementUnit)); listBoxAvailableIngredients.SelectedItem = null; listBoxItemIngredients.SelectedItem = null; InitializeFields(); DoValueChangedEvent(); }
private FormattedListBoxItem AddAvailable(Discount discount) { FormattedListBoxItem result = new FormattedListBoxItem(discount, discount.Description, true); listBoxAvailable.Items.Add(result); return(result); }
private FormattedListBoxItem AddListEntry(Employee employee, Person person) { var item = new FormattedListBoxItem(employee, person.LastName + ", " + person.FirstName, true); listBoxEmployees.Items.Add(item); return(item); }
private FormattedListBoxItem AddAvailable(Coupon coupon) { FormattedListBoxItem result = new FormattedListBoxItem(coupon, coupon.Description, true); listBoxAvailable.Items.Add(result); return(result); }
private void AddEmployeeJobToListBox(EmployeeJob job) { FormattedListBoxItem newItem = new FormattedListBoxItem(job, job.Description, true); listBox1.Items.Add(newItem); listBox1.ScrollIntoView(newItem); listBox1.SelectedItem = newItem; }
private FormattedListBoxItem AddApplied(Coupon coupon) { FormattedListBoxItem result = new FormattedListBoxItem(coupon, coupon.Description /* + Environment.NewLine + * String.Format("{0:C}", ticketCoupon.GetCouponValue()) */, true); listBoxApplied.Items.Add(result); return(result); }
private void AddDiscountToList(Discount discount, bool select) { var newItem = new FormattedListBoxItem(discount, discount.Description, true); listBox1.Items.Add(newItem); if (select) { listBox1.SelectedItem = newItem; } }
private void InitializeListBox() { listBox1.SelectedItem = null; listBox1.Items.Clear(); if (ViewMode == SeatingViewMode.Rooms) { roomEditorControl.SelectedRoom = null; FormattedListBoxItem selected = null; Room[] rooms = SeatingManager.GetAllRoom(); foreach (Room room in rooms) { FormattedListBoxItem item = new FormattedListBoxItem(room, room.Description, true); if ((SelectedRoom != null) && (SelectedRoom.Id == room.Id)) { selected = item; } listBox1.Items.Add(item); } listBox1.SelectedItem = selected; if (selected != null) { roomEditorControl.SelectedRoom = seatingEditorControl.SelectedRoom = selected.ReferenceObject as Room; } SetEditMode(false); } else { if (SelectedRoom != null) { seatingEditorControl.SelectedSeating = null; FormattedListBoxItem selected = null; IEnumerable <Seating> seatings = SeatingManager.GetAllSeating(SelectedRoom.Id); foreach (Seating seating in seatings) { FormattedListBoxItem item = new FormattedListBoxItem(seating, seating.Description, true); if ((SelectedSeating != null) && (SelectedSeating.Id == seating.Id)) { selected = item; } listBox1.Items.Add(item); } listBox1.SelectedItem = selected; if (selected != null) { seatingEditorControl.SelectedSeating = selected.ReferenceObject as Seating; } SetEditMode(false); } } }
private void AddEmployeeJob() { lastKnownSelection = listBox1.SelectedItem as FormattedListBoxItem; if (lastKnownSelection != null) { lastKnownSelection.IsSelected = false; } listBox1.SelectedItem = null; SetEditMode(true); editorControl.Add(); }
private FormattedListBoxItem AddLicense(License license) { Customer customer = Customer.Get(license.CustomerId); FormattedListBoxItem item = new FormattedListBoxItem(license, customer.ContactsName + Environment.NewLine + customer.BusinessName + Environment.NewLine + customer.City + ", " + customer.State, true); listBox.Items.Add(item); return(item); }
private void InitializeInvites() { IEnumerable <PartyInvite> invites = PartyInvite.GetAll(ActiveParty.Id); foreach (PartyInvite invite in invites) { FormattedListBoxItem item = new FormattedListBoxItem(invite.Id, invite.GuestName, true); item.SetHeight(35); listBoxGuests.Items.Add(item); } }
private void AddItem(Ticket ticket, string text) { var item = new FormattedListBoxItem(ticket, text, true); Items.Add(item); if ((SelectedTicket != null) && ticket.PrimaryKey.Equals(SelectedTicket.PrimaryKey)) { item.IsSelected = true; MainWindow.Singleton. orderEntryControl.ticketDetailsControl.SelectedTicket = SelectedTicket; } }
private void UpdateCoupon() { if (editorControl.UpdateCoupon()) { SetEditMode(false); if (listBox1.SelectedIndex >= 0) { var item = (FormattedListBoxItem)listBox1.SelectedItem; item.Set(editorControl.ActiveCoupon, editorControl.ActiveCoupon.Description); } else { var listItem = new FormattedListBoxItem( editorControl.ActiveCoupon, editorControl.ActiveCoupon.Description, true); listBox1.Items.Add(listItem); listBox1.SelectedItem = listItem; listBox1.ScrollIntoView(listItem); buttonDelete.IsEnabled = true; } } if (editorControl.ActiveCoupon != null) { var couponCategories = new List <CouponCategory>(CouponCategory.GetAll(editorControl.ActiveCoupon.Id)); foreach (int id in editorControl.couponCategorySelectionControl.SelectedCategoryIds .Where(id => CouponCategory.FindByCategoryId(couponCategories, id) == null)) { CouponCategory.Add(editorControl.ActiveCoupon.Id, id); } foreach (CouponCategory category in couponCategories .Where(category => !editorControl.couponCategorySelectionControl.SelectedCategoryIds .Contains(category.CategoryId))) { CouponCategory.Delete(editorControl.ActiveCoupon.Id, category.CategoryId); } var couponItems = new List <CouponItem>(CouponItem.GetAll(editorControl.ActiveCoupon.Id)); foreach (int id in editorControl.couponItemSelectionControl.SelectedItemIds .Where(id => CouponItem.FindByItemId(couponItems, id) == null)) { CouponItem.Add(editorControl.ActiveCoupon.Id, id); } foreach (CouponItem item in couponItems .Where(item => !editorControl.couponCategorySelectionControl.SelectedCategoryIds .Contains(item.ItemId))) { CouponItem.Delete(editorControl.ActiveCoupon.Id, item.ItemId); } } }
private void UpdateListBoxItem() { if (listBox1.SelectedItem == null) { return; } FormattedListBoxItem selectedItem = listBox1.SelectedItem as FormattedListBoxItem; if (selectedItem != null) { selectedItem.Set(selectedItem.ReferenceObject, GetText(ActiveIngredient)); } }
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((e.AddedItems == null) || (e.AddedItems.Count == 0)) { return; } FormattedListBoxItem selectedItem = listBox1.SelectedItem as FormattedListBoxItem; if (selectedItem != null) { ActiveJob = selectedItem.ReferenceObject as EmployeeJob; } }
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((e.AddedItems == null) || (e.AddedItems.Count == 0)) { return; } FormattedListBoxItem item = (FormattedListBoxItem)e.AddedItems[0]; ItemPricingModel model = (ItemPricingModel)item.ReferenceObject; InitializeFields(model); buttonRemove.IsEnabled = true; //SetReadOnly(false); }