Exemplo n.º 1
0
 public VM_EditExpression(string exp, double ration, string format)
 {
     ExpressionString = exp;
     _ratio           = ration;
     _format          = format;
     BudgetVars       = new ObservableCollection <BudgetVar>(BudgetVar.GetAll());
 }
Exemplo n.º 2
0
        public VM_AddBudget(Action <VM_BudgetItem> action = null)
        {
            ModelNew     = new VM_BudgetItem(new BudgetItem());
            BudgetGroups = BudgetGroup.GetAll();
            _budgetVars  = BudgetVar.GetAll();

            _updateAction = action;
        }
Exemplo n.º 3
0
        public VM_EditBudgetVar(VM_BudgetVar vM_BudgetVar)
        {
            MethodList = new ObservableCollection <string>(BudgetVar.GetMethodList());

            _vM_BudgetVar = vM_BudgetVar;
            Name          = vM_BudgetVar.Name;
            Value         = vM_BudgetVar.Value;
            SelMethod     = vM_BudgetVar.Method;
        }
Exemplo n.º 4
0
        private void Initialize()
        {
            // 所有预算和所有变量
            var list       = BudgetGroup.GetAll();
            var budgetVars = BudgetVar.GetAll();

            BudgetItems = new ObservableCollection <VM_BudgetItem>();

            foreach (var itemGroup in list)
            {
                if (itemGroup.BudgetItems == null)
                {
                    continue;
                }
                foreach (var item in itemGroup.BudgetItems)
                {
                    var vb = new VM_BudgetItem(item)
                    {
                        GroupName = itemGroup.Name
                    };
                    BudgetItems.Add(vb);

                    var expression = item.Expression;
                    budgetVars.ForEach(bv =>
                    {
                        if (expression.Contains(bv.Name))
                        {
                            expression = expression.Replace(bv.Name, bv.GetQuantities());
                        }
                    });
                    try
                    {
                        vb.QuantitieString = string.Format(item.Format, Convert.ToDouble(new System.Data.DataTable().Compute(expression, null)) * item.Ratio);
                    }
                    catch (Exception ex)
                    {
                        vb.QuantitieString = "计算出错";
                    }
                }
            }

            collectionView = CollectionViewSource.GetDefaultView(BudgetItems);
            collectionView.GroupDescriptions.Add(new PropertyGroupDescription("GroupName"));
        }
Exemplo n.º 5
0
 private void Initialize()
 {
     MethodList = new ObservableCollection <string>(BudgetVar.GetMethodList());
     SelMethod  = "Value";
     Name       = Value = "";
 }