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; } }
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() }); } } } }
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"); }
protected void btnSave2_Click(object sender, EventArgs e) { var association = Session[SessionConstants.SelectedAssociation] as Administratoro.DAL.Associations; Dictionary <int, int> dictionary = GetSelectdExpenses(); AssociationExpensesManager.AddAssociationExpensesByApartmentAndMonth(association.Id, dictionary); association = AssociationsManager.GetById(association.Id); Session[SessionConstants.SelectedAssociation] = association; ConfigureStep3(); }
private void stairsRemove_Click(object sender, EventArgs e) { LinkButton btn = (LinkButton)sender; int stairCaseId; if (int.TryParse(btn.CommandName, out stairCaseId)) { StairCasesManager.Remove(stairCaseId, Association.Id); var es = AssociationsManager.GetById(Association.Id); Session[SessionConstants.SelectedAssociation] = es; InitializeStairs(); } }
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"); }
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); } } }
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); } } }
protected void associationEqualIndiviza_SelectedIndexChanged(object sender, EventArgs e) { var es = AssociationsManager.GetById(Association.Id); if (es.CotaIndivizaAparments.HasValue && drpAssociationEqualIndiviza.SelectedIndex == 0) { es.CotaIndivizaAparments = null; AssociationsManager.Update(es); Session[SessionConstants.SelectedAssociation] = es; } if (drpAssociationEqualIndiviza.SelectedIndex == 0) { txtAssociationCotaIndivizaApartments.Visible = false; btnAssociationEqualIndiviza.Visible = false; } else { txtAssociationCotaIndivizaApartments.Visible = true; btnAssociationEqualIndiviza.Visible = true; } }
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; } }
protected void btnAssociationstairCasesNew_Click(object sender, EventArgs e) { if (newStairCasePanel.Visible) { decimal indiviza; if (!string.IsNullOrEmpty(txtAssociationStairCaseName.Text) && decimal.TryParse(txtAssociationStairCaseIndiviza.Text , out indiviza)) { StairCasesManager.AddNew(Association, txtAssociationStairCaseName.Text, indiviza); var newAssociation = AssociationsManager.GetById(Association.Id); Session[SessionConstants.SelectedAssociation] = newAssociation; Response.Redirect(Request.RawUrl); } else { txtAssociationStairCaseIndiviza.Attributes.CssStyle.Add("border-color", "red"); txtAssociationStairCaseName.Attributes.Add("style", "border-color:red"); } } else { newStairCasePanel.Visible = true; } }
public void RefreshAssociation() { Session[SessionConstants.SelectedAssociation] = AssociationsManager.GetById(Association.Id); }
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(); }