Exemple #1
0
        private void InitializeEsates(Partners partner)
        {
            var association  = Session[SessionConstants.SelectedAssociation] as Administratoro.DAL.Associations;
            var associations = Session[SessionConstants.AllAssociations] as List <Administratoro.DAL.Associations>;

            if (association == null || associations == null)
            {
                associations = AssociationsManager.GetAllAssociationsByPartner(partner.Id);
                if (associations != null && associations.Count > 0)
                {
                    association = associations.FirstOrDefault();
                    Session[SessionConstants.SelectedAssociation] = association;
                    Session[SessionConstants.AllAssociations]     = associations;
                }
            }

            drpMainEstate.Items.Clear();
            foreach (var itemEstate in associations)
            {
                drpMainEstate.Items.Add(new ListItem
                {
                    Text     = itemEstate.Name,
                    Value    = itemEstate.Id.ToString(),
                    Selected = (itemEstate.Id == association.Id)
                });
            }


            drpMainEstate.Items.Add(new ListItem
            {
                Text  = "Adaugă o nouă asociație",
                Value = "-1"
            });
        }
Exemple #2
0
        protected void drpMainEstate_SelectedIndexChanged(object sender, EventArgs e)
        {
            int?selectedAssociation = drpMainEstate.SelectedValue.ToNullableInt();
            var partner             = Session[SessionConstants.LoggedPartner] as Partners;

            if (selectedAssociation.HasValue && selectedAssociation.Value != -1)
            {
                var associations        = AssociationsManager.GetAllAssociationsByPartner(partner.Id);
                var existingAssociation = associations.FirstOrDefault(es => es.Id == selectedAssociation.Value);
                if (existingAssociation != null)
                {
                    Session[SessionConstants.SelectedAssociation] = existingAssociation;
                    Response.Redirect("~/");
                }
                else
                {
                    // to do- redirect
                }
            }
            else
            {
                //Response.Redirect("~/Account/Login.aspx");
                Response.Redirect("~/Associations/New.aspx");
            }

            Response.Redirect(Request.RawUrl);
        }
Exemple #3
0
 protected void btnAssociationBanckAccount_Click(object sender, EventArgs e)
 {
     txtAssociationBanckAccount.Attributes.CssStyle.Add("border-color", "");
     if (txtAssociationBanckAccount.Enabled)
     {
         if (string.IsNullOrEmpty(txtAssociationBanckAccount.Text))
         {
             txtAssociationBanckAccount.Attributes.CssStyle.Add("border-color", "red");
         }
         else
         {
             txtAssociationBanckAccount.Enabled = false;
             var es = AssociationsManager.GetById(Association.Id);
             es.BanckAccont = txtAssociationBanckAccount.Text;
             AssociationsManager.Update(es);
             Session[SessionConstants.SelectedAssociation] = es;
             var associations = AssociationsManager.GetAllAssociationsByPartner(Association.Id_Partner);
             Session[SessionConstants.AllAssociations] = associations;
             Response.Redirect(Request.RawUrl);
         }
     }
     else
     {
         txtAssociationBanckAccount.Enabled = true;
     }
 }
