protected void btnAssociationCountersNew_Click(object sender, EventArgs e) { if (newCounter.Visible) { if (!string.IsNullOrEmpty(txtAssociationCounterValueNew.Text)) { List <AssociationCountersStairCase> associationCounterStariCases = GetStairCases(chbAssociationStairs); AssociationCounters associationCounters = new AssociationCounters { Id_Estate = Association.Id, Value = txtAssociationCounterValueNew.Text, Id_Expense = drpAssociationCounterTypeNew.SelectedValue.ToNullableInt().Value, AssociationCountersStairCase = associationCounterStariCases }; AssociationCountersManager.Add(associationCounters); var newAssociation = AssociationsManager.GetById(Association.Id); Session[SessionConstants.SelectedAssociation] = newAssociation; Response.Redirect(Request.RawUrl); } else { txtAssociationCounterValueNew.Attributes.Add("style", "border-color:red"); } } else { newCounter.Visible = true; IEnumerable <Expenses> expenses = ExpensesManager.GetAllExpenses(); foreach (Expenses expense in expenses) { drpAssociationCounterTypeNew.Items.Add(new ListItem { Text = expense.Name, Value = expense.Id.ToString() }); } var defaultExpense = new ListItem { Value = "", Text = "Contor pe bloc" }; chbAssociationStairs.Items.Add(defaultExpense); if (Association.HasStaircase) { foreach (var stairCase in Association.StairCases) { chbAssociationStairs.Items.Add(new ListItem { Text = stairCase.Nume, Value = stairCase.Id.ToString() }); } } } }
private void AddBodyPanels(int associationId, int yearNr, int monthNr) { string mainRowCssFormat = "col-md-12 col-sm-12 xs-12 cashBokItemsRow {0}"; bool even = false; IEnumerable <Administratoro.DAL.Expenses> allExpenses = ExpensesManager.GetAllExpenses(); var associationExpenses = AssociationExpensesManager.GetByMonthAndYearNotDisabled(associationId, yearNr, monthNr).OrderBy(ee => ee.Id_ExpenseType); // add expense panels foreach (Expenses expense in allExpenses) { var associationExpense = associationExpenses.FirstOrDefault(ea => ea.Id_Expense == expense.Id); if (associationExpense != null) { var mainCol = new Panel(); if (even) { even = false; mainCol.CssClass = string.Format(mainRowCssFormat, "evenRow"); } else { even = true; mainCol.CssClass = string.Format(mainRowCssFormat, "oddRow"); } bool isExpensePerIndex = associationExpense.ExpenseTypes.Id == (int)ExpenseType.PerIndex; var col0 = AddBodyPanelCol0(associationExpense, isExpensePerIndex); var col1 = AddBodyPanelCol1(expense, associationExpense); TextBox tb2; var col2 = AddBodyPanelCol2(associationExpense, out tb2); TextBox tb3; var col3 = AddBodyPanelCol3(associationExpense, tb2, out tb3); var col6 = AddBodyPanelCol6(associationExpense); var col4 = AddBodyPanelCol4(associationExpense, tb2); var col5 = AddBodyPanelCol5(associationExpense, isExpensePerIndex); mainCol.Controls.Add(col0); mainCol.Controls.Add(col1); mainCol.Controls.Add(col2); mainCol.Controls.Add(col3); mainCol.Controls.Add(col6); mainCol.Controls.Add(col4); mainCol.Controls.Add(col5); invoiceMain.Controls.Add(mainCol); } } }
private void PopulateCounters(Administratoro.DAL.Associations association, int?apartmentId) { estateCounters.Visible = false; //if (association.HasStaircase) if (true) { Administratoro.DAL.Apartments apartment = null; if (apartmentId.HasValue) { apartment = ApartmentsManager.GetById(apartmentId.Value); } Panel headerPanel = new Panel(); Label lbExpense = new Label { Text = "Cheltuială", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; Label lbName = new Label { Text = "Contor alocat", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; Label lbNrCountersPerApartment = new Label { Text = "Numărul de contoare în apartament ", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; headerPanel.Controls.Add(lbExpense); headerPanel.Controls.Add(lbName); headerPanel.Controls.Add(lbNrCountersPerApartment); estateCounters.Controls.Add(headerPanel); IEnumerable <Administratoro.DAL.Expenses> expenses = ExpensesManager.GetAllExpenses(); foreach (var expense in expenses) { PopulateCountersData(association, expense, apartment); } } }
private void InitializeExpenses() { //tblMonthlyExpenses.Rows.Clear(); int month; int _year = Year().HasValue ? Year().Value : 2017; if (int.TryParse(drpExpenseMonth.SelectedValue, out month)) { var estate = (Associations)Session[SessionConstants.SelectedAssociation]; if (estate != null) { var ee = AssociationExpensesManager.GetByMonthAndYearNotDisabled(estate.Id, _year, month); var eeAlsoDisabled = AssociationExpensesManager.GetAllAssociationExpensesByMonthAndYearIncludingDisabled(estate.Id, _year, month); IEnumerable <Expenses> expenses = ExpensesManager.GetAllExpenses(); foreach (var expense in expenses) { TableRow row = new TableRow(); // add expense that were added TableCell expenseExists = new TableCell(); CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("esateExpense{0}", expense.Id); esexExists.Checked = IsExpenseSelected(expense, ee, _year, month); expenseExists.Controls.Add(esexExists); row.Cells.Add(expenseExists); // add expense name TableCell expenseName = new TableCell { Text = expense.Name }; row.Cells.Add(expenseName); // add expense type TableCell expenseType = new TableCell(); AssociationExpenses esex = eeAlsoDisabled.FirstOrDefault(s => s.Id_Expense == expense.Id && s.Month == month && s.Year == _year && s.Id_Estate == estate.Id); DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { var selected1 = IsDplExpenseTypesSelected(esex, ExpenseType.PerIndex); dp.Items.Add(new ListItem { Value = "1", Text = "Individuală prin indecși", Selected = selected1 }); var selected2 = IsDplExpenseTypesSelected(esex, ExpenseType.PerCotaIndiviza); dp.Items.Add(new ListItem { Value = "2", Text = "Cotă indiviză de proprietate", Selected = selected2 }); var selected3 = IsDplExpenseTypesSelected(esex, ExpenseType.PerNrTenants); dp.Items.Add(new ListItem { Value = "3", Text = "Per număr persoane imobil", Selected = selected3 }); var selected4 = IsDplExpenseTypesSelected(esex, ExpenseType.PerApartament); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerApartament).ToString(), Text = ExpenseType.PerApartament.ToDescription(), Selected = selected4 }); } dp.Items.Add(new ListItem { Value = "6", Text = "Individual", }); expenseType.Controls.Add(dp); row.Cells.Add(expenseType); if (estate.HasStaircase) { TableCell tcStairCase = new TableCell(); CheckBox stairCaseSplit = new CheckBox(); stairCaseSplit.AutoPostBack = false; stairCaseSplit.Checked = IsStairCaseSplitSelected(expense, ee, _year, month); tcStairCase.Controls.Add(stairCaseSplit); row.Cells.Add(tcStairCase); } else { tblMonthlyExpensesStairCaseSplit.Visible = false; } tblMonthlyExpenses.Rows.Add(row); } } } }
private void Step2PopulateExpenses() { IEnumerable <Administratoro.DAL.Expenses> expenses = ExpensesManager.GetAllExpenses().OrderBy(e => e.LegalType); foreach (var expense in expenses) { var panel = new Panel { CssClass = "associationNewExpense col-md-6 col-xs-6" }; // add expense that were added CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("expense{0}", expense.Id); panel.Controls.Add(esexExists); // add expense name TableCell expenseName = new TableCell { Text = " " + expense.Name + " " }; panel.Controls.Add(expenseName); // add expense type DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerIndex).ToString(), Text = "Individuală prin indecși", Selected = expense.LegalType == (int)ExpenseType.PerIndex }); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerCotaIndiviza).ToString(), Text = "Cotă indiviză de proprietate", Selected = expense.LegalType == (int)ExpenseType.PerCotaIndiviza }); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerNrTenants).ToString(), Text = "Per număr persoane imobil", Selected = expense.LegalType == (int)ExpenseType.PerNrTenants }); } else { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.Individual).ToString(), Text = "Individual", Selected = expense.LegalType == (int)ExpenseType.Individual }); } panel.Controls.Add(dp); expensesDefault.Controls.Add(panel); } }
private void InitializeExpenses() { tblMonthlyExpenses.Rows.Clear(); int month = 0; int year = 0; if (int.TryParse(drpOpeningMonth.SelectedValue, out month) && int.TryParse(drpOpeningYear.SelectedValue, out year)) { var estate = (Associations)Session[SessionConstants.SelectedAssociation]; if (estate != null) { int defaultYear = 2017; int defaultMonth = 1; var defaultEe = AssociationExpensesManager.GetFromLastestOpenedMonth(estate.Id); if (defaultEe.Any()) { defaultYear = defaultEe.FirstOrDefault().Year; defaultMonth = defaultEe.FirstOrDefault().Month; } var eeAlsoDisabled = AssociationExpensesManager.GetAllAssociationExpensesByMonthAndYearIncludingDisabled(estate.Id, defaultYear, defaultMonth); IEnumerable <Expenses> expenses = ExpensesManager.GetAllExpenses(); var ee = AssociationExpensesManager.GetByMonthAndYearNotDisabled(estate.Id, defaultYear, defaultMonth); TableRow defaultRow = new TableRow(); // add expense exists TableCell defaultExpenseSelected = new TableCell { Text = "Activează pentru noua lună" }; defaultRow.Cells.Add(defaultExpenseSelected); // add expense name TableCell defaultExpenseName = new TableCell { Text = "Cheltuială" }; defaultRow.Cells.Add(defaultExpenseName); // add expense type TableCell defaultExpenseType = new TableCell() { Text = "Tip calcul cheltuială" }; defaultRow.Cells.Add(defaultExpenseType); if (estate.HasStaircase) { TableCell tcStairCaseDefaule = new TableCell() { Text = "Contor individual per scară" }; defaultRow.Cells.Add(tcStairCaseDefaule); } tblMonthlyExpenses.Rows.Add(defaultRow); foreach (var expense in expenses) { TableRow row = new TableRow(); // add expense exists TableCell expenseExists = new TableCell(); CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("expense{0}", expense.Id); esexExists.Checked = IsExpenseSelected(expense, defaultEe); expenseExists.Controls.Add(esexExists); row.Cells.Add(expenseExists); // add expense name TableCell expenseName = new TableCell { Text = expense.Name }; row.Cells.Add(expenseName); // add expense type TableCell expenseType = new TableCell(); DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { AssociationExpenses esex = eeAlsoDisabled.FirstOrDefault(s => s.Id_Expense == expense.Id); var selected1 = IsDplExpenseTypesSelected(esex, ExpenseType.PerIndex, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerIndex).ToString(), Text = "Individuală prin indecși", Selected = selected1 }); var selected2 = IsDplExpenseTypesSelected(esex, ExpenseType.PerCotaIndiviza, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerCotaIndiviza).ToString(), Text = "Cotă indiviză de proprietate", Selected = selected2 }); var selected3 = IsDplExpenseTypesSelected(esex, ExpenseType.PerNrTenants, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerNrTenants).ToString(), Text = "Per număr persoane imobil", Selected = selected3 }); var selected4 = IsDplExpenseTypesSelected(esex, ExpenseType.PerApartament, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerApartament).ToString(), Text = ExpenseType.PerApartament.ToDescription(), Selected = selected4 }); } else { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.Individual).ToString(), Text = "Individual", Selected = expense.LegalType == (int)ExpenseType.Individual }); } expenseType.Controls.Add(dp); row.Cells.Add(expenseType); if (estate.HasStaircase) { TableCell tcStairCase = new TableCell(); CheckBox stairCaseSplit = new CheckBox(); stairCaseSplit.AutoPostBack = false; stairCaseSplit.Checked = IsStairCaseSplitSelected(expense, ee, defaultYear, defaultMonth); tcStairCase.Controls.Add(stairCaseSplit); row.Cells.Add(tcStairCase); } tblMonthlyExpenses.Rows.Add(row); } } } }