コード例 #1
0
        private List <AssociationCountersApartment> GetAllCounters(Administratoro.DAL.Apartments apartment)
        {
            var result = new List <AssociationCountersApartment>();

            for (int i = 0; i < estateCounters.Controls.Count; i++)
            {
                if (estateCounters.Controls[i] is Panel)
                {
                    var mainPanel = (Panel)estateCounters.Controls[i];

                    if (mainPanel.Controls.Count > 2 && mainPanel.Controls[0] is Label &&
                        mainPanel.Controls[2] is DropDownList)
                    {
                        var apCounterId = (Label)mainPanel.Controls[0];
                        var counterId   = (DropDownList)mainPanel.Controls[2];
                        var counterNr   = (TextBox)mainPanel.Controls[3];

                        int apCntId;
                        int apCntIdResult = -1;
                        if (int.TryParse(apCounterId.Text, out apCntId))
                        {
                            apCntIdResult = apCntId;
                        }

                        int cntId;
                        int cntIdResult = -1;
                        if (int.TryParse(counterId.Text, out cntId))
                        {
                            cntIdResult = cntId;
                        }

                        int nrCountersId;
                        int?nrCountersIdResult = null;
                        if (int.TryParse(counterNr.Text, out nrCountersId))
                        {
                            nrCountersIdResult = nrCountersId;
                        }

                        var counter = new AssociationCountersApartment
                        {
                            Id                      = apCntIdResult,
                            Id_Counters             = cntIdResult,
                            Id_Apartment            = apartment.Id,
                            CountersInsideApartment = nrCountersIdResult
                        };

                        result.Add(counter);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ValidateInputs())
            {
                return;
            }

            var cota      = apartmentCota.Value.ToNullableDecimal();
            var apartment = new Administratoro.DAL.Apartments
            {
                Name          = userName.Value,
                Dependents    = userDependents.Value.ToNullableInt().Value,
                ExtraInfo     = userExtraInfo.Value,
                CotaIndiviza  = cota ?? 0,
                Number        = userNr.Value.ToNullableInt().Value,
                Telephone     = userPhone.Value,
                Email         = userEmail.Value,
                CreatedDate   = DateTime.Now,
                id_Estate     = Association.Id,
                Password      = "******",
                Id_StairCase  = userStairCase.SelectedValue.ToNullableInt(),
                HasHeatHelp   = userHeatHelp.SelectedIndex == 1,
                FondReparatii = txtFondRepairs.Value.ToNullableDecimal(),
                FondRulment   = txtfondRulment.Value.ToNullableDecimal()
            };

            if (!string.IsNullOrEmpty(lblUserId.Text) && lblUserId.Text.ToNullableInt() != 0)
            {
                apartment.Id = lblUserId.Text.ToNullableInt().Value;
                ApartmentsManager.Update(apartment);
            }
            else
            {
                apartment          = ApartmentsManager.Add(apartment);
                lblStatus.Text     = FlowMessages.ApartmentAddSuccess;
                lblStatus.CssClass = "SuccessBox";
            }

            ProcessSaveCounters(apartment);

            var association = AssociationsManager.GetById(Association.Id);

            Session[SessionConstants.SelectedAssociation] = association;

            Response.Redirect("~/Apartments/Manage.aspx?Message=UserUpdatedSuccess");
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
ファイル: Flyers.aspx.cs プロジェクト: adrian10nagy/adro
        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);
        }
コード例 #5
0
        private void ProcessSaveCounters(Administratoro.DAL.Apartments apartment)
        {
            List <AssociationCountersApartment> counters = GetAllCounters(apartment);

            AssociationCountersManager.AddOrUpdateAssociationCountersApartment(counters);
        }
コード例 #6
0
        private void PopulateCountersData(Administratoro.DAL.Associations association, Administratoro.DAL.Expenses expense, Administratoro.DAL.Apartments apartment)
        {
            Panel mainPanel = new Panel();

            Label lb = new Label
            {
                Text     = expense.Name,
                CssClass = "col-md-4 col-xs-4"
            };

            DropDownList drp = new DropDownList()
            {
                CssClass = "col-md-4 col-xs-4"
            };

            ListItem defaultNull = new ListItem
            {
                Value = null,
                Text  = " -Fără contor- "
            };

            drp.Items.Add(defaultNull);

            AssociationCountersApartment ac = null;
            var assCounters = association.AssociationCounters.Where(c => c.Id_Expense == expense.Id).ToList();

            if (apartment != null)
            {
                foreach (var assCounter in assCounters)
                {
                    AssociationCountersApartment assApCounter = ApartmentCountersManager.Get(apartment.Id, assCounter.Id);
                    if (assApCounter != null)
                    {
                        ac = assApCounter;
                    }
                }
            }

            if (assCounters.Count != 0)
            {
                Label lbApCounter = new Label
                {
                    Text    = (ac != null) ? ac.Id.ToString() : string.Empty,
                    Visible = false
                };

                int i = 0;
                foreach (var counter in assCounters)
                {
                    ListItem li = new ListItem
                    {
                        Text     = counter.Value,
                        Value    = counter.Id.ToString(),
                        Selected = (ac != null && ac.Id_Counters == counter.Id) || (apartment == null && i == 0)
                    };
                    drp.Items.Add(li);

                    i++;
                }

                TextBox txtNrOfCounters = new TextBox
                {
                    CssClass         = "col-md-4 col-xs-4",
                    AutoCompleteType = AutoCompleteType.Disabled
                };

                if (ac == null)
                {
                    txtNrOfCounters.Text = "0";
                }
                else if (ac.CountersInsideApartment.HasValue)
                {
                    txtNrOfCounters.Text = ac.CountersInsideApartment.ToString();
                }
                else
                {
                    txtNrOfCounters.Text = "1";
                }

                mainPanel.Controls.Add(lbApCounter);
                mainPanel.Controls.Add(lb);
                mainPanel.Controls.Add(drp);
                mainPanel.Controls.Add(txtNrOfCounters);
                mainPanel.Controls.Add(new LiteralControl("<br />"));
                mainPanel.Controls.Add(new LiteralControl("<br />"));
                estateCounters.Visible = true;
                estateCounters.Controls.Add(mainPanel);
            }
        }