Ejemplo n.º 1
0
        private void RadDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            if (e.PropertyName == "Id")
            {
                e.DataField.IsReadOnly = true;
            }

            if ((e.PropertyName.EndsWith("Id") && e.PropertyName != "Id") && (!Properties.Settings.Default.IdFieldsVisible))
            {
                e.DataField.Visibility = Visibility.Collapsed;
            }


            if (typeof(INotifyPropertyChanged).IsAssignableFrom(e.PropertyType))
            {
                dynamic DataCollection = DataCatalogsSingleton.Instance.GetCatalogData(e.PropertyType);
                if (DataCollection != null)
                {
                    e.DataField = new DataFormComboBoxField()
                    {
                        Label             = e.DataField.Label,
                        DisplayMemberPath = "Name",
                        SelectedValuePath = "Id",
                        DataMemberBinding = new Binding(DataCatalogsSingleton.Instance.GetBindingIdCollectionName(e.PropertyName))
                        {
                            Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        },
                        ItemsSource = DataCollection,
                    };
                }
            }
        }
Ejemplo n.º 2
0
 private void rdfFighters_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName == "Fights1" || e.PropertyName == "Fights2")
     {
         e.Cancel = true;
     }
 }
Ejemplo n.º 3
0
 private void StudentsForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName == "Id")
     {
         e.DataField.IsReadOnly = true;
     }
 }
 // Esto no deberia estar aqui!
 private void radDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName == "Provincia")
     {
         // Funca OK
         e.DataField.DataMemberBinding = new Binding("Provincia.Descripcion");
     }
 }
Ejemplo n.º 5
0
 private void dataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName.Equals("FacultyName"))
     {
         e.Order = 1;
     }
     else if (e.PropertyName.Equals("Ord"))
     {
         e.Order = 2;
     }
     else
     {
         e.Cancel = true;
     }
 }
        private void RadDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            if (e.PropertyName == "Id")
            {
                e.DataField.IsReadOnly = true;
            }
            var disFialds = new List <string>()
            {
                "FullName", "Phones", "Addresses"
            };

            if (disFialds.Contains(e.PropertyName))
            {
                e.DataField.Visibility = Visibility.Collapsed;
            }
        }
 private void RadDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName.Equals("Id"))
     {
         e.Cancel = true;
     }
     if (e.PropertyName.Equals("EmployeeId"))
     {
         e.Cancel = true;
     }
     if (e.PropertyName.Equals("Employee"))
     {
         e.DataField.IsReadOnly = true;
     }
     if (e.PropertyName.Equals("DocumentFileName"))
     {
         e.DataField.IsReadOnly = true;
     }
 }
Ejemplo n.º 8
0
        private void RadDataForm1_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            ClasseEtudiant etudiant = this.radDataForm1.CurrentItem as ClasseEtudiant;

            if (e.PropertyName == "Cne")
            {
                e.DataField.Label     = "CNE";
                e.DataField.IsEnabled = false;
            }
            if (e.PropertyName == "Filiere")
            {
                e.DataField.Description = "This is the initial salary!";
                //e.DataField.MouseDoubleClick += new MouseButtonEventHandler(changeFiliere);
                e.DataField.PreviewMouseDoubleClick += new MouseButtonEventHandler(changeFiliere);
            }
            if (etudiant.Sexe == Gender.Femme)
            {
                e.DataField.Foreground = new SolidColorBrush(Colors.Purple);
            }
            else
            {
                e.DataField.Foreground = new SolidColorBrush(Colors.Blue);
            }
        }
Ejemplo n.º 9
0
 private void DataFormDatabaseConfiguration_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
 {
     if (e.PropertyName == "ConnectionStrings" || e.PropertyName == "InitializeTask")
     {
         e.DataField.Visibility = Visibility.Hidden;
     }
     if (e.PropertyName == "ConnectionString")
     {
         e.DataField.MaxWidth = 632.8668 * 1.97;
         //e.DataField = new TextBoxViewField() { Label = e.DataField.Label, DataMemberBinding = e.DataField.DataMemberBinding, MaxWidth = 632.8668 * 2, VerticalAlignment = e.DataField.VerticalAlignment, HorizontalAlignment = e.DataField.HorizontalAlignment, Margin = e.DataField.Margin, Padding = e.DataField.Padding, Style = e.DataField.Style };
     }
 }
