private void ShowPaymentDatails(long p) { var result = new ExpensesManager().GetExpenseDetails(p); if (result != null) { txtInvoiceNo.Text = result.InvoiceCode; txtValue.Text = result.ExpenseValue.ToString(); txtNotes.Text = result.Notes; txtPaymentDate.Text = MinutesuaeConcrete.GetDateOnly(result.PaymentDate); //txt.Text = MinutesuaeConcrete.GetDateOnly(result.DueDate); rblCompanyType.SelectedValue = result.CompanyType; rblCompanyType_SelectedIndexChanged(rblCompanyType, new EventArgs()); ddlCurrencyUsed.SelectedValue = result.Currency_ID.ToString(); //ddlExpenseType.SelectedValue = result.ExpenseType_ID.ToString(); ddlDueforCompany.SelectedValue = result.Company_ID.ToString(); ddlExchangeCo.SelectedValue = result.ExchangeCompany_ID.ToString(); //lblCompanyCode.Text = result.Car_ID.ToString(); //linkCancel.NavigateUrl = "car/" + lblCompanyCode.Text + "/expenses.aspx"; //cbActive.Checked = (bool)result.Active; } }
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() }); } } } }
private void AddBodyPanels(int associationId, int yearNr, int monthNr) { string mainRowCssFormat = "col-md-12 col-sm-12 xs-12 cashBokItemsRow {0}"; bool even = false; IEnumerable <Administratoro.DAL.Expenses> allExpenses = ExpensesManager.GetAllExpenses(); var associationExpenses = AssociationExpensesManager.GetByMonthAndYearNotDisabled(associationId, yearNr, monthNr).OrderBy(ee => ee.Id_ExpenseType); // add expense panels foreach (Expenses expense in allExpenses) { var associationExpense = associationExpenses.FirstOrDefault(ea => ea.Id_Expense == expense.Id); if (associationExpense != null) { var mainCol = new Panel(); if (even) { even = false; mainCol.CssClass = string.Format(mainRowCssFormat, "evenRow"); } else { even = true; mainCol.CssClass = string.Format(mainRowCssFormat, "oddRow"); } bool isExpensePerIndex = associationExpense.ExpenseTypes.Id == (int)ExpenseType.PerIndex; var col0 = AddBodyPanelCol0(associationExpense, isExpensePerIndex); var col1 = AddBodyPanelCol1(expense, associationExpense); TextBox tb2; var col2 = AddBodyPanelCol2(associationExpense, out tb2); TextBox tb3; var col3 = AddBodyPanelCol3(associationExpense, tb2, out tb3); var col6 = AddBodyPanelCol6(associationExpense); var col4 = AddBodyPanelCol4(associationExpense, tb2); var col5 = AddBodyPanelCol5(associationExpense, isExpensePerIndex); mainCol.Controls.Add(col0); mainCol.Controls.Add(col1); mainCol.Controls.Add(col2); mainCol.Controls.Add(col3); mainCol.Controls.Add(col6); mainCol.Controls.Add(col4); mainCol.Controls.Add(col5); invoiceMain.Controls.Add(mainCol); } } }
private void PopulateCounters(Administratoro.DAL.Associations association, int?apartmentId) { estateCounters.Visible = false; //if (association.HasStaircase) if (true) { Administratoro.DAL.Apartments apartment = null; if (apartmentId.HasValue) { apartment = ApartmentsManager.GetById(apartmentId.Value); } Panel headerPanel = new Panel(); Label lbExpense = new Label { Text = "Cheltuială", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; Label lbName = new Label { Text = "Contor alocat", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; Label lbNrCountersPerApartment = new Label { Text = "Numărul de contoare în apartament ", CssClass = "col-md-4 col-xs-4 countersTableHeader" }; headerPanel.Controls.Add(lbExpense); headerPanel.Controls.Add(lbName); headerPanel.Controls.Add(lbNrCountersPerApartment); estateCounters.Controls.Add(headerPanel); IEnumerable <Administratoro.DAL.Expenses> expenses = ExpensesManager.GetAllExpenses(); foreach (var expense in expenses) { PopulateCountersData(association, expense, apartment); } } }
private void FillExpensesList() { // Filter expenses for this car. long cID = 0; if (Page.RouteData.Values["carId"] != null) { cID = Convert.ToInt64(Page.RouteData.Values["carId"]); linkAddExpense.NavigateUrl = "addexpense-" + cID.ToString() + "/1.aspx"; lnkAddADEExpense.NavigateUrl = "addexpense-" + cID.ToString() + "/2.aspx"; } var result = new ExpensesManager().GetExpenses(cID); gvExpenses.DataSource = result.Where(rr => rr.ExchangeRate == 1); // Dollar Currency only. gvExpenses.DataBind(); gvExpensesDirham.DataSource = result.Where(rr => rr.ExchangeRate != 1); // Dirham currency. gvExpensesDirham.DataBind(); // Show short statistics if (result.Count > 0) { //var symb = ((result.Where(ex => ex.ExchangeRate == 1).FirstOrDefault() != null) ? result.Where(ex => ex.ExchangeRate == 1).FirstOrDefault().CurrencySymbol : result.FirstOrDefault().CurrencySymbol); double totDollar = (double)result.Where(rr => rr.ExchangeRate == 1).Sum(a => a.ExpenseValue); double totDirham = (double)result.Where(rr => rr.ExchangeRate < 1).Sum(a => a.ExpenseValue); tblTotalDollar.Visible = (totDollar > 0); divTotalDollar.InnerHtml = string.Format("{0:F} $.", totDollar); tblTotalDirham.Visible = (totDirham > 0); divTotalDirham.InnerHtml = string.Format("{0:F} AED.", totDirham); // 1 usd * 0.2722 = 1 aed. double expTotal = (totDirham + (totDollar / 0.2722)); tblTotalAllAll.Visible = (expTotal > 0); divTotalAll.InnerHtml = string.Format("{0:F} AED.", expTotal); Button2.Visible = true; Button1.Visible = true; } }
private ListItem[] GetExpensesAsListItemsWithExtradummyValue(int controlId) { Dictionary <int, int> expenses = GetSelectdExpenses(); ListItem[] result = new ListItem[expenses.Count]; int i = 0; foreach (var expense in expenses) { var ex = ExpensesManager.GetById(expense.Key); var theExpense = new ListItem { Value = ex.Id + "dummyExpense" + controlId, Text = ex.Name }; result[i] = theExpense; i++; } return(result); }
private void InitializeExpenses() { //tblMonthlyExpenses.Rows.Clear(); int month; int _year = Year().HasValue ? Year().Value : 2017; if (int.TryParse(drpExpenseMonth.SelectedValue, out month)) { var estate = (Associations)Session[SessionConstants.SelectedAssociation]; if (estate != null) { var ee = AssociationExpensesManager.GetByMonthAndYearNotDisabled(estate.Id, _year, month); var eeAlsoDisabled = AssociationExpensesManager.GetAllAssociationExpensesByMonthAndYearIncludingDisabled(estate.Id, _year, month); IEnumerable <Expenses> expenses = ExpensesManager.GetAllExpenses(); foreach (var expense in expenses) { TableRow row = new TableRow(); // add expense that were added TableCell expenseExists = new TableCell(); CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("esateExpense{0}", expense.Id); esexExists.Checked = IsExpenseSelected(expense, ee, _year, month); expenseExists.Controls.Add(esexExists); row.Cells.Add(expenseExists); // add expense name TableCell expenseName = new TableCell { Text = expense.Name }; row.Cells.Add(expenseName); // add expense type TableCell expenseType = new TableCell(); AssociationExpenses esex = eeAlsoDisabled.FirstOrDefault(s => s.Id_Expense == expense.Id && s.Month == month && s.Year == _year && s.Id_Estate == estate.Id); DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { var selected1 = IsDplExpenseTypesSelected(esex, ExpenseType.PerIndex); dp.Items.Add(new ListItem { Value = "1", Text = "Individuală prin indecși", Selected = selected1 }); var selected2 = IsDplExpenseTypesSelected(esex, ExpenseType.PerCotaIndiviza); dp.Items.Add(new ListItem { Value = "2", Text = "Cotă indiviză de proprietate", Selected = selected2 }); var selected3 = IsDplExpenseTypesSelected(esex, ExpenseType.PerNrTenants); dp.Items.Add(new ListItem { Value = "3", Text = "Per număr persoane imobil", Selected = selected3 }); var selected4 = IsDplExpenseTypesSelected(esex, ExpenseType.PerApartament); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerApartament).ToString(), Text = ExpenseType.PerApartament.ToDescription(), Selected = selected4 }); } dp.Items.Add(new ListItem { Value = "6", Text = "Individual", }); expenseType.Controls.Add(dp); row.Cells.Add(expenseType); if (estate.HasStaircase) { TableCell tcStairCase = new TableCell(); CheckBox stairCaseSplit = new CheckBox(); stairCaseSplit.AutoPostBack = false; stairCaseSplit.Checked = IsStairCaseSplitSelected(expense, ee, _year, month); tcStairCase.Controls.Add(stairCaseSplit); row.Cells.Add(tcStairCase); } else { tblMonthlyExpensesStairCaseSplit.Visible = false; } tblMonthlyExpenses.Rows.Add(row); } } } }
private void FillPaymentsList() { #region "Accessing data" string _param = ""; if (Page.RouteData.Values["compId"] != null && Page.RouteData.Values["CompType"] != null && Page.RouteData.Values["CoName"] != null) { string co_ID = Page.RouteData.Values["compId"].ToString(); string co_Type = Page.RouteData.Values["CompType"].ToString(); string co_Name = Page.RouteData.Values["CoName"].ToString(); string currencyId = GetCurrencyID(co_Type); linkAddPayment.NavigateUrl = "addpayment-" + currencyId + "/" + co_Type + "/" + co_ID + ".aspx"; ltlCoName.Text = "(" + co_Name.Replace('-', ' ') + ")"; _param = " AND Company_ID = " + co_ID + " AND CompanyType = '" + co_Type + "' "; } IList <Expenses_GetSelectListResult> result = new ExpensesManager().GetExpenses(_param); #endregion #region "Short Statistics" if (result.Count > 0) { decimal expVal = (decimal)result.Where(e => e.InOutType == "expense").Sum(s => s.ExpenseValue); decimal paymVal = (decimal)result.Where(e => e.InOutType == "payment").Sum(ss => ss.ExpenseValue); var firstBalance = result.FirstOrDefault().OpeningBalance; var usedCurrency = ((result.Where(r => r.ExchangeRate == 1).FirstOrDefault() != null) ? (result.Where(r => r.ExchangeRate == 1).FirstOrDefault().CurrencySymbol) : (result.FirstOrDefault().CurrencySymbol)); decimal openVal = (firstBalance != null ? (decimal)firstBalance : 0); divOpeningbalance.InnerHtml = string.Format("{0:F} {1}", openVal, usedCurrency); divTotalExpense.InnerHtml = "<a href='" + Request.Url.AbsolutePath.Replace("payments", "expenses") + "'>" + string.Format("{0:F} {1}", expVal, usedCurrency) + "</a>"; divTotalPayments.InnerHtml = string.Format("{0:F} {1}", paymVal, usedCurrency); divRemainder.InnerHtml = string.Format("{0:F} {1}", ((openVal + expVal) - paymVal), usedCurrency); Button2.Visible = true; Button1.Visible = true; } #endregion #region "Filter payments lists" result = (from a in result where a.InOutType == "payment" select a).ToList <Expenses_GetSelectListResult>(); if (txtPaymentDateFrom.Text != "") { result = result.Where(p => p.PaymentDate >= Convert.ToDateTime(txtPaymentDateFrom.Text.Trim())).ToList <Expenses_GetSelectListResult>(); // _param += " AND PaymentDate >= CAST('" + txtPaymentDateFrom.Text.Trim() + "' AS DATETIME) "; } if (txtPaymentDateTo.Text != "") { result = result.Where(p => p.PaymentDate <= Convert.ToDateTime(txtPaymentDateTo.Text.Trim())).ToList <Expenses_GetSelectListResult>(); //_param += " AND PaymentDate <= CAST('" + txtPaymentDateTo.Text.Trim() + "' AS DATETIME) "; } if (txtCode.Text != "") { result = result.Where(p => p.InvoiceCode == txtCode.Text.Trim()).ToList <Expenses_GetSelectListResult>(); //_param += " AND InvoiceCode = " + txtCode.Text.Trim(); } gvPayments.DataSource = result; gvPayments.DataBind(); #endregion }
private void FillPaymentsList() { #region "Accessing data" string _param = " AND Active = 1 AND Deleted = 0 AND Store_ID = " + 1 + " AND INOutType = 'payment' "; if (rblType.SelectedValue == "General") { _param += " AND GroupName = 'General' "; } else if (rblType.SelectedValue == "Cars") { _param += " AND (GroupName <> 'General' OR GroupName IS NULL) "; } if (txtExpenseDateFrom.Text != "") { _param += " AND PaymentDate >= " + txtExpenseDateFrom.Text; } if (txtExpenseDateTo.Text != "") { _param += " AND PaymentDate <= " + txtExpenseDateTo.Text; } _param += " ORDER BY ExpenseID DESC "; IList <Expenses_GetSelectListResult> result = new ExpensesManager().GetExpenses(_param); #endregion #region "Short Statistics" gvPayments.DataSource = result.Where(rr => rr.ExchangeRate == 1); // Dollar Currency only. gvPayments.DataBind(); gvExpensesDirham.DataSource = result.Where(rr => rr.ExchangeRate != 1); // Dirham currency. gvExpensesDirham.DataBind(); // Show short statistics if (result.Count > 0) { double totDollar = (double)result.Where(rr => rr.ExchangeRate == 1).Sum(a => a.ExpenseValue); double totDirham = (double)result.Where(rr => rr.ExchangeRate < 1).Sum(a => a.ExpenseValue); tblTotalDollar.Visible = (totDollar > 0); divTotalDollar.InnerHtml = string.Format("{0:F} $.", totDollar); tblTotalDirham.Visible = (totDirham > 0); divTotalDirham.InnerHtml = string.Format("{0:F} AED.", totDirham); // 1 usd * 0.2722 = 1 aed. double expTotal = totDirham + (totDollar * 0.2722); tblTotalAllAll.Visible = (expTotal > 0); divTotalAll.InnerHtml = string.Format("{0:F} AED.", expTotal); Button2.Visible = true; Button1.Visible = true; // Show Safe/Store name. lblStore.Text = string.Format("({0})", result.FirstOrDefault().StoreName); } #endregion }
private void Step2PopulateExpenses() { IEnumerable <Administratoro.DAL.Expenses> expenses = ExpensesManager.GetAllExpenses().OrderBy(e => e.LegalType); foreach (var expense in expenses) { var panel = new Panel { CssClass = "associationNewExpense col-md-6 col-xs-6" }; // add expense that were added CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("expense{0}", expense.Id); panel.Controls.Add(esexExists); // add expense name TableCell expenseName = new TableCell { Text = " " + expense.Name + " " }; panel.Controls.Add(expenseName); // add expense type DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerIndex).ToString(), Text = "Individuală prin indecși", Selected = expense.LegalType == (int)ExpenseType.PerIndex }); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerCotaIndiviza).ToString(), Text = "Cotă indiviză de proprietate", Selected = expense.LegalType == (int)ExpenseType.PerCotaIndiviza }); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerNrTenants).ToString(), Text = "Per număr persoane imobil", Selected = expense.LegalType == (int)ExpenseType.PerNrTenants }); } else { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.Individual).ToString(), Text = "Individual", Selected = expense.LegalType == (int)ExpenseType.Individual }); } panel.Controls.Add(dp); expensesDefault.Controls.Add(panel); } }
private void InitializeExpenses() { tblMonthlyExpenses.Rows.Clear(); int month = 0; int year = 0; if (int.TryParse(drpOpeningMonth.SelectedValue, out month) && int.TryParse(drpOpeningYear.SelectedValue, out year)) { var estate = (Associations)Session[SessionConstants.SelectedAssociation]; if (estate != null) { int defaultYear = 2017; int defaultMonth = 1; var defaultEe = AssociationExpensesManager.GetFromLastestOpenedMonth(estate.Id); if (defaultEe.Any()) { defaultYear = defaultEe.FirstOrDefault().Year; defaultMonth = defaultEe.FirstOrDefault().Month; } var eeAlsoDisabled = AssociationExpensesManager.GetAllAssociationExpensesByMonthAndYearIncludingDisabled(estate.Id, defaultYear, defaultMonth); IEnumerable <Expenses> expenses = ExpensesManager.GetAllExpenses(); var ee = AssociationExpensesManager.GetByMonthAndYearNotDisabled(estate.Id, defaultYear, defaultMonth); TableRow defaultRow = new TableRow(); // add expense exists TableCell defaultExpenseSelected = new TableCell { Text = "Activează pentru noua lună" }; defaultRow.Cells.Add(defaultExpenseSelected); // add expense name TableCell defaultExpenseName = new TableCell { Text = "Cheltuială" }; defaultRow.Cells.Add(defaultExpenseName); // add expense type TableCell defaultExpenseType = new TableCell() { Text = "Tip calcul cheltuială" }; defaultRow.Cells.Add(defaultExpenseType); if (estate.HasStaircase) { TableCell tcStairCaseDefaule = new TableCell() { Text = "Contor individual per scară" }; defaultRow.Cells.Add(tcStairCaseDefaule); } tblMonthlyExpenses.Rows.Add(defaultRow); foreach (var expense in expenses) { TableRow row = new TableRow(); // add expense exists TableCell expenseExists = new TableCell(); CheckBox esexExists = new CheckBox(); esexExists.AutoPostBack = false; esexExists.ID = String.Format("expense{0}", expense.Id); esexExists.Checked = IsExpenseSelected(expense, defaultEe); expenseExists.Controls.Add(esexExists); row.Cells.Add(expenseExists); // add expense name TableCell expenseName = new TableCell { Text = expense.Name }; row.Cells.Add(expenseName); // add expense type TableCell expenseType = new TableCell(); DropDownList dp = new DropDownList(); if (expense.Id != (int)Expense.AjutorÎncălzire) { AssociationExpenses esex = eeAlsoDisabled.FirstOrDefault(s => s.Id_Expense == expense.Id); var selected1 = IsDplExpenseTypesSelected(esex, ExpenseType.PerIndex, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerIndex).ToString(), Text = "Individuală prin indecși", Selected = selected1 }); var selected2 = IsDplExpenseTypesSelected(esex, ExpenseType.PerCotaIndiviza, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerCotaIndiviza).ToString(), Text = "Cotă indiviză de proprietate", Selected = selected2 }); var selected3 = IsDplExpenseTypesSelected(esex, ExpenseType.PerNrTenants, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerNrTenants).ToString(), Text = "Per număr persoane imobil", Selected = selected3 }); var selected4 = IsDplExpenseTypesSelected(esex, ExpenseType.PerApartament, expense.LegalType); dp.Items.Add(new ListItem { Value = ((int)ExpenseType.PerApartament).ToString(), Text = ExpenseType.PerApartament.ToDescription(), Selected = selected4 }); } else { dp.Items.Add(new ListItem { Value = ((int)ExpenseType.Individual).ToString(), Text = "Individual", Selected = expense.LegalType == (int)ExpenseType.Individual }); } expenseType.Controls.Add(dp); row.Cells.Add(expenseType); if (estate.HasStaircase) { TableCell tcStairCase = new TableCell(); CheckBox stairCaseSplit = new CheckBox(); stairCaseSplit.AutoPostBack = false; stairCaseSplit.Checked = IsStairCaseSplitSelected(expense, ee, defaultYear, defaultMonth); tcStairCase.Controls.Add(stairCaseSplit); row.Cells.Add(tcStairCase); } tblMonthlyExpenses.Rows.Add(row); } } } }