public VM_EditExpression(string exp, double ration, string format) { ExpressionString = exp; _ratio = ration; _format = format; BudgetVars = new ObservableCollection <BudgetVar>(BudgetVar.GetAll()); }
public VM_AddBudget(Action <VM_BudgetItem> action = null) { ModelNew = new VM_BudgetItem(new BudgetItem()); BudgetGroups = BudgetGroup.GetAll(); _budgetVars = BudgetVar.GetAll(); _updateAction = action; }
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; }
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")); }
private void Initialize() { MethodList = new ObservableCollection <string>(BudgetVar.GetMethodList()); SelMethod = "Value"; Name = Value = ""; }