Ejemplo n.º 10
0
        private void OnAutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            //var order = this.CurrentItem as SalesOrderHeader;
            //if (order != null)
            //{
            //    if (e.PropertyName == "Customer")
            //    {
            //        var customers = MainRepository.TopCustomersCache;
            //        var orderCustomer = order.Customer;
            //        if (orderCustomer != null && !customers.Contains(orderCustomer))
            //        {
            //            customers.Insert(0, orderCustomer);
            //        }

            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("CustomerID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = customers,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "CustomerID"
            //        };
            //    }
            //    else if (e.PropertyName == "ShipMethod")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ShipMethodID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ShipMethodsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ShipMethodID"
            //        };
            //    }

            //    return;
            //}

            //var address = this.CurrentItem as Address;
            //if (address != null)
            //{
            //    if (e.PropertyName == "StateProvinceID")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("StateProvinceID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.StatesCache,
            //            DisplayMemberPath = "FullName",
            //            SelectedValuePath = "StateProvinceID"
            //        };
            //    }

            // return;
            // }

            //var customer = this.CurrentItem as Customer;
            //if (customer != null)
            //{
            //    if (e.PropertyName == "State")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("Address.StateProvinceID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.StatesCache,
            //            DisplayMemberPath = "FullName",
            //            SelectedValuePath = "StateProvinceID"
            //        };
            //    }

            //    if (customer.IsPerson)
            //    {
            //        if (e.PropertyName == "CompanyName" || e.PropertyName == "StoreContact")
            //        {
            //            e.Cancel = true;
            //        }
            //    }
            //    else
            //    {
            //        if (e.PropertyName == "FirstName" || e.PropertyName == "LastName")
            //        {
            //            e.Cancel = true;
            //        }
            //    }

            //    return;
            // }

            //var billOfMaterial = this.CurrentItem as BillOfMaterial;
            //if (billOfMaterial != null)
            //{
            //    if (e.PropertyName == "Product")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ComponentID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ProductsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ProductID"
            //        };
            //    }

            //    if (e.PropertyName == "Product1")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ProductAssemblyID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ProductsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ProductID"
            //        };
            //    }

            //    if (e.PropertyName == "UnitMeasure")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("UnitMeasureCode") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.UnitMeasuresCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "UnitMeasureCode"
            //        };
            //    }

            //    return;
            //}

            //var productInventory = this.CurrentItem as ProductInventory;
            //if (productInventory != null)
            //{
            //    if (e.PropertyName == "Product")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ProductID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ProductsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ProductID",
            //            IsEnabled = this.IsCreatingNew
            //        };
            //    }
            //    else if (e.PropertyName == "Color")
            //    {
            //        e.DataField = new ColorPickerDataFormDataField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = e.DataField.DataMemberBinding
            //        };
            //    }
            //    else if (e.PropertyName == "Location")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("LocationID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.LocationsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "LocationID",
            //            IsEnabled = this.IsCreatingNew
            //        };
            //    }
            //}

            //var vendor = this.CurrentItem as Vendor;
            //if (vendor != null)
            //{
            //    if (e.PropertyName == "CreditRating")
            //    {
            //        e.DataField = new NumericUpDownDataFormDataField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = e.DataField.DataMemberBinding
            //        };
            //    }

            //    return;
            //}

            //var workOrder = this.CurrentItem as WorkOrder;
            //if (workOrder != null)
            //{
            //    if (e.PropertyName == "Product")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ProductID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ProductsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ProductID"
            //        };
            //    }

            //    return;
            //}

            //var purchaseOrder = this.CurrentItem as PurchaseOrderHeader;
            //if (purchaseOrder != null)
            //{
            //    if (e.PropertyName == "ShipMethod")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("ShipMethodID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.ShipMethodsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "ShipMethodID"
            //        };
            //    }
            //    else if (e.PropertyName == "Vendor")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("VendorID") { Mode = BindingMode.TwoWay },
            //            ItemsSource = MainRepository.VendorsCache,
            //            DisplayMemberPath = "Name",
            //            SelectedValuePath = "BusinessEntityID"
            //        };
            //    }
            //    else if (e.PropertyName == "OrderStatus")
            //    {
            //        e.DataField = new DataFormComboBoxField
            //        {
            //            Label = e.DataField.Label,
            //            DataMemberBinding = new Binding("OrderStatus") { Mode = BindingMode.TwoWay },
            //            ItemsSource = purchaseOrder.OrderStatuses,
            //        };
            //    }

            //    return;
            //}
        }
