Exemple #1
0
        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()
                        });
                    }
                }
            }
        }
Exemple #2
0
        protected void btnSave3_Click(object sender, EventArgs e)
        {
            List <AssociationCounters> cnts = new List <AssociationCounters>();

            foreach (var control in countersConfiguration.Controls)
            {
                if (control is Panel)
                {
                    var thePanel = (Panel)control;

                    if (thePanel.Controls.Count > 1 && thePanel.Controls[0] is DropDownList && thePanel.Controls[1] is TextBox)
                    {
                        var expenseControl = (DropDownList)thePanel.Controls[0];
                        var expenseCleaned = expenseControl.SelectedValue.Remove(expenseControl.SelectedValue.IndexOf("dummyExpense"));
                        var valueControl   = (TextBox)thePanel.Controls[1];

                        int?stairIdResult = null;
                        if (thePanel.Controls.Count == 3 && thePanel.Controls[2] is DropDownList)
                        {
                            var stairCaseControl = (DropDownList)thePanel.Controls[2];
                            var stairCleaned     = stairCaseControl.SelectedValue.Remove(stairCaseControl.SelectedValue.IndexOf("dummyStair"));
                            int stairId;
                            if (int.TryParse(stairCleaned, out stairId))
                            {
                                stairIdResult = stairId;
                            }
                        }

                        // to do, add checkbox and select multiple

                        int expenseId;
                        if (!string.IsNullOrEmpty(expenseControl.Text) &&
                            int.TryParse(expenseCleaned, out expenseId))
                        {
                            var cnt = new AssociationCounters()
                            {
                                Id_Estate  = Association.Id,
                                Id_Expense = expenseId,
                                Value      = valueControl.Text,
                                AssociationCountersStairCase = new List <AssociationCountersStairCase> {
                                    new AssociationCountersStairCase {
                                        Id_StairCase = stairIdResult
                                    }
                                }
                            };
                            cnts.Add(cnt);
                        }
                    }
                }
            }

            AssociationCountersManager.Addcounter(cnts);
            var association = AssociationsManager.GetById(Association.Id);

            Session[SessionConstants.SelectedAssociation] = association;
            Response.Redirect("~/?message=newEstate");
        }
Exemple #3
0
        protected void gvCounters_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var row = gvCounters.Rows[e.RowIndex];

            if (row.Cells.Count > 4 && row.Cells[2].Controls[0] is TextBox &&
                row.Cells[4].Controls[3] is CheckBoxList)
            {
                var counterValue   = (TextBox)row.Cells[2].Controls[0];
                var stairCases     = (CheckBoxList)row.Cells[4].Controls[3];
                var counterIdValue = row.Cells[6];

                int counterId;
                if (string.IsNullOrEmpty(counterValue.Text) || !int.TryParse(counterIdValue.Text, out counterId))
                {
                    counterValue.Attributes.Add("style", "background-color:red");
                }
                else
                {
                    AssociationCounters associationCounters = AssociationCountersManager.GetById(counterId);
                    List <AssociationCountersStairCase> associationCounterStariCases = GetStairCases(stairCases);
                    if (associationCounters != null)
                    {
                        var theCounter = new AssociationCounters
                        {
                            Value = counterValue.Text,
                            AssociationCountersStairCase = associationCounterStariCases,
                            Id = counterId
                        };
                        AssociationCountersManager.Update(theCounter);
                    }

                    gvStaircases.EditIndex = -1;
                    gvStaircases.DataBind();

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

                    Session[SessionConstants.SelectedAssociation] = addedAssociation;
                    var associations = AssociationsManager.GetAllAssociationsByPartner(Association.Id_Partner);
                    Session[SessionConstants.AllAssociations] = associations;
                    Response.Redirect(Request.RawUrl);
                }
            }
        }
Exemple #4
0
        private void ProcessSaveCounters(Administratoro.DAL.Apartments apartment)
        {
            List <AssociationCountersApartment> counters = GetAllCounters(apartment);

            AssociationCountersManager.AddOrUpdateAssociationCountersApartment(counters);
        }