private void ConfigureRedistributeMessages(int associationExpenseId) { string redistributeValue = RedistributionManager.CalculateRedistributeValueAsString(associationExpenseId); invoiceRedistributeMessage.Text = "<br>Cheltuială de redistribuit:" + redistributeValue + "<br>"; decimal redistributeVal; if (decimal.TryParse(redistributeValue, out redistributeVal)) { IEnumerable <Apartments> apartmentsForRedistribute = AssociationExpensesManager.GetApartmentsNrThatShouldRedistributeTo(associationExpenseId); txtInvoiceRedistributeEqualApartment.Text = apartmentsForRedistribute.Count() + " apartamente, alocă <b>" + Math.Round(redistributeVal / apartmentsForRedistribute.Count(), 2) + "</b> la fiecare apartament"; var allApartmentDependents = apartmentsForRedistribute.Sum(t => t.Dependents); var valuePerApartment = "0"; if (allApartmentDependents != 0) { valuePerApartment = Math.Round(redistributeVal / allApartmentDependents, 2).ToString(); } txtInvoiceRedistributeEqualTenants.Text = allApartmentDependents + " persoane în bloc, alocă <b>" + valuePerApartment + "</b> per fiecare locatar"; invoiceRedistributeEqualApartment.CommandArgument = associationExpenseId.ToString(); invoiceRedistributeEqualTenants.CommandArgument = associationExpenseId.ToString(); invoiceRedistributeConsumption.CommandArgument = associationExpenseId.ToString(); } }
private static Panel AddBodyPanelCol3(AssociationExpenses associationExpense, TextBox tb1, out TextBox tb3) { // column 3 var col3 = new Panel { CssClass = "col-md-1 col-sm-4 col-xs-6" }; tb3 = new TextBox { Enabled = false, CssClass = "invoiceItemTextbox" }; if (associationExpense.Id_ExpenseType == (int)ExpenseType.PerIndex) { if (!associationExpense.RedistributeType.HasValue) { var percentage = AssociationExpensesManager.GetPercentageAsString(associationExpense); if (percentage == "100") { var redistributeResult = RedistributionManager.GetRedistributeValuePerIndex(associationExpense); tb3.Text = redistributeResult.HasValue ? redistributeResult.Value.ToString() : string.Empty; } if (tb3.Text == "0,0000000") { tb3.Text = string.Empty; } if (!string.IsNullOrEmpty(tb3.Text)) { var col3Literal = new Literal { Text = "<b>" + tb1.Text + " - " + associationExpense.ApartmentExpenses.Sum(ee => ee.Value) + "</b>" }; col3.Controls.Add(col3Literal); } col3.Controls.Add(tb3); } else { tb3.Text = ""; col3.Controls.Add(tb3); } } //else if (apartmentExpense.Id_ExpenseType == (int)ExpenseType.PerCotaIndiviza) //{ // //if (!string.IsNullOrEmpty(tb1.Text)) // //{ // // var col3Literal = new Literal { Text = "0" }; // // col3.Controls.Add(col3Literal); // //} //} //else if (apartmentExpense.Id_ExpenseType == (int)ExpenseType.PerTenants && estateapartmentExpenseExpense.TenantExpenses.Count > 0) //{ // //var col3Literal = new Literal { Text = "0" }; // //var col3Literal = new Literal { Text = Estate.Tenants.Sum(s => s.Dependents) + " persoane, <b>" + ApartmentExpensesManager.CalculatePertenantPrice(apartmentExpense) + "</b> alocat fiecăruia " }; // //col3.Controls.Add(col3Literal); //} return(col3); }
private static decimal?AddIndexTable(Document document, List <ApartmentExpenses> apExpenses, Administratoro.DAL.Apartments apartment, int assExpenseId) { PdfPTable table = new PdfPTable(6); table.TotalWidth = 450f; //fix the absolute width of the table table.LockedWidth = true; table.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //leave a gap before and after the table table.SpacingBefore = 10f; table.SpacingAfter = 10f; table.AddCell(apExpenses.FirstOrDefault().AssociationExpenses.Expenses.Name); table.AddCell("Index vechi"); table.AddCell("Index nou"); table.AddCell("Consum"); table.AddCell("Pret / m2"); table.AddCell("Valoare"); decimal?sumIndexOld = null; decimal?sumIndexNew = null; decimal?sumConsum = null; decimal?sumValue = null; foreach (var apExpense in apExpenses) { decimal?subValue = null; table.AddCell(apExpense.CounterOrder.HasValue ? "Contor " + apExpense.CounterOrder.Value : string.Empty); table.AddCell(ConvertToDecimalPrintable(apExpense.IndexOld, 1)); table.AddCell(ConvertToDecimalPrintable(apExpense.IndexNew, 1)); table.AddCell(ConvertToDecimalPrintable((apExpense.IndexNew - apExpense.IndexOld), 1)); var pricePerUnit = UnitPricesManager.Get(apExpense.AssociationExpenses.Id, apExpense.Apartments.Id_StairCase); if (pricePerUnit != null) { table.AddCell(ConvertToDecimalPrintable(pricePerUnit.PricePerExpenseUnit, 4)); subValue = ((apExpense.IndexNew - apExpense.IndexOld) * pricePerUnit.PricePerExpenseUnit); table.AddCell(ConvertToDecimalPrintable(subValue, 4)); } else { table.AddCell(string.Empty); table.AddCell(string.Empty); } if (apExpense.IndexOld.HasValue) { sumIndexOld = sumIndexOld.HasValue ? (sumIndexOld + apExpense.IndexOld.Value) : apExpense.IndexOld.Value; } if (apExpense.IndexNew.HasValue) { sumIndexNew = sumIndexNew.HasValue ? (sumIndexNew + apExpense.IndexNew.Value) : apExpense.IndexNew.Value; } if (apExpense.IndexNew.HasValue && apExpense.IndexOld.HasValue) { sumConsum = sumConsum.HasValue ? (sumConsum + (apExpense.IndexNew - apExpense.IndexOld)) : (apExpense.IndexNew - apExpense.IndexOld); } if (subValue.HasValue) { sumValue = sumValue.HasValue ? (sumValue + subValue) : subValue; } } var apartmentExpenseRedistributionValue = RedistributionManager.CalculateRedistributeValueForStairCase( assExpenseId, apartment, apExpenses); if (apartmentExpenseRedistributionValue.HasValue) { table.AddCell("Diferenta"); table.AddCell(string.Empty); table.AddCell(string.Empty); table.AddCell(string.Empty); table.AddCell(string.Empty); table.AddCell(ConvertToDecimalPrintable(apartmentExpenseRedistributionValue)); sumValue = sumValue + apartmentExpenseRedistributionValue; } table.AddCell("TOTAL"); table.AddCell(ConvertToDecimalPrintable(sumIndexOld)); table.AddCell(ConvertToDecimalPrintable(sumIndexNew)); table.AddCell(ConvertToDecimalPrintable(sumConsum)); table.AddCell(""); table.AddCell(ConvertToDecimalPrintable(sumValue)); document.Add(table); return(sumValue); }