Ejemplo n.º 11
0
        private void RadDataForm_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            var frameworkElement = sender as FrameworkElement;
            var orderViewModel   = frameworkElement?.DataContext as OrderViewModel;

            if (orderViewModel != null)
            {
                if (e.PropertyName == "Code")
                {
                    if (orderViewModel != null)
                    {
                        e.DataField = new DataFormComboBoxField()
                        {
                            Name              = "CodeCombobox",
                            ItemsSource       = orderViewModel.Codes,
                            SelectedValuePath = "Number",
                            DataMemberBinding = new Binding("Code")
                            {
                                Mode = BindingMode.TwoWay
                            },
                            Label = Properties.Resources.CodeText,
                            IsComboboxEditable = true
                        };
                        e.DataField.KeyUp += OnTextInput;
                    }
                }
                if (e.PropertyName == "Invoice")
                {
                    if (orderViewModel != null)
                    {
                        e.DataField = new DataFormComboBoxField()
                        {
                            ItemsSource       = orderViewModel.Invoices,
                            FontSize          = 15,
                            DataMemberBinding = new Binding("Invoice")
                            {
                                Mode = BindingMode.TwoWay
                            },
                            Label     = Properties.Resources.InvoiceText,
                            IsEnabled = orderViewModel.User.Role == RoleEnum.Manager
                        };
                    }
                }
                if (e.PropertyName == "Supplier")
                {
                    if (orderViewModel != null)
                    {
                        e.DataField = new DataFormComboBoxField()
                        {
                            ItemsSource       = orderViewModel.Suppliers,
                            FontSize          = 15,
                            DataMemberBinding = new Binding("Supplier")
                            {
                                Mode = BindingMode.TwoWay
                            },
                            Label     = Properties.Resources.SupplierColumnText,
                            IsEnabled = orderViewModel.User.Role == RoleEnum.Manager
                        };
                    }
                }
                if (e.PropertyName == "PesonPost")
                {
                    if (orderViewModel != null)
                    {
                        e.DataField = new DataFormComboBoxField()
                        {
                            ItemsSource       = orderViewModel.Positions,
                            FontSize          = 15,
                            DataMemberBinding = new Binding("PesonPost")
                            {
                                Mode = BindingMode.TwoWay
                            },
                            Label = Properties.Resources.PersonPostText
                        };
                    }
                }
                if (e.PropertyName == "StoragePlaceColumnText")
                {
                    if (orderViewModel != null)
                    {
                        Binding bind = new Binding();
                        bind.Path   = new PropertyPath("Received");
                        bind.Source = orderViewModel;

                        BindingOperations.SetBinding(e.DataField, TextBlock.IsEnabledProperty, bind);
                    }
                }
                if (e.PropertyName == "Vessel")
                {
                    e.DataField.IsEnabled = orderViewModel != null && orderViewModel.User.Role == RoleEnum.Manager;
                }
                if (e.PropertyName == "Status")
                {
                    e.DataField.Visibility = Visibility.Collapsed;
                }
                if (e.PropertyName == "Type")
                {
                    e.DataField.Visibility = Visibility.Collapsed;
                }
            }
            var binding = e.DataField.DataMemberBinding;

            if (binding != null)
            {
                e.DataField.DataMemberBinding.ValidatesOnDataErrors   = true;
                e.DataField.DataMemberBinding.NotifyOnValidationError = true;
            }
        }