protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { /* This section adds dynamic list view - it will be removed at some point */ ListViewStackPanel.Children.Add(listViewIngredientsDetail); listViewIngredientsDetail.SelectionChanged += ListView_SelectionChanged; Thickness margin = listViewIngredientsDetail.Margin; margin.Bottom = 0; margin.Left = 380; margin.Right = 100; margin.Top = 100; listViewIngredientsDetail.Margin = margin; /*-----------------------------------------------------------------------*/ _meal = (MealViewModel)e.Parameter; mealItemsViewModel = new MealItemsViewModel(); _mealItems = mealItemsViewModel.GetMealItems(_meal.MealItemIDsWithWeight); MealItemsGridView.ItemsSource = _mealItems; _contact = new ContactViewModel(); _contact = _contact.GetContact(_meal.ContactId); ContactNameTextBox.Text = _contact.NameAndAddress; this.DataContext = _meal; NumberOfGuestsTextBox.Text = _meal.NumberOfGuests.ToString(); _numberOfGuests = _meal.NumberOfGuests.ToString(); DeliveryDatePicker.Date = _meal.DeliveryDate; DeliveryTimePicker.Time = _meal.DeliveryTime; DeliveryNoteIdTextBox.Text = _meal.DeliveryNoteId; } }
public NewMealCustomerEventDataInput() { this.InitializeComponent(); _contact = new ContactViewModel(); AttentionTextBox.ItemsSource = _attention; ContactTextBox.ItemsSource = _contactPerson; }
public object Convert(object value, Type type, object parameter, string language) { string result = ""; if (value == null) throw new ArgumentNullException(); if ((int)value != 0) { ContactViewModel contact = new ContactViewModel(); contact = contact.GetContact((int)value); result = contact.NameAndAddress; } return result; }
public string SaveContact(ContactViewModel contact) { string result = string.Empty; using (var db = new SQLite.SQLiteConnection(App.DBPath)) { string change = string.Empty; try { var existingContact = (db.Table<Contact>().Where( c => c.Id == contact.Id)).SingleOrDefault(); if (existingContact != null) { existingContact.Attention = contact.Attention; existingContact.FirstName = contact.FirstName; existingContact.LastName = contact.LastName; existingContact.NameAndAddress = contact.NameAndAddress; existingContact.Company = contact.Company; existingContact.Street = contact.Street; existingContact.Zip = contact.Zip; existingContact.City = contact.City; existingContact.PhoneNr = contact.PhoneNr; existingContact.CellPhoneNr = contact.CellPhoneNr; int success = db.Update(existingContact); } else { int success = db.Insert(new Contact() { Attention = contact.Attention, FirstName = contact.FirstName, LastName = contact.LastName, NameAndAddress = contact.NameAndAddress, Company = contact.Company, Street = contact.Street, Zip = contact.Zip, City = contact.City, PhoneNr = contact.PhoneNr, CellPhoneNr = contact.CellPhoneNr }); SQLiteCommand cmd = db.CreateCommand("SELECT last_insert_rowid()"); int rowId = cmd.ExecuteScalar<int>(); cmd.CommandText = "SELECT Id FROM Contact WHERE rowid = " + rowId.ToString(); contact.Id = cmd.ExecuteScalar<int>(); } result = "Success"; } catch { result = "This contact was not saved."; } } return result; }
public ContactViewModel GetContact(string contactInfo) { var contact = new ContactViewModel(); using (var db = new SQLite.SQLiteConnection(App.DBPath)) { var _contact = (db.Table<Contact>().Where(c => c.LastName.Contains(contactInfo))).Single(); contact.Attention = _contact.Attention; contact.FirstName = _contact.FirstName; contact.LastName = _contact.LastName; contact.NameAndAddress = _contact.NameAndAddress; contact.Company = _contact.Company; contact.Street = _contact.Street; contact.Zip = _contact.Zip; contact.City = _contact.Zip; contact.PhoneNr = _contact.PhoneNr; contact.CellPhoneNr = _contact.CellPhoneNr; } return contact; }
private void ContactNameTextBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { //We only want to get results when it was a user typing, //otherwise we assume the value got filled in by TextMemberPath //or the handler for SuggestionChosen if ((args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) && (sender.Text != "")) { ContactViewModel contactViewModel = new ContactViewModel(); //ObservableCollection<ContactViewModel> matchingContacts = contactViewModel.GetMatchingContacts(sender.Text); ObservableCollection<string> matchingContacts = contactViewModel.GetMatchingContacts(sender.Text); sender.ItemsSource = matchingContacts; } }
public string GetTextRepresentation(IMealViewModel meal) { StringBuilder result = new StringBuilder(); MealItemsViewModel mealItemsView = new MealItemsViewModel(); IngredientsViewModel ingredientsView = new IngredientsViewModel(); ContactViewModel contact = new ContactViewModel(); contact = contact.GetContact(meal.ContactId); string tmp = contact.NameAndAddress; tmp = tmp.Replace('\n', '|'); tmp = tmp.Replace('\r', '|'); string nameAndAddress = tmp.Replace("||", "\\line "); nameAndAddress = contact.Attention + "\\line " + tmp.Replace("||", "\\line "); result.Append(@"{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Calibri;}}"); result.Append(@"{\*\generator Riched20 10.0.10240}\viewkind4\uc1\pard\tx720\cf1\f0\fs22\lang1031\line\line\line\f1\fs26"); result.Append(" Lieferschein Nr. ").Append(meal.DeliveryNoteId).Append(@"\line \line "); ; result.Append(nameAndAddress).Append(@" \line "); result.Append("Tel. Nr. : ").Append(contact.PhoneNr).Append(@" \line "); result.Append("Handy Nr. : ").Append(contact.CellPhoneNr).Append(@" \line \line "); result.Append("Veranstaltungsort:").Append(@" \line "); result.Append(meal.DeliveryLocation).Append(@" \line \line "); result.Append("Ihr Ansprechpartner: ").Append(@" \line \line "); result.Append(_dateTimeConverter.Convert(meal.DeliveryDate, null, null, "")).Append(" "); result.Append(_timeSpanConverter.Convert(meal.DeliveryTime,null,null,"")).Append(" Uhr Buffetbeginn").Append(@"\line \line \line"); result.Append(@" \highlight2 "); result.Append("Erwachsene: ").Append(meal.NumberOfGuests).Append(@"\line \line "); result.Append(@" \highlight0 "); ObservableCollection<MealItemViewModel> _mealItems = mealItemsView.GetMealItems(meal.MealItemIDsWithWeight); foreach (var mealItem in _mealItems) { float mealItemWeight = meal.MealItemIDsWithWeight[mealItem.Id]; result.Append(@"\b "); result.Append(mealItem.Name.ToString()).Append(" "); UnitOfMeasureViewModel unitOfMeasure = new UnitOfMeasureViewModel(); string unitOfMeasureName = unitOfMeasure.GetUnitOfMeasure(mealItem.TotalAmountUnitOfMeasure).UnitName; string unitOfMeasureAbbreviation = unitOfMeasure.GetUnitOfMeasure(mealItem.TotalAmountUnitOfMeasure).Abbreviation; result.Append(mealItemWeight.ToString()).Append("").Append(unitOfMeasureAbbreviation); result.Append(@"\line\b0 "); result.Append(GetIngredientsAsText(ingredientsView, mealItem, meal.MealItemIDsWithWeight)); result.Append(@" \line "); } result.Append(@" \line }"); return result.ToString(); }