/// <summary>
 /// Deprecated Method for adding a new object to the Suppliers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSuppliers(Supplier supplier)
 {
     base.AddObject("Suppliers", supplier);
 }
 /// <summary>
 /// Create a new Supplier object.
 /// </summary>
 /// <param name="code">Initial value of the Code property.</param>
 public static Supplier CreateSupplier(global::System.Int32 code)
 {
     Supplier supplier = new Supplier();
     supplier.Code = code;
     return supplier;
 }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!IsInDesignMode)
            {
                taxPositionCodeComboBox.ItemsSource = BusinessContext.Instance.Model.TaxPositions;
                paymentInstrumentCodeComboBox.ItemsSource = BusinessContext.Instance.Model.PaymentInstruments;
                switch (ControlMode)
                {
                    case ControlMode.New:
                        CurrentSupplier = Supplier.CreateSupplier(BusinessContext.Instance.Model.Suppliers.Count());
                        break;
                    case ControlMode.Update:
                        if (!CurrentSupplier.TaxPositionReference.IsLoaded)
                            CurrentSupplier.TaxPositionReference.Load();
                        taxPositionCodeComboBox.SelectedItem = CurrentSupplier.TaxPosition;
                        paymentInstrumentCodeComboBox.SelectedItem = CurrentSupplier.PaymentInstrument;
                        break;
                    case ControlMode.Delete:
                        break;
                    case ControlMode.ReadOnly:
                        break;
                    default:
                        break;
                }

                grid1.DataContext = CurrentSupplier;
            }
        }