Exemple #1
0
        private void InitializeGridViewExpensesPerIndex(DataTable dt, int esexId)
        {
            var apartments = ApartmentsManager.GetForIndividual(Association.Id, esexId);

            AssociationExpenses ee = AssociationExpensesManager.GetById(esexId);

            foreach (var apartment in apartments)
            {
                ApartmentExpensesManager.ConfigureIndividual(ee, apartment);

                string query = @"
                    Select 
                    TE.Id as Id,
                    A.Number as Apartament,
                    TE.Value as 'Valoare'
                    from ApartmentExpenses TE
                    Inner join Apartments A
                    ON TE.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["dtIndividual"]     = dt;
            gvExpensesPerIndex.DataSource = dt;
            gvExpensesPerIndex.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeStairCases();
            var idExes = Request.QueryString["id_exes"];
            int idExpenseEstate;

            if (int.TryParse(idExes, out idExpenseEstate))
            {
                AssociationExpenses ee = AssociationExpensesManager.GetById(idExpenseEstate);
                if (ee != null)
                {
                    btnRedirect.PostBackUrl = "Invoices.aspx?year=" + ee.Year + "&month=" + ee.Month;
                    btnRedirect.Visible     = true;

                    lblExpenseMeessage.Text = "Modifică <b>" + ee.Expenses.Name + "</b> pe luna <b>"
                                              + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(ee.Month) + "</b> (cheltuială " + ee.ExpenseTypes.Name + ")";

                    if (ee.ExpenseTypes.Id == (int)ExpenseType.PerIndex)
                    {
                        DataTable dt = new DataTable();
                        if (!Page.IsPostBack)
                        {
                            //todo1 - work around counters and staircase
                            //txtExpensesPerIndexValue.Text = ee.AssociationExpensesUnitPrices.FirstOrDefault().PricePerExpenseUnit.ToString();
                        }

                        if (ViewState["dtPerIndex"] == null)
                        {
                            InitializeGridViewExpensesPerIndex(dt, ee.Id);
                        }
                        else
                        {
                            dt = (DataTable)ViewState["dtPerIndex"];
                            ViewState["dtPerIndex"]       = dt;
                            gvExpensesPerIndex.DataSource = dt;
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Expense type not per index");
                    }
                }
                else
                {
                    throw new ArgumentException("AddEditExpenseRequest parameter does not exist");
                }
            }
            else
            {
                throw new ArgumentException("AddEditExpenseRequest parameter not correct");
            }
        }
Exemple #3
0
        public void ClickablePanel1_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    associationExpenseId;

            if (int.TryParse(btn.CommandArgument, out associationExpenseId))
            {
                var associationExpense = AssociationExpensesManager.GetById(associationExpenseId);

                if (associationExpense == null)
                {
                    return;
                }

                Response.Redirect("~/Invoices/Add.aspx?year=" + year() + "&month=" + month() + "&expense=" + associationExpense.Id_Expense);
            }
        }
        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();
        }