Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 public void NotifyInspectorEdited(Gebruiker gebruiker)
 {
     Inspectors.Remove(Inspectors.FirstOrDefault(k => k.Id == gebruiker.Id));
     Inspectors.Add(new GebruikerVM(gebruiker));
     edit.Close();
     edit = null;
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public void NotifyInspectorAdded(GebruikerVM gebruiker)
 {
     Inspectors.Add(gebruiker);
     _addInspectorWindow.Close();
     _addInspectorWindow = null;
 }
Ejemplo n.º 9
0
 public TBuilder WithCollapsibleGroup(string name, CollapsibleGroupBuilder builder)
 {
     Inspectors.Add(builder.ToCollapsibleGroup(name));
     return((TBuilder)this);
 }