private void btnCalculateProfitCost_Click(object sender, EventArgs e) { Disbalance disbalance = (Disbalance)_dbInterface1.GetCurrentObject(); XPCollection <DatebookProfitCollection> xpcProfit = new XPCollection <DatebookProfitCollection>(); xpcProfit.Criteria = CriteriaOperator.Parse("[DatebookOwner].[Date] Between(?, ?)", disbalance.BeginDate, disbalance.EndDate); double profitSum = 0; foreach (DatebookProfitCollection profit in xpcProfit) { profitSum += profit.Profit; } disbalance.Profit = profitSum; XPCollection <DatebookCostCollection> xpcCost = new XPCollection <DatebookCostCollection>(); xpcCost.Criteria = CriteriaOperator.Parse("[DatebookOwner].[Date] Between(?, ?)", disbalance.BeginDate, disbalance.EndDate); double costSum = 0; foreach (DatebookCostCollection cost in xpcCost) { costSum += cost.Cost; } disbalance.Cost = costSum; }
private void btnCalculateDisbalance_Click(object sender, EventArgs e) { Disbalance disCurrent = (Disbalance)_dbInterface1.GetCurrentObject(); disCurrent.Value = disCurrent.Account1 + disCurrent.Account2 + disCurrent.Account3 + disCurrent.Account4 + disCurrent.Account5 + disCurrent.Account6 + disCurrent.Account7 + disCurrent.Account8 + disCurrent.Account9 + disCurrent.Account10 - (disCurrent.Profit - disCurrent.Cost); disCurrent.Value = Math.Round(disCurrent.Value, 2); XPCollection <Disbalance> xpcDisbalance = new XPCollection <Disbalance>(); int t = 0; for (int i = 0; i < xpcDisbalance.Count; i++) { if (xpcDisbalance[i].Oid == disCurrent.Oid) { t = i; break; } } if (t != 0) { disCurrent.CostPercentLast = Math.Round(xpcDisbalance[t].Cost - xpcDisbalance[t - 1].Cost, 2); disCurrent.ValuePercentLast = Math.Round(disCurrent.Value / (xpcDisbalance[t].Cost - xpcDisbalance[t - 1].Cost) * 100, 2); } }