private void btnAddPerson_Click(object sender, RoutedEventArgs e) { if (!(firstName.Text.Equals("") || lastName.Text.Equals("") || date.Text.Equals("") || cBoxClients.Text.Equals("") || cBoxPositionTypes.SelectedItem == null)) { DateTime dt = new DateTime(1900, 1, 1); try { dt = DateTime.Parse(date.SelectedDate.ToString()); } catch { } ClientBO cbo = cBoxClients.SelectedItem as ClientBO; PositionTypeBO pTo = cBoxPositionTypes.SelectedItem as PositionTypeBO; PersonBO bo = new PersonBO(0, firstName.Text, lastName.Text, dt, cbo._id, pTo.Id); if (bo.Age < 16) { MessageBoxResult result = MessageBox.Show("The age of the person is less than 16, aborting add", "Warning", MessageBoxButton.OK); return; } bo.AddOrUpdate(); searchBox.Text = ""; lvPersons.ItemsSource = _vm.Persons; lvPersons.UpdateLayout(); } else { MessageBoxResult result = MessageBox.Show("Add a valid Date, Name, Lastname, Client", "Warning", MessageBoxButton.OK); } e.Handled = true; }
private void lvPositionTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) { PositionTypeBO ctbo = lvPositionTypes.SelectedItem as PositionTypeBO; if (ctbo != null) { txtPositionTypeName.Text = ctbo.Name; } e.Handled = true; }
public static ObservableCollection <PositionTypeBO> GetAllPositionTypes() { using (ElibriumEntities db = new ElibriumEntities()) { var positionTypes = db.PositionType.ToList(); ObservableCollection <PositionTypeBO> cts = new ObservableCollection <PositionTypeBO>(); foreach (var positionType in positionTypes) { PositionTypeBO pt = new PositionTypeBO(positionType); cts.Add(pt); } return(cts); } }
private void btnSavePositionType_Click(object sender, RoutedEventArgs e) { if (lvPositionTypes.SelectedItem != null) { PositionTypeBO bo = new PositionTypeBO((lvPositionTypes.SelectedItem as PositionTypeBO).Id, txtPositionTypeName.Text); bo.AddOrUpdate(); lvPositionTypes.ItemsSource = _vm.PositionTypes; lvPositionTypes.UpdateLayout(); } else { MessageBoxResult result = MessageBox.Show("Select a Contact Type to edit first", "Warning", MessageBoxButton.OK); } e.Handled = true; }
private void btnAddPositionType_Click(object sender, RoutedEventArgs e) { string errorMsg = "Contact Type name can not be {0}"; if (!txtPositionTypeName.Text.Equals("")) { if (txtPositionTypeName.Text.Length > 32) { MessageBox.Show(String.Format(errorMsg, "longer than 32"), "Warning", MessageBoxButton.OK); } else { PositionTypeBO bo = new PositionTypeBO(txtPositionTypeName.Text); bo.AddOrUpdate(); lvPositionTypes.ItemsSource = _vm.PositionTypes; lvPositionTypes.UpdateLayout(); } } else { MessageBox.Show(String.Format(errorMsg, "empty"), "Warning", MessageBoxButton.OK); } e.Handled = true; }