示例#1
0
        private static void ValidateAndSetSource(Intellibox source, Binding bind, string propertyName)
        {
            if (!string.IsNullOrEmpty(bind.ElementName))
            {
                throw new ArgumentOutOfRangeException("The IntelliBox control does not support setting 'ElementName' on the DisplayValueBinding or SelectedValueBinding properties.");
            }

            if (bind.RelativeSource != null)
            {
                throw new ArgumentOutOfRangeException("The IntelliBox control does not support setting 'RelativeSource' on the DisplayValueBinding or SelectedValueBinding properties.");
            }

            if (bind.XPath != null)
            {
                throw new ArgumentOutOfRangeException("The IntelliBox control does not support setting XPath binding expressions.");
            }

            if (bind.Path == null || bind.Path.Path == null)
            {
                bind.Path = new PropertyPath(propertyName);
            }
            else
            {
                bind.Path = new PropertyPath(propertyName + "." + bind.Path.Path, bind.Path.PathParameters);
            }

            bind.Source = source;
        }
示例#2
0
        private static BindingBase ConstructBinding(Intellibox source, BindingBase template, string propertyName)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentOutOfRangeException("propertyName", "Cannot be null or empty.");
            }

            if (template == null)
            {
                return new Binding(propertyName)
                       {
                           Source = source
                       }
            }
            ;

            if (!(template is Binding) && !(template is MultiBinding) && !(template is PriorityBinding))
            {
                throw new ArgumentOutOfRangeException("template", "Unrecognized BindingBase: " + template.GetType().ToString());
            }

            var bind = CloneHelper.Clone(template);

            if (bind is Binding)
            {
                ValidateAndSetSource(source, bind as Binding, propertyName);
            }
            else if (bind is MultiBinding)
            {
                var a = bind as MultiBinding;
                // all of these binding have already been cloned, so its safe to set them back to themselves
                for (int i = 0; i < a.Bindings.Count; i++)
                {
                    a.Bindings[i] = ConstructBinding(source, a.Bindings[i], propertyName);
                }
            }
            else if (bind is PriorityBinding)
            {
                var a = bind as PriorityBinding;
                // all of these binding have already been cloned, so its safe to set them back to themselves
                for (int i = 0; i < a.Bindings.Count; i++)
                {
                    a.Bindings[i] = ConstructBinding(source, a.Bindings[i], propertyName);
                }
            }

            return(bind);
        }
 public void AddDrug(Intellibox control)
 {
     if (SelectedProductId == 0)
     {
         return;
     }
     ImportProducts.Add(new Product()
     {
         ProductId   = _selectedProduct.ProductId,
         BrandName   = _selectedProduct.BrandName,
         Quantity    = Quantity,
         Country     = _selectedProduct.Country,
         Exp         = Exp,
         GenericDrug = _selectedProduct.GenericDrug,
         Price       = Price,
         Type        = _selectedProduct.Type
     });
     control.Focus();
 }
示例#4
0
        public void AddDrug(Intellibox control)
        {
            var product = _esClinicContext.Products.ToList().FirstOrDefault(p => p.ProductId == SelectedProduct);

            Cost = (int)(Quantity * product.Price);

            var drug = new Drug
            {
                Days      = Days,
                Morning   = Morning,
                Noon      = Noon,
                Afternoon = Afternoon,
                Night     = Night,
                Quantity  = Quantity,
                Note      = DrugNote,
                Cost      = Cost,
                SessionId = _currentSession.SessionId,
                ProductId = SelectedProduct,
                Product   = product
            };

            Drugs.Add(drug);

            Morning   = 0;
            Noon      = 0;
            Afternoon = 0;
            Night     = 0;
            Quantity  = 0;
            DrugNote  = "";

            _drugSaved = false;
            NotifyOfPropertyChange(() => CanSaveDrugs);
            TotalCost += drug.Cost;

            control.Focus();
        }
示例#5
0
 public static BindingBase ConstructBindingForSelected(Intellibox source, BindingBase template)
 {
     return(ConstructBinding(source, template, "SelectedItem"));
 }
示例#6
0
 public static BindingBase ConstructBindingForHighlighted(Intellibox source, BindingBase template)
 {
     return(ConstructBinding(source, template, "ResultsList.SelectedItem"));
 }
 public void AddDrug(Intellibox control)
 {            
     if (SelectedProductId == 0) return;
     ImportProducts.Add(new Product()
     {
         ProductId = _selectedProduct.ProductId,
         BrandName = _selectedProduct.BrandName,
         Quantity = Quantity,
         Country = _selectedProduct.Country,
         Exp = Exp,
         GenericDrug = _selectedProduct.GenericDrug,
         Price = Price,
         Type = _selectedProduct.Type
     });
     control.Focus();
 }