/// <summary> /// It will get the Customer Details and returns their Expense details based on that Customer /// </summary> /// <param name="customerId"></param> public void GetCustomerExpenseDetails(int customerId) { try { DataTable dtExpenseDetails = new DataTable(); CustomerBo customerBo = new CustomerBo(); dtExpenseDetails = customerBo.GetCustomerExpenseDetails(customerId); if (dtExpenseDetails.Rows.Count == 0) { btnEdit.Visible = false; btnSave.Text = "Save"; EnableAllControls(); } else { if (dtExpenseDetails.Rows[0]["CE_Transportation"].ToString() != "") { txtTranMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Transportation"].ToString())); txtTranYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Transportation"].ToString()) * 12).ToString(); ddlTranCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeTransportation"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Food"].ToString() != "") { txtFoodMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Food"].ToString())); txtFoodYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Food"].ToString()) * 12).ToString(); ddlFoodCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeFood"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Clothing"].ToString() != "") { txtCloMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Clothing"].ToString())); txtCloYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Clothing"].ToString()) * 12).ToString(); ddlCloCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeClothing"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Home"].ToString() != "") { txtHomeMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Home"].ToString())); txtHomeYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Home"].ToString()) * 12).ToString(); ddlHomeCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeHome"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Utilities"].ToString() != "") { txtUtiMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Utilities"].ToString())); txtUtiYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Utilities"].ToString()) * 12).ToString(); ddlUtiCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeUtilities"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_SelfCare"].ToString() != "") { txtSCMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_SelfCare"].ToString())); txtSCYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_SelfCare"].ToString()) * 12).ToString(); ddlSCCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeSelfCare"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_HealthCare"].ToString() != "") { txtHCMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_HealthCare"].ToString())); txtHCYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_HealthCare"].ToString()) * 12).ToString(); ddlHCCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeHealthCare"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Education"].ToString() != "") { txtEduMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Education"].ToString())); txtEduYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Education"].ToString()) * 12).ToString(); ddlEduCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeEducation"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Pets"].ToString() != "") { txtPetsMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Pets"].ToString())); txtPetsYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Pets"].ToString()) * 12).ToString(); ddlPetsCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodePets"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Entertainment"].ToString() != "") { txtEntMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Entertainment"].ToString())); txtEntYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Entertainment"].ToString()) * 12).ToString(); ddlEntCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeEntertainment"].ToString(); } if (dtExpenseDetails.Rows[0]["CE_Miscellaneous"].ToString() != "") { txtMisMonthly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Miscellaneous"].ToString())); txtMisYearly.Text = String.Format("{0:0.00}", decimal.Parse(dtExpenseDetails.Rows[0]["CE_Miscellaneous"].ToString()) * 12).ToString(); ddlMisCurrency.SelectedValue = dtExpenseDetails.Rows[0]["XC_CurrencyCodeMiscellaneous"].ToString(); } txttotal.Text = (double.Parse(txtTranMonthly.Text) + double.Parse(txtFoodMonthly.Text) + double.Parse(txtCloMonthly.Text) + double.Parse(txtHomeMonthly.Text) + double.Parse(txtUtiMonthly.Text) + double.Parse(txtSCMonthly.Text) + double.Parse(txtHCMonthly.Text) + double.Parse(txtEduMonthly.Text) + double.Parse(txtPetsMonthly.Text) + double.Parse(txtEntMonthly.Text) + double.Parse(txtMisMonthly.Text)).ToString(); txttotalyear.Text = (double.Parse(txtTranYearly.Text) + double.Parse(txtFoodYearly.Text) + double.Parse(txtCloYearly.Text) + double.Parse(txtHomeYearly.Text) + double.Parse(txtUtiYearly.Text) + double.Parse(txtSCYearly.Text) + double.Parse(txtHCYearly.Text) + double.Parse(txtEduYearly.Text) + double.Parse(txtPetsYearly.Text) + double.Parse(txtEntYearly.Text) + double.Parse(txtMisYearly.Text)).ToString(); if (dtExpenseDetails.Rows[0]["CE_DateOfEntry"].ToString() != "") { txtDateOfEntry.Text = DateTime.Parse(dtExpenseDetails.Rows[0]["CE_DateOfEntry"].ToString()).ToShortDateString(); } btnEdit.Visible = true; btnSave.Text = "Update"; btnSave.Visible = false; DisableAllControls(); } } catch (BaseApplicationException Ex) { throw Ex; } catch (Exception Ex) { BaseApplicationException exBase = new BaseApplicationException(Ex.Message, Ex); NameValueCollection FunctionInfo = new NameValueCollection(); FunctionInfo.Add("Method", "CustomerIncome.ascx:GetCustomerIncomeDetails()"); object[] objects = new object[1]; objects[0] = customerId; FunctionInfo = exBase.AddObject(FunctionInfo, objects); exBase.AdditionalInformation = FunctionInfo; ExceptionManager.Publish(exBase); throw exBase; } }