Exemple #4
0
        protected void gvStaircases_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var row = gvStaircases.Rows[e.RowIndex];

            if (row.Cells.Count > 4 &&
                row.Cells[2].Controls.Count > 0 && row.Cells[2].Controls[0] is TextBox &&
                row.Cells[4].Controls.Count > 0 && row.Cells[4].Controls[0] is TextBox)
            {
                var stairName         = (TextBox)row.Cells[2].Controls[0];
                var stairCotaIndiviza = (TextBox)row.Cells[4].Controls[0];
                var stairIdValue      = (TextBox)row.Cells[1].Controls[0];

                decimal newIndivizaValue;
                int     stairId;
                if (string.IsNullOrEmpty(stairName.Text) || !decimal.TryParse(stairCotaIndiviza.Text, out newIndivizaValue) ||
                    !int.TryParse(stairIdValue.Text, out stairId))
                {
                    stairName.Attributes.Add("style", "background-color:red");
                    stairCotaIndiviza.Attributes.Add("style", "background-color:red");
                }
                else
                {
                    var stairCase = StairCasesManager.GetById(stairId);
                    if (stairCase != null && (stairCase.Nume != stairName.Text || stairCase.Indiviza != newIndivizaValue))
                    {
                        var newStairCase = new StairCases
                        {
                            Nume     = stairName.Text,
                            Indiviza = newIndivizaValue
                        };
                        StairCasesManager.Update(newStairCase, stairId);
                    }

                    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 #5
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 #6
0
        protected void btnAssociationEqualIndiviza_Click(object sender, EventArgs e)
        {
            txtAssociationCotaIndivizaApartments.Attributes.CssStyle.Add("border-color", "");
            if (txtAssociationCotaIndivizaApartments.Enabled)
            {
                if (string.IsNullOrEmpty(txtAssociationCotaIndivizaApartments.Text))
                {
                    txtAssociationCotaIndivizaApartments.Attributes.CssStyle.Add("border-color", "red");
                }
                else
                {
                    txtAssociationCotaIndivizaApartments.Enabled = false;
                    var es = AssociationsManager.GetById(Association.Id);

                    decimal?cotaIndivizaAparmentsResult;
                    decimal cotaIndivizaAparments;
                    if (decimal.TryParse(txtAssociationCotaIndivizaApartments.Text, out cotaIndivizaAparments))
                    {
                        cotaIndivizaAparmentsResult = cotaIndivizaAparments;
                    }
                    else
                    {
                        cotaIndivizaAparmentsResult = null;
                    }
                    es.CotaIndivizaAparments = cotaIndivizaAparments;
                    AssociationsManager.Update(es);
                    Session[SessionConstants.SelectedAssociation] = es;
                    var Associations = AssociationsManager.GetAllAssociationsByPartner(Association.Id_Partner);
                    Session[SessionConstants.AllAssociations] = Associations;
                    Response.Redirect(Request.RawUrl);
                }
            }
            else
            {
                txtAssociationCotaIndivizaApartments.Enabled = true;
            }
        }
Exemple #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Partners partner = Session[SessionConstants.LoggedPartner] as Partners;

            Step = 2;
            decimal?indivizaAparmentsResult = null;

            if (associationStairs.SelectedIndex == 1)
            {
                decimal indivizaAparments;
                if (decimal.TryParse(associationCotaIndivizaApartments.Text, out indivizaAparments))
                {
                    indivizaAparmentsResult = indivizaAparments;
                }
            }

            var association = new Administratoro.DAL.Associations
            {
                Name                  = associationName.Value,
                Address               = associationAddress.Value,
                HasStaircase          = (associationStairs.SelectedIndex == 1),
                Id_Partner            = partner.Id,
                FiscalCode            = associationFiscalCode.Value,
                CotaIndivizaAparments = indivizaAparmentsResult
            };

            var addedAssociation = AssociationsManager.AddNew(association);

            for (int i = 0; i < DynamicStairs.Count; i++)
            {
                var stairName     = FindControl(DynamicStairs.ElementAt(i).Key);
                var stairIndiviza = FindControl(DynamicStairs.ElementAt(i).Value);
                if (stairName is TextBox)
                {
                    TextBox sn = (TextBox)stairName;
                    TextBox si = (TextBox)stairIndiviza;

                    decimal indivizaValue;

                    if (!string.IsNullOrEmpty(sn.Text))
                    {
                        if (decimal.TryParse(si.Text, out indivizaValue))
                        {
                            StairCasesManager.AddNew(association, sn.Text, indivizaValue);
                        }
                        else
                        {
                            StairCasesManager.AddNew(association, sn.Text, null);
                        }
                    }
                }
            }

            addedAssociation = AssociationsManager.GetById(addedAssociation.Id);

            Session[SessionConstants.SelectedAssociation] = addedAssociation;
            var associations = AssociationsManager.GetAllAssociationsByPartner(partner.Id);

            Session[SessionConstants.AllAssociations] = associations;

            ConfigureStep2();
        }