Exemplo n.º 1
0
        public static void ConfigurePerIndex(Associations association, int year, int month)
        {
            IEnumerable <Expenses> allExpenses = ExpensesManager.GetAllExpenses();
            var associationExpenses            = GetByMonthAndYearNotDisabled(association.Id, year, month);

            foreach (Expenses expense in allExpenses)
            {
                var associationExpense = associationExpenses.FirstOrDefault(ea => ea.Id_Expense == expense.Id);
                if (associationExpense != null)
                {
                    var apartments = ApartmentsManager.GetAllThatAreRegisteredWithSpecificCounters(association.Id, associationExpense.Id);
                    ApartmentExpensesManager.ConfigurePerIndex(associationExpense, apartments);
                }
            }
        }
Exemplo n.º 2
0
        private void InitializeGridViewExpensesPerIndex(DataTable dt, int esexId)
        {
            AssociationExpenses ee = AssociationExpensesManager.GetById(esexId);

            int stairCase;
            List <Administratoro.DAL.Apartments> apartments;

            if (Association.HasStaircase && !string.IsNullOrEmpty(drpStairCases.SelectedValue) && int.TryParse(drpStairCases.SelectedValue, out stairCase))
            {
                apartments = ApartmentsManager.GetAllThatAreRegisteredWithSpecificCounters(Association.Id, esexId, stairCase);
            }
            else
            {
                apartments = ApartmentsManager.GetAllThatAreRegisteredWithSpecificCounters(Association.Id, esexId);
            }


            ApartmentExpensesManager.ConfigurePerIndex(ee, apartments);

            foreach (var apartment in apartments)
            {
                string query = @"
                    Select 
                    AE.Id as Id,
                    A.Number as Apartament,
                    cast(AE.IndexOld as float) as 'Index vechi',
                    cast(AE.IndexNew as float) as 'Index nou',
                    (AE.IndexNew - AE.IndexOld ) as 'Consum',
                    AE.Value as 'Valoare'
                    from ApartmentExpenses AE
                    Inner join Apartments A
                    ON AE.Id_Tenant = A.Id
                    where Id_EstateExpense = " + esexId + " and Id_Tenant = " + apartment.Id +
                               " and A.Id_Estate = " + Association.Id;

                SqlConnection  cnn = new SqlConnection("data source=HOME\\SQLEXPRESS;initial catalog=Administratoro;integrated security=True;MultipleActiveResultSets=True;");
                SqlCommand     cmd = new SqlCommand(query, cnn);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(dt);
            }

            ViewState["dtPerIndex"]       = dt;
            gvExpensesPerIndex.DataSource = dt;
            gvExpensesPerIndex.DataBind();
        }