public void ExecuteAddCommand(object parameter) { Inspector ins = (from i in db.Inspectors where i.Number == NewInspector.Number select i).FirstOrDefault(); if (ins != null) { MessageBox.Show("Такой номер уже существует. Инспектор не добавлен"); } else { NewInspector.FirstName = NewInspector.FirstName.ToLower(); NewInspector.FirstName = NewInspector.FirstName.Substring(0, 1).ToUpper() + NewInspector.FirstName.Remove(0, 1); NewInspector.LastName = NewInspector.LastName.ToLower(); NewInspector.LastName = NewInspector.LastName.Substring(0, 1).ToUpper() + NewInspector.LastName.Remove(0, 1); NewInspector.MiddleName = NewInspector.MiddleName.ToLower(); NewInspector.MiddleName = NewInspector.MiddleName.Substring(0, 1).ToUpper() + NewInspector.MiddleName.Remove(0, 1); db.Inspectors.Add(NewInspector); db.SaveChanges(); MessageBox.Show("Инспектор добавлен"); Inspectors.Add(NewInspector); NewInspector = null; } }
void GetAllInspectors() { if (Inspectors == null) { Inspectors = new BindingList <InspectorViewType>(); } var foundInspectors = repos.InspectorRepo.GetAll(); if (foundInspectors != null) { foreach (Inspector i in foundInspectors) { Inspectors.Add(new InspectorViewType(i)); } } else { log.Warn("Setup settings: List of Inspectors is NULL."); } foreach (var insp in this.Inspectors) { // Due to incomplete the collection type matching returned at reading from the database and properties binding // the following solution have been proposed. Perhaps this problem can be solved by entities mapping. if (insp.Certificates.Count == 0) { insp.Certificates = new List <InspectorCertificate>(); } } Inspectors.ListChanged += (s, e) => ModifiableView.IsModified = true; }
public void NotifyInspectorEdited(Gebruiker gebruiker) { Inspectors.Remove(Inspectors.FirstOrDefault(k => k.Id == gebruiker.Id)); Inspectors.Add(new GebruikerVM(gebruiker)); edit.Close(); edit = null; }
public TBuilder WithObjectProperties(object instance, Func <PropertyDescriptor, bool> propertyFilter) { var properties = TypeDescriptor.GetProperties(instance) .Cast <PropertyDescriptor>() .Where(x => x.IsBrowsable && propertyFilter(x)) .ToList(); // If any properties are not in the default group, show all properties in collapsible groups. if (properties.Any(x => !string.IsNullOrEmpty(x.Category) && x.Category != CategoryAttribute.Default.Category)) { foreach (var category in properties.GroupBy(x => x.Category)) { var actualCategory = (string.IsNullOrEmpty(category.Key) || category.Key == CategoryAttribute.Default.Category) ? "Miscellaneous" : category.Key; var collapsibleGroupBuilder = new CollapsibleGroupBuilder(); AddProperties(instance, category, collapsibleGroupBuilder.Inspectors); if (collapsibleGroupBuilder.Inspectors.Any()) { Inspectors.Add(collapsibleGroupBuilder.ToCollapsibleGroup(actualCategory)); } } } else // Otherwise, show properties in flat list. { AddProperties(instance, properties, Inspectors); } return((TBuilder)this); }
public TBuilder WithEditor <T, TProperty, TEditor>(T instance, Expression <Func <T, TProperty> > propertyExpression, TEditor editor) where TEditor : IEditor { var propertyName = KSoft.Reflection.Util.PropertyNameFromExpr(propertyExpression); editor.BoundPropertyDescriptor = BoundPropertyDescriptor.FromProperty(instance, propertyName); Inspectors.Add(editor); return((TBuilder)this); }
private void Remove() { if (SelectedRemoveEmployee == null) { return; } Inspectors.Add(SelectedRemoveEmployee); SelectedInspectors.Remove(SelectedRemoveEmployee); SelectedRemoveEmployee = null; }
public TBuilder WithObjectProperty(object instance, PropertyDescriptor property) { var editor = DefaultPropertyInspectors.CreateEditor(property); if (editor != null) { editor.BoundPropertyDescriptor = new BoundPropertyDescriptor(instance, property); Inspectors.Add(editor); } return((TBuilder)this); }
public void NotifyInspectorAdded(GebruikerVM gebruiker) { Inspectors.Add(gebruiker); _addInspectorWindow.Close(); _addInspectorWindow = null; }
public TBuilder WithCollapsibleGroup(string name, CollapsibleGroupBuilder builder) { Inspectors.Add(builder.ToCollapsibleGroup(name)); return((TBuilder)this); }