protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["LogedInUser"] != null && (Session["LogedInUser"] as DAL.Login) != null) { DAL.Login login = Session["LogedInUser"] as DAL.Login; if (login != null) { lblUserName.Text = login.Name; LoansBLL loanBLL = new LoansBLL(); lblDetails.InnerText = DateTime.Now.ToString() + " - " + loanBLL.GetLoanCount() + " Records in Loans DB"; // Show the Admin tab only to Administrator role if (login.Role == AppConstants.Roles.Admin.ToString() && !string.IsNullOrEmpty(Request.Path)) { hlAdministration.Visible = true; if (Request.Path.Contains("Administration")) { hlAdministration.Text = "Main"; hlAdministration.NavigateUrl = "~/Default.aspx"; lblAdministration.Visible = true; } else if (Request.Path.Contains("/administration.aspx")) { hlAdministration.Text = "Main"; hlAdministration.NavigateUrl = "~/Default.aspx"; lblAdministration.Visible = true; } else { hlAdministration.Text = "Administration"; hlAdministration.NavigateUrl = "~/Administration.aspx"; } } else { hlAdministration.Visible = false; lblAdministration.Visible = false; } } } } }
private List<Loans> ExtractLoanList(DataTable csvData, List<string> columnNames) { List<Loans> importedList = new List<Loans>(); // string strMessage = ""; try { // Get All properties //PropertyInfo[] properties = model.GetType().GetProperties(); //foreach (PropertyInfo pInfo in properties) //{ // if (columnNames.Contains(pInfo.Name)) // { // object value = row[pInfo.Name]; // TypeConverter typeConverter = TypeDescriptor.GetConverter(pInfo.PropertyType); // object propValue = null; // if (typeConverter.GetType().FullName == "System.ComponentModel.NullableConverter") // { // if (value.ToString().Trim() == "1" || value.ToString().Trim() == "Yes") // { // propValue = typeConverter.ConvertFromString(("True")); // } // } // else // propValue = typeConverter.ConvertFromString((value.ToString())); // // Set value on the property // pInfo.SetValue(model, propValue, null); // } foreach (DataRow dr in csvData.Rows) { Loans model = new Loans(); model.CodeName = dr["CodeName"].ToString(); // model.AmortisationsStartPoint = dr["AmortisationsStartPoint"].ToString(); model.Borrower = dr["Borrower"].ToString(); if (dr["Gurantor"] != null ) { model.Gurantor = dr["Gurantor"].ToString(); } model.Country = dr["Country"].ToString(); model.Grid = dr["Grid"].ToString(); model.SummitCreditEntity = dr["SummitCreditEntity"].ToString(); model.CreditRatingModys = dr["CreditRatingModys"].ToString(); model.CreditRatingSPs = dr["CreditRatingSPs"].ToString(); model.CreditRatingFitch = dr["CreditRatingFitch"].ToString(); model.CreditRatingING = dr["CreditRatingING"].ToString(); model.StructureID = dr["StructureID"].ToString(); model.PP = dr["PP"].ToString(); model.Sector = dr["Sector"].ToString(); model.FacilitySize = dr["FacilitySize"].ToString(); model.Signing_Date = dr["Signing_Date"].ToString(); model.Maturity_Date = dr["Maturity_Date"].ToString(); model.CouponDate = dr["CouponDate"].ToString(); model.FixedOrFloating = dr["FixedOrFloating"].ToString(); model.Margin = dr["Margin"].ToString(); model.Notional = dr["Notional"].ToString(); model.Currency = dr["Currency"].ToString(); model.CouponFrequency = dr["CouponFrequency"].ToString(); if (dr["Bilateral"].ToString() == "Yes") model.Bilateral = true; else model.Bilateral = false; //model.Amortizing = dr["Amortizing"].ToString(); model.Amortizing = "Yes"; if (dr["AmortisationsStartPoint"].ToString() != string.Empty) { model.AmortisationsStartPoint = dr["AmortisationsStartPoint"].ToString(); } else model.AmortisationsStartPoint = dr["CouponDate"].ToString(); if (dr["NoOfAmortisationPoint"].ToString().Trim() != string.Empty) model.NoOfAmortisationPoint = Convert.ToInt16(dr["NoOfAmortisationPoint"]); else model.NoOfAmortisationPoint = GetNoOfAmortisations(); importedList.Add(model); LoansBLL bll = new LoansBLL(); string str = bll.AddImportedLoans(model); if (str != "") { RadWindowManager1.RadAlert(str, 330, 180, "realedge associates", "alertCallBackFn"); } } } catch (Exception ex) { } return importedList; }
private void SetLoanC(string loanName, RadDatePicker dt) { //Fill up the detail now LoansBLL bll = new LoansBLL(); //Loans loan = bll.GetLoanByCode(txtLoanNameC.Text); // txtBoxTradeDate3.SelectedDate = DateTime.Now; string strLoanName = loanName; if (strLoanName.Contains(';')) { strLoanName = strLoanName.Replace(';', ' '); } // Session.Add("Legend", strLoanName); Loans loan = bll.GetLoanByCode(strLoanName.Trim()); //lblNameC.Visible = true; //lblLoanNameC.Visible = true; //lblLoanNameC.InnerText = strLoanName; txtBoxTradeDate3.SelectedDate = Convert.ToDateTime(Session["Trade3"]); try { QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL(); QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(loanName); if (quotes != null) { if (quotes.BidPrice != null) txtBoxBidPriceC.Text = quotes.BidPrice.Value.ToString(); if (quotes.BidSpread != null) txtBoxBidSpreadC.Text = quotes.BidSpread.Value.ToString(); if (quotes.OfferPrice != null) txtBoxOfferPriceC.Text = quotes.OfferPrice.Value.ToString(); if (quotes.OfferSpread != null) txtBoxOfferSpreadC.Text = quotes.OfferSpread.Value.ToString(); if (quotes.AverageLife != null) txtAvgLifeC.Text = quotes.AverageLife.Value.ToString(); if (quotes.AvgLifeDisc != null) txtBoxAveLifDiscC.Text = quotes.AvgLifeDisc.Value.ToString(); if (quotes.AvgLifeRiskDisc != null) txtBoxAveLifRiskyDiscC.Text = quotes.AvgLifeRiskDisc.Value.ToString(); if (quotes.Traded != null) chkBoxTradedC.Checked = quotes.Traded.Value; } } catch (Exception) { } txtLoanNameC.SelectedValue = strLoanName; if (txtBoxTradeDate3.SelectedDate != null) { txtBoxSettlementDate3.SelectedDate = AddBusinessDays(txtBoxTradeDate3.SelectedDate.Value, 10); } if (loan != null) { hfSelectedLoanC.Value = loan.ID.ToString(); if (loan.Signing_Date != string.Empty || loan.Signing_Date != "") { txtBoxSettlementDate3.SelectedDate = Convert.ToDateTime(loan.Signing_Date); } if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "") { txtMaturityDateC.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); } txtInterestRateC.Text = loan.Margin; // txtLoanNameC.Text = loan.CodeName; // Nik Commented //txtDiscountMarginC.Text = loan.Margin; txtCurrencyC.Text = loan.Currency; txtBoxCouponFrequencyLoanC.Text = loan.CouponFrequency; txtLastFixingC.Text = loan.FixedOrFloating; // txtBoxIRCouponC.Text = loan.Margin; //DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency); //if (frequency != null) //{ // frequency.Selected = true; //} if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null) {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty ComputeCouponDatesAndFractions(dt, txtLoanNameC, txtBoxSettlementDate3, txtMaturityDateC, txtBoxCouponFrequencyLoanC, txtBoxAveLifNonDiscC, grdCalculatedDates3, 3, txtBoxNotional3, txtInterestRateC, txtCurrencyC); } else { grdCalculatedDates3.DataSource = null; grdCalculatedDates3.DataBind(); RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn"); } LogActivity("Compute the CashFlow C", "Compute the cashflow for compact view C", string.Empty); } else { RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn"); } }
private void SetLoanA() { //Fill up the detail now try { LoansBLL bll = new LoansBLL(); string strLoanName = txtLoanNameA.Text.ToString(); txtBoxTradeDate1.SelectedDate = DateTime.Now; if (strLoanName.Contains(';')) { strLoanName = strLoanName.Replace(';', ' '); } Loans loan = bll.GetLoanByCode(strLoanName.Trim()); //lblNameA.Visible = true; //lblLoanNameA.Visible = true; //lblLoanNameA.InnerText = strLoanName; txtLoanNameA.SelectedValue = strLoanName; try { QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL(); QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(strLoanName); if (quotes != null) { if (quotes.BidPrice != null) txtBidPriceA.Text = quotes.BidPrice.Value.ToString(); if (quotes.BidSpread != null) txtBidSpreadA.Text = quotes.BidSpread.Value.ToString(); if (quotes.OfferPrice != null) txtOfferPriceA.Text = quotes.OfferPrice.Value.ToString(); if (quotes.OfferSpread != null) txtOfferSpreadA.Text = quotes.OfferSpread.Value.ToString(); if (quotes.AverageLife != null) txtAvgLifeA.Text = quotes.AverageLife.Value.ToString(); if (quotes.AvgLifeDisc != null) txtAveLifDiscA.Text = quotes.AvgLifeDisc.Value.ToString(); if (quotes.AvgLifeRiskDisc != null) txtAveLifRiskyDiscA.Text = quotes.AvgLifeRiskDisc.Value.ToString(); if (quotes.Traded != null) chkBoxTradedA.Checked = quotes.Traded.Value; } } catch (Exception) { } if (txtBoxTradeDate1.SelectedDate != null) { txtBoxSettlementDate1.SelectedDate = AddBusinessDays(txtBoxTradeDate1.SelectedDate.Value, 10); } Session.Add("LegendA", strLoanName); if (loan != null) { hfSelectedLoanA.Value = loan.ID.ToString(); if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "") { txtBoxMaturityDateA.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); } txtBoxInterestRateA.Text = loan.Margin; //by Nidhi // txtLoanNameA.Text = loan.CodeName; / Nik Commented //txtDiscountMarginA.Text = loan.Margin; txtBoxCurrencyLoanA.Text = loan.Currency; txtBoxCouponFrequencyLoanA.Text = loan.CouponFrequency; txtBoxLastFixingA.Text = loan.FixedOrFloating; // txtBoxIRCouponA.Text = loan.Margin; ddlCounterPartyA.SelectedValue = "CounterPartyA"; //nik commneted 02-04 if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null) {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty ComputeCouponDatesAndFractions(txtBoxTradeDate1, txtLoanNameA, txtBoxSettlementDate1, txtBoxMaturityDateA, txtBoxCouponFrequencyLoanA, txtAveLifNonDiscA, grdCalculatedDates1, 1, txtBoxNotional1, txtBoxInterestRateA, txtBoxCurrencyLoanA); } else { grdCalculatedDates1.DataSource = null; grdCalculatedDates1.DataBind(); RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn"); } LogActivity("Compute the CashFlow A", "Compute the cashflow for compact view A", string.Empty); } else { RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn"); } } catch (Exception ex) { RadWindowManager1.RadAlert("Error in SetLoan A : " + ex.Message, 330, 180, "realedge associates", "alertCallBackFn"); } }
private void InsertDuplicateRecord() { try { DuplicateRecord model = new DuplicateRecord(); if (!string.IsNullOrEmpty(txtBidPriceA.Text)) { model.BidPrice = Convert.ToDecimal(txtBidPriceA.Text); } if (!string.IsNullOrEmpty(txtBidSpreadA.Text)) { string strBidSpread = Convert.ToDecimal(txtBidSpreadA.Text).ToString("0.00"); model.BidSpread = Convert.ToDecimal(strBidSpread); } model.CounterParty = ddlCounterPartyA.SelectedValue; model.LoanName = txtLoanNameA.Text; if (!string.IsNullOrEmpty(txtOfferPriceA.Text)) { model.OfferPrice = Convert.ToDecimal(txtOfferPriceA.Text); } if (!string.IsNullOrEmpty(txtOfferSpreadA.Text)) { string strOfferSpread = Convert.ToDecimal(txtOfferSpreadA.Text).ToString("0.00"); model.OfferSpread = Convert.ToDecimal(strOfferSpread); } // model.MarketValue model.TimeStamp = DateTime.UtcNow; model.Traded = chkBoxTradedA.Checked; if (txtLoanNameA.SelectedValue != string.Empty) { LoansBLL loanBLL = new LoansBLL(); model.Country = loanBLL.GetCoutryIDbyLoanID(txtLoanNameA.SelectedValue); } // model.CountryID = Convert.ToInt32(ddlRegionA.SelectedValue); //need to ask whether to keep this lines or not? //List<QuotesAndTrades> lst = new List<QuotesAndTrades>(); //lst.Add(model); QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); bll.InsertDuplicateRecord(model); } catch (Exception ex) { lblTradeQuoteStatusC.Text = "Error in saving"; LogActivity("Quote and Loan A added(Unsuccessfull)", "Unable to add the quote and trade", ex.Message); } }
private Loans GetLoanByName(string loanName) { LoansBLL bll = new LoansBLL(); Loans loan = bll.GetLoanByCode(loanName); return loan; }
private void ComputeCouponDatesAndFractions(RadDatePicker txtBoxTradeDate, RadComboBox txtBoxLoanName, RadDatePicker txtBoxSettlementDate, RadDatePicker txtBoxMaturityDate, RadTextBox txtBoxCouponFrequency, RadTextBox txtNonDiscountedAverageLife, RadGrid grdCalculatedDates, int type, RadTextBox txtNotional, RadTextBox txtMargin, RadTextBox txtCurrency) { try { int countryID = getCountryForLoan(txtBoxLoanName); //PublicHolidayBLL bll = new PublicHolidayBLL(); //List<tblHoliday> publicHolidays = bll.GetPublicHolidays(countryID); List<CalculatedDates> calculatedList = new List<CalculatedDates>(); DateTime cpnDT; cpnDT = AddBusinessDays(DateTime.Now, 10); LoanScheduleBL loanScheduleBL = new LoanScheduleBL(); DataTable dtSchedule = loanScheduleBL.GenerateTable(15, 10, cpnDT, txtBoxCouponFrequency.Text, txtNotional.Text, txtBoxMaturityDate.SelectedDate.Value, cpnDT, Convert.ToDecimal(txtMargin.Text), Convert.ToString(txtCurrency.Text), Convert.ToDateTime(txtBoxTradeDate.SelectedDate.Value), txtBoxSettlementDate.SelectedDate.Value); if (dtSchedule.Rows.Count > 0) { LoansBLL loanBL = new LoansBLL(); int loanID = loanBL.GetLoanByCode(txtBoxLoanName.Text).ID; loanScheduleBL.EditSchedule(loanID, dtSchedule); } foreach (DataRow dr in dtSchedule.Rows) { CalculatedDates cal = new CalculatedDates(); cal.Fraction = dr["CoupFrac"].ToString(); cal.CalculatedDate = Convert.ToDateTime(dr["EndDate"]); calculatedList.Add(cal); } grdCalculatedDates.Visible = true; grdCalculatedDates.DataSource = calculatedList; grdCalculatedDates.DataBind(); switch (type) { case 1: tempCalculatedList1 = calculatedList; break; case 2: tempCalculatedList2 = calculatedList; break; case 3: tempCalculatedList3 = calculatedList; break; default: break; } } catch (Exception) { } }
private string CalculateIRR(string loanName, string marketPrice) { LoansBLL bll = new LoansBLL(); Loans loan = bll.GetLoanByCode(loanName); int loanID = loan.ID; double notional = Convert.ToDouble(loan.Notional); LoanScheduleBL loanScheduleBL = new LoanScheduleBL(); List<LoanSchedule> loanSchedule = new List<LoanSchedule>(); loanSchedule = loanScheduleBL.GetLoanByID(loanID); double[] cashFlows; double[] days; List<DateTime> scheduleDateTime = new List<DateTime>(); if (loanSchedule != null) { List<double> cashFlowDouble = new List<double>(); double mktPrice = 0.99; if (marketPrice != string.Empty) { mktPrice = Convert.ToDouble(marketPrice) / 100; } double dFirstCashFlow = (Convert.ToDouble(mktPrice) * Convert.ToDouble(notional)) * -1; scheduleDateTime.Add(loanSchedule.First().StartDate.Value); cashFlowDouble.Add(dFirstCashFlow); List<double> day = new List<double>(); foreach (var item in loanSchedule) { cashFlowDouble.Add(Convert.ToDouble(item.AmortisationInt)); day.Add(Convert.ToInt16(item.Days)); scheduleDateTime.Add(Convert.ToDateTime(item.EndDate)); } cashFlows = cashFlowDouble.ToArray(); days = day.ToArray(); } else { cashFlows = new double[1] { 0.0 }; days = new double[1] { 0.0 }; } //Zainco.NewtonRaphson.IRRCalculator.Domain.ICalculator calculator = new NewtonRaphsonIRRCalc(cashFlows); //Double d = calculator.Execute(); IRR irr = new IRR(); //double xirr = irr.Newtons_method(0.1, // irr.total_f_xirr(cashFlows, days), // irr.total_df_xirr(cashFlows, days)); double xirr = System.Numeric.Financial.XIrr(cashFlows, scheduleDateTime) * 100; return Convert.ToDecimal(xirr).ToString("0.00"); // return d; }
protected void grdLoans_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "Edit") { int id = Convert.ToInt32(e.CommandArgument); Session.Add("EditLoanID", id); Response.Redirect("default.aspx?page=addstaticloan"); } else if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); LoansBLL loansBll = new LoansBLL(); string loanName = Convert.ToString(loansBll.GetLoanByID(id).CodeName); loansBll.RemoveLoan(id); DAL.Login login = Session["LogedInUser"] as DAL.Login; LoanHistory history = new LoanHistory(); LoanHistoryBL historyBL = new LoanHistoryBL(); history.Action = "Delete"; history.LastModified = DateTime.Now; history.LoanName = loanName; history.UserName = login.Name; historyBL.SaveHistory(history); RadWindowManager1.RadAlert("Loan removed successfully", 330, 180, "realedge associates", "alertCallBackFn"); } BindLoansData(); }
protected void grdLoans_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e) { DataTable data = new DataTable(); switch (e.Column.DataField) { case "CodeName": data.Columns.Add("CodeName"); LoansBLL loansBLL = new LoansBLL(); List<Loans> loans = loansBLL.GetLoans(); for (int i = 0; i <= loans.Count - 1; i++) { data.Rows.Add(loans[i].CodeName); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CodeName"; e.ListBox.DataTextField = "CodeName"; e.ListBox.DataValueField = "CodeName"; e.ListBox.DataBind(); break; case "Borrower": data = new DataTable(); data.Columns.Add("Borrower"); BorrowersBL borrowerBL = new BorrowersBL(); List<Borrower> borrower = borrowerBL.GetBorrowers(); for (int i = 0; i < borrower.Count - 1; i++) { data.Rows.Add(borrower[i].Name); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Borrower"; e.ListBox.DataTextField = "Borrower"; e.ListBox.DataValueField = "Borrower"; e.ListBox.DataBind(); break; case "Country": data = new DataTable(); data.Columns.Add("Country"); CountryBL CountryBL = new CountryBL(); List<tblCountry> country = CountryBL.GetCountry(); for (int i = 0; i < country.Count - 1; i++) { data.Rows.Add(country[i].Name); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Country"; e.ListBox.DataTextField = "Country"; e.ListBox.DataValueField = "Country"; e.ListBox.DataBind(); break; case "CreditRating": data = new DataTable(); data.Columns.Add("CreditRating"); CreditRatingsBL CreditRatingsBL = new CreditRatingsBL(); List<CreditRating> CreditRating = CreditRatingsBL.GetRatings(); for (int i = 0; i < CreditRating.Count - 1; i++) { data.Rows.Add(CreditRating[i].Rating); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CreditRating"; e.ListBox.DataTextField = "CreditRating"; e.ListBox.DataValueField = "CreditRating"; e.ListBox.DataBind(); break; case "Sector": data = new DataTable(); data.Columns.Add("Sector"); LoansBLL loansBll = new LoansBLL(); List<Sectors> sector = loansBll.GetSector(); for (int i = 0; i < sector.Count; i++) { if (sector[i] != null) { data.Rows.Add(sector[i].Sector); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Sector"; e.ListBox.DataTextField = "Sector"; e.ListBox.DataValueField = "Sector"; e.ListBox.DataBind(); break; case "PP": data = new DataTable(); data.Columns.Add("PP"); loansBll = new LoansBLL(); List<PP> pp = loansBll.GetPP(); for (int i = 0; i < pp.Count; i++) { if (pp[i] != null) { data.Rows.Add(pp[i].pp); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "PP"; e.ListBox.DataTextField = "PP"; e.ListBox.DataValueField = "PP"; e.ListBox.DataBind(); break; case "FixedOrFloating": data = new DataTable(); data.Columns.Add("FixedOrFloating"); loansBll = new LoansBLL(); List<BLL.FixedOrFloating> fof = loansBll.GetFixedFloating(); for (int i = 0; i < fof.Count; i++) { if (fof[i] != null) { data.Rows.Add(fof[i].fixedorfloating); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "FixedOrFloating"; e.ListBox.DataTextField = "FixedOrFloating"; e.ListBox.DataValueField = "FixedOrFloating"; e.ListBox.DataBind(); break; case "Notional": data = new DataTable(); data.Columns.Add("Notional"); loansBll = new LoansBLL(); List<BLL.Notional> notional = loansBll.GetNotional(); for (int i = 0; i < notional.Count; i++) { if (notional[i] != null) { data.Rows.Add(notional[i].notional); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Notional"; e.ListBox.DataTextField = "Notional"; e.ListBox.DataValueField = "Notional"; e.ListBox.DataBind(); break; case "Margin": data = new DataTable(); data.Columns.Add("Margin"); loansBll = new LoansBLL(); List<BLL.Margin> margin = loansBll.GetMargin(); for (int i = 0; i < margin.Count; i++) { if (margin[i] != null) { data.Rows.Add(margin[i].margin); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Margin"; e.ListBox.DataTextField = "Margin"; e.ListBox.DataValueField = "Margin"; e.ListBox.DataBind(); break; case "Currency": data = new DataTable(); data.Columns.Add("Currency"); CurrenciesBL currencyBL = new CurrenciesBL(); List<Currency> currency = currencyBL.GetCurrency(); for (int i = 0; i < currency.Count; i++) { if (currency[i].Currancy != null) { data.Rows.Add(currency[i].Currancy); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "Currency"; e.ListBox.DataTextField = "Currency"; e.ListBox.DataValueField = "Currency"; e.ListBox.DataBind(); break; case "CouponFrequency": data = new DataTable(); data.Columns.Add("CouponFrequency"); loansBll = new LoansBLL(); List<BLL.CouponFrequency> couponFreq = loansBll.GetCouponFrequency(); for (int i = 0; i < couponFreq.Count; i++) { if (couponFreq[i] != null) { data.Rows.Add(couponFreq[i].coupon); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CouponFrequency"; e.ListBox.DataTextField = "CouponFrequency"; e.ListBox.DataValueField = "CouponFrequency"; e.ListBox.DataBind(); break; case "FacilitySize": data = new DataTable(); data.Columns.Add("FacilitySize"); loansBll = new LoansBLL(); List<BLL.FacilitySize> facility = loansBll.GetFacilitySize(); for (int i = 0; i < facility.Count; i++) { if (facility[i] != null) { data.Rows.Add(facility[i].facility); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "FacilitySize"; e.ListBox.DataTextField = "FacilitySize"; e.ListBox.DataValueField = "FacilitySize"; e.ListBox.DataBind(); break; case "CreditRatingModys": data = new DataTable(); data.Columns.Add("CreditRatings"); loansBll = new LoansBLL(); List<CreditRating> creditRatingModdys = loansBll.GetCreditRatingModdys(); for (int i = 0; i < creditRatingModdys.Count; i++) { data.Rows.Add(creditRatingModdys[i].Rating); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CreditRatings"; e.ListBox.DataTextField = "CreditRatings"; e.ListBox.DataValueField = "CreditRatings"; e.ListBox.DataBind(); break; case "CreditRatingSPs": data = new DataTable(); data.Columns.Add("CreditRatings"); loansBll = new LoansBLL(); List<CreditRating> creditRatingSPs = loansBll.GetCreditRatingSP(); for (int i = 0; i < creditRatingSPs.Count; i++) { data.Rows.Add(creditRatingSPs[i].Rating); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CreditRatings"; e.ListBox.DataTextField = "CreditRatings"; e.ListBox.DataValueField = "CreditRatings"; e.ListBox.DataBind(); break; case "CreditRatingFitch": data = new DataTable(); data.Columns.Add("CreditRatings"); loansBll = new LoansBLL(); List<CreditRating> creditRatingFitch = loansBll.GetCreditRatingFitch(); for (int i = 0; i < creditRatingFitch.Count; i++) { data.Rows.Add(creditRatingFitch[i].Rating); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CreditRatings"; e.ListBox.DataTextField = "CreditRatings"; e.ListBox.DataValueField = "CreditRatings"; e.ListBox.DataBind(); break; case "CreditRatingING": data = new DataTable(); data.Columns.Add("CreditRatings"); loansBll = new LoansBLL(); List<CreditRating> creditRatingING = loansBll.GetCreditRatingING(); for (int i = 0; i < creditRatingING.Count; i++) { data.Rows.Add(creditRatingING[i].Rating); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CreditRatings"; e.ListBox.DataTextField = "CreditRatings"; e.ListBox.DataValueField = "CreditRatings"; e.ListBox.DataBind(); break; //case "NoOfAmortisation": // data = new DataTable(); // data.Columns.Add("NoOfAmortrization"); // loansBll = new LoansBLL(); // List<BLL.NoOfAmortrization> noOfAmort = loansBll.GetNoOfAmortrization(); // for (int i = 0; i < noOfAmort.Count; i++) // { // if (noOfAmort[i] != null) // { // data.Rows.Add(noOfAmort[i].noofAmort); // } // } // e.ListBox.DataSource = data; // e.ListBox.DataKeyField = "noofAmort"; // e.ListBox.DataTextField = "noofAmort"; // e.ListBox.DataValueField = "noofAmort"; // e.ListBox.DataBind(); // break; case "StructureID": data = new DataTable(); data.Columns.Add("StructureID"); loansBll = new LoansBLL(); List<BLL.StructureID> structure = loansBll.GetStructureID(); for (int i = 0; i < structure.Count; i++) { if (structure[i] != null) { data.Rows.Add(structure[i].structureID); } } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "StructureID"; e.ListBox.DataTextField = "StructureID"; e.ListBox.DataValueField = "StructureID"; e.ListBox.DataBind(); break; default: break; } //// sector //data = new DataTable(); //data.Columns.Add("CreditRating"); //CreditRatingsBL CreditRatingsBL = new CreditRatingsBL(); //List<CreditRating> CreditRating = CreditRatingsBL.GetRatings(); //for (int i = 0; i < CreditRating.Count - 1; i++) //{ // data.Rows.Add(CreditRating[i].Rating); //} //e.ListBox.DataSource = data; //e.ListBox.DataKeyField = "CreditRating"; //e.ListBox.DataTextField = "CreditRating"; //e.ListBox.DataValueField = "CreditRating"; //e.ListBox.DataBind(); }
protected DataTable GetCompactChartData(string loanName) { try { DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("EndDate"); dt.Columns.Add("Notation"); LoansBLL loanBL = new LoansBLL(); int loanID = loanBL.GetLoanByCode(loanName).ID; LoanScheduleBL loanScheduleBL = new LoanScheduleBL(); List<LoanSchedule> loanSchedule = loanScheduleBL.GetLoanByID(loanID); if (loanSchedule != null) { for (int i = 0; i < loanSchedule.Count; i++) { dt.Rows.Add((i + 1), new DateTime(loanSchedule[i].EndDate.Value.Year, loanSchedule[i].EndDate.Value.Month, loanSchedule[i].EndDate.Value.Day), loanSchedule[i].Notation.ToString()); } } return dt; } catch (Exception) { return null; } }
protected void tmrLoanDiv_Tick(object sender, EventArgs e) { LoansBLL loanBLL = new LoansBLL(); lblDetails.InnerText = DateTime.Now.ToString() + " - " + loanBLL.GetLoanCount() + " Records in Loans DB"; }
protected void ExportToCSV() { string csv_file_path = Server.MapPath("~/Temp/tempfile1.csv"); if (ddlImportType.SelectedValue == "Loan") { LoansBLL bll = new LoansBLL(); var loanList = bll.GetLoans().Select(x => new { LoanName = x.CodeName, Borrower = x.Borrower, Country = x.Country, Sector = x.Sector, SigingDate = x.Signing_Date, MaturityDate = x.Maturity_Date, FixedOrFloating = x.FixedOrFloating, Margin = x.Margin, Currency = x.Currency, CouponFrequency = x.CouponFrequency, FacilitySize = x.FacilitySize, Bilateral = x.Bilateral, Amortizing = x.Amortizing, CouponDate = x.CouponDate, Notional = x.Notional, AmortisationsStartPoint = x.AmortisationsStartPoint, NoOfAmortisationPoint = x.NoOfAmortisationPoint, StructureID = x.StructureID, PP = x.PP, FixedFloating = x.Fixed_Floating, CreditRatingModys = x.CreditRatingModys, CreditRatingSPs = x.CreditRatingSPs, CreditRatingFitch = x.CreditRatingFitch, CreditRatingING = x.CreditRatingING, Gurantor = x.Gurantor, Grid = x.Grid, SummitCreditEntity = x.SummitCreditEntity }); List<LoanTable> loanTable = new List<LoanTable>(); foreach (var item in loanList) { loanTable.Add(new LoanTable(item.LoanName, item.Borrower, item.Country, Convert.ToDateTime(item.SigingDate), Convert.ToDateTime(item.MaturityDate), item.FixedOrFloating, item.Margin, item.Currency, item.CouponFrequency, item.FacilitySize, Convert.ToBoolean(item.Bilateral), item.Amortizing, Convert.ToDateTime(item.CouponDate), item.Notional, item.AmortisationsStartPoint, Convert.ToInt16(item.NoOfAmortisationPoint), item.StructureID, item.PP, item.FixedFloating, item.CreditRatingModys, item.CreditRatingSPs, item.CreditRatingFitch, item.CreditRatingING, item.Gurantor, item.Grid, item.SummitCreditEntity)); } BLL.CsvExport<LoanTable> exportHelper = new CsvExport<LoanTable>(loanTable); exportHelper.ExportToFile(csv_file_path); LogActivity("Loans Exported", "Export the Loans", string.Empty); } else if (ddlImportType.SelectedValue == "Quotes") { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); var quotesList = bll.GetQuotesAndTrades().Select(x => new { LoanName = x.LoanName, TimeStamp = x.TimeStamp, CounterParty = x.CounterParty, BidPrice = x.BidPrice, OfferPrice = x.OfferPrice, BidSpread = x.BidSpread, OfferSpread = x.OfferSpread, Traded = x.Traded, MarketValue = x.MarketValue, Country = x.Country, AverageLife = x.AverageLife, AvgLifeDisc = x.AvgLifeDisc, AvgLifeRiskDisc = x.AvgLifeRiskDisc, AvgLifeNonDisc = x.AvgLifeNonDisc, SettlementDate = x.SettlementDate, Margin = x.Margin }); List<HistoricalQuote> quotes = new List<HistoricalQuote>(); foreach (var item in quotesList) { quotes.Add(new HistoricalQuote(item.LoanName, Convert.ToDateTime(item.TimeStamp.Value), item.CounterParty, Convert.ToDecimal(item.BidPrice), Convert.ToDecimal(item.OfferPrice), Convert.ToDecimal(item.BidSpread), Convert.ToDecimal(item.OfferSpread), Convert.ToBoolean(item.Traded), Convert.ToDecimal(item.MarketValue), item.Country, Convert.ToDecimal(item.AverageLife), Convert.ToDecimal(item.AvgLifeDisc), Convert.ToDecimal(item.AvgLifeRiskDisc), Convert.ToDecimal(item.AvgLifeNonDisc), Convert.ToDateTime(item.SettlementDate), item.Margin)); } BLL.CsvExport<HistoricalQuote> exportHelper = new CsvExport<HistoricalQuote>(quotes); exportHelper.ExportToFile(csv_file_path); LogActivity("QuotesAndTrades Exported", "Export the quotesAndtrades", string.Empty); } else if (ddlImportType.SelectedValue == "EUR Curve") { EURCurvesBL bll = new EURCurvesBL(); var list = bll.GetEURCurve().Select(x => new { UploadDate = x.UploadDate, SummitGenDate = x.SummitGenDate, CCY = x.CCY, Index = x.CurveIndex, Days = x.Days, Rate = x.Rate, DiscFreq = x.DiscFreq }); List<EURCurveTable> eurTable = new List<EURCurveTable>(); foreach (var item in list) { eurTable.Add(new EURCurveTable(Convert.ToDateTime(item.UploadDate), Convert.ToDateTime(item.SummitGenDate), item.CCY, item.Index, Convert.ToInt16(item.Days), Convert.ToDecimal(item.Rate), Convert.ToDecimal(item.DiscFreq))); } BLL.CsvExport<EURCurveTable> exportHelper = new CsvExport<EURCurveTable>(eurTable); exportHelper.ExportToFile(csv_file_path); LogActivity("EURCurve Exported", "Export the EURCurve", string.Empty); } else if (ddlImportType.SelectedValue == "US Curve") { USDCurveBL bll = new USDCurveBL(); var list = bll.GetUSCurve().Select(x => new { UploadDate = x.UploadDate, SummitGenDate = x.SummitGenDate, CCY = x.CCY, Index = x.CurveIndex, Days = x.Days, Rate = x.Rate, DiscFreq = x.DiscFreq }); List<USDCurveTable> eurTable = new List<USDCurveTable>(); foreach (var item in list) { eurTable.Add(new USDCurveTable(Convert.ToDateTime(item.UploadDate), Convert.ToDateTime(item.SummitGenDate), item.CCY, item.Index, Convert.ToInt16(item.Days), Convert.ToDecimal(item.Rate), Convert.ToDecimal(item.DiscFreq))); } BLL.CsvExport<USDCurveTable> exportHelper = new CsvExport<USDCurveTable>(eurTable); exportHelper.ExportToFile(csv_file_path); LogActivity("USCurve Exported", "Export the USCurve", string.Empty); } FileInfo file = new FileInfo(csv_file_path); if (file.Exists) { ShowMessage("Message", "Data has been exported successfully"); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "text/plain"; Response.Flush(); Response.TransmitFile(file.FullName); Response.End(); } }
protected void btnRemoveLoan_Click(object sender, EventArgs e) { LoansBLL bll = new LoansBLL(); bool result = bll.RemoveAllLoans(); if (result) { // all loans List<Loans> allLoans = bll.GetLoans(); // check to see if the loan has been added or updated ApplicationHub.RefreshLoans(allLoans); ShowMessage("Message", "All loans deleted successfully"); LogActivity("Delete All Loans", "Remove all the quotes", string.Empty); } else { LogActivity("Delete All Loans(Unsuccessfull)", "Remove all the quotes", string.Empty); lblRemoveLoanMessage.Text = "Unable to delete the loans"; } }
private void BindQuotesAndTradesChart() { List<Browser> browsers = new List<Browser>(); LoansBLL loansBLL = new LoansBLL(); DataSet ds = new DataSet(); ds = loansBLL.GetLoanCountryGraphDetails(); if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { browsers.Add(new Browser("Trades", Convert.ToDouble(dr["Trades"]), false)); browsers.Add(new Browser("Quotes", Convert.ToDouble(dr["Quotes"]), false)); } } PieSeries ps = new PieSeries(); foreach (var item in browsers) { SeriesItem s1 = new SeriesItem(); s1.Name = item.Name; s1.Exploded = item.IsExploded; s1.YValue = Convert.ToDecimal(item.MarketShare); ps.Items.Add(s1); } // ps.LabelsAppearance.Position = Telerik.Web.UI.HtmlChart.PieLabelsPosition.Column; // removed by Nik 20 03 after upgrade version // ps.LabelsAppearance.Position = Telerik.Web.UI.HtmlChart.PieLabelsPosition.Column; PieChart2.PlotArea.Series.Add(ps); PieChart2.DataBind(); BindNuberofCounterPartyChar(); }
protected void grdQuotesAndTrades_FilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e) { DataTable data = new DataTable(); switch (e.Column.DataField) { case "LoanName": data.Columns.Add("CodeName"); LoansBLL loansBLL = new LoansBLL(); List<Loans> loans = loansBLL.GetLoans(); for (int i = 0; i < loans.Count - 1; i++) { data.Rows.Add(loans[i].CodeName); } e.ListBox.DataSource = data; e.ListBox.DataKeyField = "CodeName"; e.ListBox.DataTextField = "CodeName"; e.ListBox.DataValueField = "CodeName"; e.ListBox.DataBind(); break; default: break; } }
public List<Loans> BindLoansData() { LoansBLL bll = new LoansBLL(); List<Loans> lst = bll.GetLoans(); PopulateLoanGrid = lst; return lst; }
private void BindLoanCData() { LoansBLL loanBL = new LoansBLL(); txtLoanNameC.DataSource = loanBL.BindLoanAData(); txtLoanNameC.DataTextField = "CodeName"; txtLoanNameC.DataValueField = "CodeName"; txtLoanNameC.DataBind(); }
public void InsertRecord(string param, int flag) { try { string[] strSplit = param.Split(','); QuotesAndTrades model = new QuotesAndTrades(); if (!string.IsNullOrEmpty(strSplit[0].Remove(0, 10))) { model.BidPrice = Convert.ToDecimal(strSplit[0].Remove(0, 10)); } if (!string.IsNullOrEmpty(strSplit[1].Remove(0, 10))) { string strBidSpread = Convert.ToDecimal(strSplit[1].Remove(0, 10)).ToString("0.00"); model.BidSpread = Convert.ToDecimal(strBidSpread); } model.CounterParty = strSplit[2].Remove(0, 13); model.LoanName = strSplit[3].Remove(0, 9); if (!string.IsNullOrEmpty(strSplit[4].Remove(0, 11))) { model.OfferPrice = Convert.ToDecimal(strSplit[4].Remove(0, 11)); } if (!string.IsNullOrEmpty(strSplit[5].Remove(0, 12))) { string strOfferSpread = Convert.ToDecimal(strSplit[5].Remove(0, 12)).ToString("0.00"); model.OfferSpread = Convert.ToDecimal(strOfferSpread); } // model.MarketValue model.TimeStamp = DateTime.Now; if (strSplit[6].Remove(0, 9) == "true") model.Traded = true; else model.Traded = false; if (strSplit[3].Remove(0, 9) != string.Empty) { LoansBLL loanBLL = new LoansBLL(); model.Country = loanBLL.GetCoutryIDbyLoanID(strSplit[3].Remove(0, 9)); } if (!string.IsNullOrEmpty(strSplit[12].Remove(0, 10))) { string str = strSplit[12].Remove(0, 10); DateTime tradeDate = DateTime.Now; if (str.Contains('-')) { string[] strSpl = str.Split('-'); string datetime = strSpl[1] + "/" + strSpl[0] + "/" + strSpl[2] + " " + strSpl[3] + ":" + strSpl[4] + ":" + strSpl[5]; tradeDate = Convert.ToDateTime(datetime); } else tradeDate = Convert.ToDateTime(str); model.TradedDate = Convert.ToDateTime(tradeDate); } if (!string.IsNullOrEmpty(strSplit[13].Remove(0, 12))) { string avgLifeDisc = Convert.ToDecimal(strSplit[13].Remove(0, 12)).ToString("0.00"); model.AvgLifeDisc = Convert.ToDecimal(avgLifeDisc); } if (!string.IsNullOrEmpty(strSplit[14].Remove(0, 16))) { string avgLifeRiscDisc = Convert.ToDecimal(strSplit[14].Remove(0, 16)).ToString("0.00"); model.AvgLifeRiskDisc = Convert.ToDecimal(avgLifeRiscDisc); } if (!string.IsNullOrEmpty(strSplit[15].Remove(0, 15))) { string avgLifeNonDisc = Convert.ToDecimal(strSplit[15].Remove(0, 15)).ToString("0.00"); model.AvgLifeNonDisc = Convert.ToDecimal(avgLifeNonDisc); } if (!string.IsNullOrEmpty(strSplit[16].Remove(0, 15))) { DateTime settlementDate = Convert.ToDateTime(strSplit[16].Remove(0, 15)); model.SettlementDate = settlementDate; } if (!string.IsNullOrEmpty(strSplit[17].Remove(0, 7))) { string margin = Convert.ToString(strSplit[17].Remove(0, 7)); model.Margin = margin; } if (!string.IsNullOrEmpty(strSplit[18].Remove(0, 9))) { string notional = Convert.ToDecimal(Convert.ToString(strSplit[18].Remove(0, 9))).ToString("0.00"); model.MarketValue = Convert.ToDecimal(notional); } if (!string.IsNullOrEmpty(strSplit[19].Remove(0, 9))) { string averageLife = Convert.ToDecimal(Convert.ToString(strSplit[19].Remove(0, 12).Replace('}', ' '))).ToString("0.00"); model.AverageLife = Convert.ToDecimal(averageLife); } // model.CountryID = Convert.ToInt32(ddlRegionA.SelectedValue); List<QuotesAndTrades> lst = new List<QuotesAndTrades>(); lst.Add(model); QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); bll.AddImportedQuotesAndTrades(lst); BindHistoricalQuotesAndTradesTab(); // broadcast that quote and trade has been added ApplicationHub.NewQuotesAndTradeAdded(model); if (string.IsNullOrEmpty(hfSelectedLoanA.Value)) { // Add the Loans as well Loans loanModel = new Loans(); //loanModel.Amortizing //loanModel.Bilateral loanModel.CodeName = strSplit[3].Remove(0, 9); //loanModel.Country loanModel.CouponFrequency = strSplit[7].Remove(0, 8); loanModel.Currency = strSplit[8].Remove(0, 9); //loanModel.FacilitySize loanModel.Margin = strSplit[9].Remove(0, 9); // loanModel.Margin = strSplit[10].Remove(0, 8); loanModel.Maturity_Date = strSplit[11].Remove(0, 8); //loanModel.Sector loanModel.Signing_Date = strSplit[12].Remove(0, 10).ToString().Trim(); // Persist in database LoansBLL loanBll = new LoansBLL(); if (loanBll.CheckForLoanCode(strSplit[3].Remove(0, 9).Trim())) { loanBll.SaveLoan(loanModel); //new loan has been added. //Broadcast it ApplicationHub.NewLoanAdded(loanModel); BindLoansTab(); ShowMessage("Message", "Quote and Loan added Successfully"); } else { int loanID = loanBll.GetLoanByCode(strSplit[3].Remove(0, 9)).ID; loanBll.EditLoan(loanModel, loanID, 1); //by nidhi for update the existing loan. DuplicateLoan duplicateLoan = new DuplicateLoan(); //loanModel.Amortizing //loanModel.Bilateral duplicateLoan.CodeName = strSplit[3].Remove(0, 9); //loanModel.Country duplicateLoan.CouponFrequency = strSplit[7].Remove(0, 8); duplicateLoan.Currency = strSplit[8].Remove(0, 9); //loanModel.FacilitySize duplicateLoan.FixedOrFloating = strSplit[9].Remove(0, 9); duplicateLoan.Margin = strSplit[10].Remove(0, 8); duplicateLoan.Maturity_Date = strSplit[11].Remove(0, 8); //loanModel.Sector duplicateLoan.Signing_Date = strSplit[12].Remove(0, 10).ToString().Trim(); loanBll.SaveDuplicateLoan(duplicateLoan); } } hdnQuoteTemp.Value = "N"; ShowMessage("Message", "Quote and Loan added Successfully"); switch (flag) { case 1: LogActivity("Quote and Loan A added", "Add the quote and trade on compact view A", string.Empty); break; case 2: LogActivity("Quote and Loan B added", "Add the quote and trade on compact view B", string.Empty); break; case 3: LogActivity("Quote and Loan C added", "Add the quote and trade on compact view C", string.Empty); break; default: break; } } catch (Exception) { } }
private void BindLoanCode() { LoansBLL loanBL = new LoansBLL(); ddlAddLoanCode.DataSource = loanBL.BindLoanAData(); ddlAddLoanCode.DataTextField = "CodeName"; ddlAddLoanCode.DataValueField = "CodeName"; ddlAddLoanCode.DataBind(); ddlQuotesLoanName.DataSource = loanBL.BindLoanAData(); ddlQuotesLoanName.DataTextField = "CodeName"; ddlQuotesLoanName.DataValueField = "CodeName"; ddlQuotesLoanName.DataBind(); }
private void FillData() { try { Loans loan = new Loans(); LoansBLL bll = new LoansBLL(); loan = bll.GetLoanByID(Convert.ToInt16(Session["EditLoanID"])); ddlAddLoanCode.SelectedValue = loan.CodeName; txtBoxAddLoanCode.Text = loan.CodeName; ddlBorrower.SelectedValue = loan.Borrower; // txtBoxAddSector.Text = loan.Sector; ddlSector.SelectedValue = loan.Sector; if (loan.Signing_Date != null) txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date); if (loan.Maturity_Date != null) txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); ddlAddFixedOrFloating.SelectedValue = loan.FixedOrFloating; txtBoxAddMargin.Text = loan.Margin; ddlAddCurrency.SelectedValue = loan.Currency; bindCountry(); if (loan.Country != null) { CountryBL countryBL = new CountryBL(); int id = countryBL.GetCountryFromName(loan.Country); if (id != 0) ddlCountry.SelectedValue = Convert.ToString(id); } ddlAddCouponFrequency.SelectedValue = loan.CouponFrequency; txtBoxFacilitySize.Text = Convert.ToDecimal(loan.FacilitySize).ToString("N"); if (loan.Bilateral == true) ddlAddBilateral.SelectedValue = "Yes"; else ddlAddBilateral.SelectedValue = "No"; ddlAmortizing.SelectedValue = loan.Amortizing; CheckNodes(tvCreditRating, loan); //txtCouponDate. //txtNotional txtPP.Text = loan.PP; // txtCRating.Text = loan.CreditRating; txtStructureID.Text = loan.StructureID; txtBoxAddMargin.Text = loan.Margin; if (loan.CouponDate != null) txtCouponDate.SelectedDate = Convert.ToDateTime(loan.CouponDate); txtNotional.Text = Convert.ToDecimal(loan.Notional).ToString("N"); if (ddlAmortizing.SelectedValue == "Yes") { if (loan.AmortisationsStartPoint != null) txtAmortisationsStartDate.SelectedDate = Convert.ToDateTime(loan.AmortisationsStartPoint); txtAmortisations.Text = loan.NoOfAmortisationPoint.ToString(); trDate.Visible = true; trNo.Visible = true; tblAmortisation.Visible = true; } txtSummitCredit.Text = loan.SummitCreditEntity; txtGrid.Text = loan.Grid; txtGurantor.Text = loan.Gurantor; LoanScheduleBL scheduleBL = new LoanScheduleBL(); List<LoanSchedule> scheduleList = scheduleBL.GetLoanByID(loan.ID); if (scheduleList != null && scheduleList.Count > 0) { dt1.Clear(); //dt1.Columns.Add("ID", typeof(int)); //dt1.Columns.Add("StartDate", typeof(DateTime)); //dt1.Columns.Add("EndDate", typeof(DateTime)); //dt1.Columns.Add("Notional", typeof(long)); //dt1.Columns.Add("Factor", typeof(float)); for (int i = 0; i < scheduleList.Count; i++) { // dt1.Rows.Add(scheduleList[i].ID, scheduleList[i].StartDate, scheduleList[i].EndDate, scheduleList[i].Notation, scheduleList[i].Factor); dt1.Rows.Add(i + 1, scheduleList[i].StartDate.Value.ToShortDateString(), scheduleList[i].EndDate.Value.ToShortDateString(), scheduleList[i].CoupFrac, scheduleList[i].Notation, scheduleList[i].Amortisation, scheduleList[i].Factor); } pnlAmortizing.Visible = true; grdAmortizing.Visible = true; btnCalculatSchedule.Visible = true; grdAmortizing.DataSource = dt1; grdAmortizing.DataBind(); } hfLoanID.Value = loan.ID.ToString(); lblConfirm.Text = "Loan already exists, do you wish to overwrite?"; _operation = "Edit"; } catch (Exception) { } }
//private void BindLoanCodeDetails() //{ // try // { // LoansBLL bll = new LoansBLL(); // string strLoanName = ddlAddLoanCode.Text.ToString(); // if (strLoanName.Contains(';')) // { // strLoanName = strLoanName.Replace(';', ' '); // } // Loans loan = bll.GetLoanByCode(strLoanName.Trim()); // if (loan != null) // { // txtBoxAddBorrower.Text = Convert.ToString(loan.Borrower); // txtBoxAddSector.Text = Convert.ToString(loan.Sector); // if (loan.Signing_Date != "") // txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date); // else // txtBoxAddSigningDate.Clear(); // if (loan.Maturity_Date != "") // txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); // else // txtBoxAddMaturityDate.Clear(); // txtBoxFacilitySize.Text = loan.FacilitySize; // ddlAddFixedOrFloating.SelectedValue = loan.FixedOrFloating; // txtBoxAddMargin.Text = loan.Margin; // ddlAddCurrency.SelectedValue = loan.Currency; // ddlCountry.SelectedValue = loan.Country; // ddlAddCouponFrequency.SelectedValue = loan.CouponFrequency; // if (loan.Bilateral == true) // ddlAddBilateral.SelectedValue = "Yes"; // else // ddlAddBilateral.SelectedValue = "No"; // ddlAmortizing.SelectedValue = loan.Amortizing; // lblConfirm.Text = "Loan already exists, do you wish to overwrite?"; // _operation = "Edit"; // } // else // { // _operation = "Add"; // } // //else // //{ // // Clear(); // //} // } // catch (Exception) // { // } //} private void BindLoanCodeDetails() { try { LoansBLL bll = new LoansBLL(); string strLoanName = ddlAddLoanCode.Text.ToString(); if (strLoanName.Contains(';')) { strLoanName = strLoanName.Replace(';', ' '); } Loans loan = bll.GetLoanByCode(strLoanName.Trim()); if (loan != null) { if (loan.Borrower != null) { ddlBorrower.SelectedValue = Convert.ToString(loan.Borrower); BorrowersBL borrowerBL = new BorrowersBL(); if (ddlBorrower.SelectedValue != string.Empty) { if (ddlBorrower.SelectedItem != null) { Borrower borrower = borrowerBL.GetBorrower(ddlBorrower.SelectedItem.Text); txtGrid.Text = loan.Grid; txtSummitCredit.Text = loan.SummitCreditEntity; } } } // txtBoxAddSector.Text = Convert.ToString(loan.Sector); if (loan.Sector != null) { ddlSector.SelectedValue = Convert.ToString(loan.Sector); } if (loan.Signing_Date != "" && loan.Signing_Date != null) txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date); else txtBoxAddSigningDate.Clear(); if (loan.Maturity_Date != "" && loan.Maturity_Date != null) txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); else txtBoxAddMaturityDate.Clear(); if (loan.CouponDate != "" && loan.CouponDate != null) txtCouponDate.SelectedDate = Convert.ToDateTime(loan.CouponDate); else txtCouponDate.Clear(); if (loan.FacilitySize != null) { txtBoxFacilitySize.Text = Convert.ToDecimal(loan.FacilitySize).ToString("N"); } if (loan.Fixed_Floating != null) { ddlAddFixedOrFloating.SelectedValue = loan.FixedOrFloating; } txtBoxAddMargin.Text = loan.Margin; if (loan.Currency != null) { ddlAddCurrency.SelectedValue = loan.Currency; } if (loan.Country != null) { ddlCountry.SelectedValue = loan.Country; } txtPP.Text = loan.PP; // txtCRating.Text = loan.CreditRating; txtStructureID.Text = loan.StructureID; if (loan.CouponFrequency != null) { ddlAddCouponFrequency.SelectedValue = loan.CouponFrequency; } txtNotional.Text = Convert.ToDecimal(loan.Notional).ToString("N"); if (loan.Bilateral == true) ddlAddBilateral.SelectedValue = "Yes"; else ddlAddBilateral.SelectedValue = "No"; if (loan.Amortizing == "Yes") { ddlAmortizing.SelectedValue = loan.Amortizing; if (ddlAmortizing.SelectedValue == "Yes") { if (loan.AmortisationsStartPoint != null) txtAmortisationsStartDate.SelectedDate = Convert.ToDateTime(loan.AmortisationsStartPoint); txtAmortisations.Text = loan.NoOfAmortisationPoint.ToString(); trDate.Visible = true; trNo.Visible = true; tblAmortisation.Visible = true; } } else { ddlAmortizing.SelectedValue = "No"; trDate.Visible = false; trNo.Visible = false; tblAmortisation.Visible = false; } txtGurantor.Text = loan.Gurantor; txtGrid.Text = loan.Grid; txtSummitCredit.Text = loan.SummitCreditEntity; CheckNodes(tvCreditRating, loan); txtBoxAddMargin.Text = loan.Margin; LoanScheduleBL scheduleBL = new LoanScheduleBL(); List<LoanSchedule> scheduleList = scheduleBL.GetLoanByID(loan.ID); if (scheduleList != null && scheduleList.Count > 0) { dt1.Clear(); //dt1.Columns.Add("ID", typeof(int)); //dt1.Columns.Add("StartDate", typeof(DateTime)); //dt1.Columns.Add("EndDate", typeof(DateTime)); //dt1.Columns.Add("Notional", typeof(long)); //dt1.Columns.Add("Factor", typeof(float)); for (int i = 0; i < scheduleList.Count; i++) { // dt1.Rows.Add(scheduleList[i].ID, scheduleList[i].StartDate, scheduleList[i].EndDate, scheduleList[i].Notation, scheduleList[i].Factor); dt1.Rows.Add(i + 1, scheduleList[i].StartDate.Value.ToShortDateString(), scheduleList[i].EndDate.Value.ToShortDateString(), scheduleList[i].CoupFrac, scheduleList[i].Notation, scheduleList[i].Amortisation, scheduleList[i].Factor, scheduleList[i].Spread, scheduleList[i].CouponPaymentDate, scheduleList[i].RiskFreeDP1, scheduleList[i].RiskFreeDP2, scheduleList[i].FloatingRate, scheduleList[i].AllInRate, scheduleList[i].Interest, scheduleList[i].Days, scheduleList[i].AmortisationInt); } pnlAmortizing.Visible = true; grdAmortizing.Visible = true; btnCalculatSchedule.Visible = true; Session.Add("LoanScheduleData", dt1); grdAmortizing.DataSource = dt1; grdAmortizing.DataBind(); } else { Session.Remove("LoanScheduleData"); dt1.Clear(); pnlAmortizing.Visible = false; btnCalculatSchedule.Visible = false; grdAmortizing.Visible = false; } hfLoanID.Value = loan.ID.ToString(); Session.Add("EditLoanID", loan.ID.ToString()); lblConfirm.Text = "Loan already exists, do you wish to overwrite?"; _operation = "Edit"; } else { hfLoanID.Value = string.Empty; _operation = "Add"; lblConfirm.Text = "Are you sure you want to add this loan to database?"; // Clear(); } } catch (Exception) { } }
private void InsertDuplicateLoan() { try { DuplicateLoan duplicateLoan = new DuplicateLoan(); LoansBLL loanBLL = new LoansBLL(); duplicateLoan.CodeName = ddlAddLoanCode.Text; duplicateLoan.Borrower = ddlBorrower.Text; duplicateLoan.Sector = ddlSector.SelectedValue;//txtBoxAddSector.Text; duplicateLoan.Signing_Date = txtBoxAddSigningDate.SelectedDate.Value.ToShortDateString(); duplicateLoan.Maturity_Date = txtBoxAddMaturityDate.SelectedDate.Value.ToShortDateString(); duplicateLoan.FixedOrFloating = ddlAddFixedOrFloating.SelectedItem.Text; duplicateLoan.Margin = txtBoxAddMargin.Text; duplicateLoan.Currency = ddlAddCurrency.SelectedItem.Text; duplicateLoan.Country = ddlCountry.SelectedItem.Text; duplicateLoan.CouponFrequency = ddlAddCouponFrequency.SelectedItem.Text; duplicateLoan.FacilitySize = Convert.ToDecimal(txtBoxFacilitySize.Text).ToString("N"); duplicateLoan.Bilateral = ddlAddBilateral.SelectedValue == "Yes"; duplicateLoan.Amortizing = ddlAmortizing.SelectedItem.Text; loanBLL.SaveDuplicateLoan(duplicateLoan); } catch (Exception) { } }
private void BindLoanDetailData(string loanCode) { LoanScheduleBL bll = new LoanScheduleBL(); LoansBLL loanBL = new LoansBLL(); if (loanCode != string.Empty) { Loans loan = loanBL.GetLoanByID(Convert.ToInt32(loanCode)); txtLoanDetailCurrency.Text = loan.Currency; txtLoanDetailMaturityDate.Text = loan.Maturity_Date; txtLoanDetailTradeDate.SelectedDate = DateTime.Now;//loan.Signing_Date; txtLoanDetailSettlementDate.SelectedDate = AddBusinessDays(DateTime.Now.Date, 10); txtLoanDetailNotional.Text = Convert.ToDecimal(loan.Notional).ToString("N"); hdnLoanDetailMargin.Value = loan.Margin.ToString(); txtLoanDetailCouponFreq.Text = loan.CouponFrequency; txtLoanDetailLastCouponDate.Text = loan.CouponDate; txtLoanDetailFixedOrFloating.Text = loan.FixedOrFloating; txtLoanDetailIRR.Text = CalculateIRR(loan.CodeName, txtLoanDetailPrice.Text); txtLoanDetailAvgLife.Text = AverageLife(loan.CodeName); txtAvgLifeNonDisc.Text = AverageLifeNonDiscount(loan.CodeName); txtLoanDetailAvgLifeRiskDisc.Text = AverageLifeRiskDisc(loan.CodeName); txtLoanDetailAvgLifeDisc.Text = AverageLifeDisc(loan.CodeName); if (txtLoanDetailPrice.Text != string.Empty) txtLoanDetailConsideration.Text = Convert.ToDecimal(Convert.ToDecimal(txtLoanDetailPrice.Text) * Convert.ToDecimal(loan.Notional)).ToString("0.00"); else txtLoanDetailConsideration.Text = Convert.ToDecimal(1 * Convert.ToDecimal(loan.Notional)).ToString("0.00"); //txtLoanDetailDiscountMargin.Text = loan.di grdLoanDetail.DataSource = bll.GetLoanByID(Convert.ToInt16(loanCode)); grdLoanDetail.DataBind(); } }
private void SetLoan0() { //Fill up the detail now LoansBLL bll = new LoansBLL(); Loans loan = bll.GetLoanByCode(txtBoxAddLoanCode.Text); hfLoanID.Value = loan.ID.ToString(); ddlBorrower.SelectedValue = loan.Borrower; // txtBoxAddSector.Text = loan.Sector; ddlSector.SelectedValue = loan.Sector; txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date); txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); DropDownListItem item = ddlAddFixedOrFloating.FindItemByValue(loan.FixedOrFloating); if (item != null) { item.Selected = true; } txtBoxAddMargin.Text = loan.Margin; DropDownListItem currencyItem = ddlAddCurrency.FindItemByValue(loan.Currency); if (currencyItem != null) { currencyItem.Selected = true; } DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency); if (frequency != null) { frequency.Selected = true; } txtBoxFacilitySize.Text = Convert.ToDecimal(loan.FacilitySize).ToString("N"); DropDownListItem yesno; if (loan.Bilateral.HasValue && loan.Bilateral.Value) { yesno = ddlAddBilateral.FindItemByValue("Yes"); } else { yesno = ddlAddBilateral.FindItemByValue("No"); } yesno.Selected = true; DropDownListItem amort = ddlAmortizing.FindItemByValue(loan.Amortizing); if (amort != null) { amort.Selected = true; } }
private void BindLoanDetails() { LoansBLL loanBL = new LoansBLL(); ddlLoanDetailsCode.DataSource = loanBL.BindLoanAData(); ddlLoanDetailsCode.DataTextField = "CodeName"; ddlLoanDetailsCode.DataValueField = "ID"; ddlLoanDetailsCode.DataBind(); }
private void SetLoanB() { //Fill up the detail now try { LoansBLL bll = new LoansBLL(); string strLoanName = txtLoanNameB.Text.ToString(); txtBoxTradeDate2.SelectedDate = DateTime.Now; //if (strLoanName.Contains(';')) //{ // strLoanName = strLoanName.Replace(';', ' '); //} try { QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL(); QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(strLoanName); if (quotes != null) { if (quotes.BidPrice != null) txtBidPriceA.Text = quotes.BidPrice.Value.ToString(); if (quotes.BidSpread != null) txtBidSpreadA.Text = quotes.BidSpread.Value.ToString(); if (quotes.OfferPrice != null) txtOfferPriceA.Text = quotes.OfferPrice.Value.ToString(); if (quotes.OfferSpread != null) txtOfferSpreadA.Text = quotes.OfferSpread.Value.ToString(); if (quotes.AverageLife != null) txtAvgLifeA.Text = quotes.AverageLife.Value.ToString(); if (quotes.AvgLifeDisc != null) txtAveLifDiscA.Text = quotes.AvgLifeDisc.Value.ToString(); if (quotes.AvgLifeRiskDisc != null) txtAveLifRiskyDiscA.Text = quotes.AvgLifeRiskDisc.Value.ToString(); if (quotes.Traded != null) chkBoxTradedA.Checked = quotes.Traded.Value; } } catch (Exception) { } Loans loan = bll.GetLoanByCode(strLoanName.Trim()); if (txtBoxTradeDate2.SelectedDate != null) { txtBoxSettlementDate2.SelectedDate = AddBusinessDays(txtBoxTradeDate2.SelectedDate.Value, 10); } if (loan != null) { txtLoanNameB.SelectedValue = strLoanName; Session.Add("LegendB", strLoanName); if (loan != null) { hfSelectedLoanB.Value = loan.ID.ToString(); //if (loan.Signing_Date != string.Empty || loan.Signing_Date != "") //{ // txtBoxSettlementDate2.SelectedDate = Convert.ToDateTime(loan.Signing_Date); //} if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "") { txtBoxMaturityDateB.SelectedDate = Convert.ToDateTime(loan.Maturity_Date); } txtInterestRateB.Text = loan.Margin; //txtDiscountMarginB.Text = loan.Margin; txtCurrencyB.Text = loan.Currency; txtBoxCouponFrequencyLoanB.Text = loan.CouponFrequency; txtBoxLastFixingB.Text = loan.FixedOrFloating; // txtBoxIRCouponB.Text = loan.Margin; ddlCounterPartyB.SelectedValue = "CounterPartyB"; // DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency); //if (frequency != null) //{ // frequency.Selected = true; //} if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null) {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty ComputeCouponDatesAndFractions(txtBoxTradeDate2, txtLoanNameB, txtBoxSettlementDate2, txtBoxMaturityDateB, txtBoxCouponFrequencyLoanB, txtBoxAveLifNonDiscB, grdCalculatedDates2, 2, txtBoxNotional2, txtInterestRateB, txtCurrencyB); } else { grdCalculatedDates2.DataSource = null; grdCalculatedDates2.DataBind(); RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn"); } LogActivity("Compute the CashFlow B", "Compute the cashflow for compact view B", string.Empty); } } else { RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn"); } } catch (Exception) { } }
private void BindLoansTab(List<Loans> lst = null) { if (lst == null) { LoansBLL bll = new LoansBLL(); lst = bll.GetLoans(); } //grdLoans.DataSource = lst; //grdLoans.DataBind(); }
protected void btnAddNewLoan_Click(object sender, EventArgs e) { try { LoansBLL bll = new LoansBLL(); if (txtBoxAddMaturityDate.SelectedDate.ToString() != "" && txtBoxAddSigningDate.SelectedDate.ToString() != "") { DateTime dtMaturity = Convert.ToDateTime(txtBoxAddMaturityDate.SelectedDate.Value); DateTime dtSigning = Convert.ToDateTime(txtBoxAddSigningDate.SelectedDate.Value); SettingsBLL settingBL = new SettingsBLL(); Setting setting = settingBL.GetSettingyear("Loan Year Settings"); if (setting != null) { TimeSpan ts = dtMaturity - dtSigning; int differenceYear = Convert.ToInt32((ts.TotalDays) / 365); int year = Convert.ToInt16(setting.Value); if (dtMaturity.Year > dtSigning.Year && (differenceYear) > year) { lblMessage.Text = "Maturity Date is not Valid"; lblMessage.Visible = true; return; } } } else { //lblMessage.Text = "Enter the Details"; //lblMessage.Visible = true; RadWindowManager1.RadAlert("Maturity Date and Signing Date required", 300, 150, "realedge associates", "alertCallBackFn"); return; } // check to see either the loan has been added or updated bool isNewLoan = false; Loans loan = new Loans(); if (!string.IsNullOrEmpty(hfLoanID.Value)) { isNewLoan = false; loan.ID = Convert.ToInt32(hfLoanID.Value); LogActivity("Update the Loan", "Update the existing loan", string.Empty); } else { isNewLoan = true; LogActivity("New Loan Added", "Add the new loan", string.Empty); } List<RatingDetails> ratingDetails = new List<RatingDetails>(); ratingDetails = ShowCheckedNodes(tvCreditRating); foreach (var item in ratingDetails) { switch (item.agencyName) { case "Moody's": loan.CreditRatingModys = item.rating; break; case "S&P's": loan.CreditRatingSPs = item.rating; break; case "Fitch": loan.CreditRatingFitch = item.rating; break; case "ING": loan.CreditRatingING = item.rating; break; default: break; } } loan.CodeName = ddlAddLoanCode.Text; loan.Borrower = ddlBorrower.Text; loan.Sector = ddlSector.SelectedValue; //txtBoxAddSector.Text; loan.Signing_Date = txtBoxAddSigningDate.SelectedDate.Value.ToShortDateString(); loan.Maturity_Date = txtBoxAddMaturityDate.SelectedDate.Value.ToShortDateString(); loan.FixedOrFloating = ddlAddFixedOrFloating.SelectedValue; loan.Margin = txtBoxAddMargin.Text; loan.Currency = ddlAddCurrency.SelectedValue; loan.Country = ddlCountry.SelectedValue; loan.CouponFrequency = ddlAddCouponFrequency.SelectedValue; loan.Gurantor = txtGurantor.Text; loan.Grid = txtGrid.Text; loan.SummitCreditEntity = txtSummitCredit.Text; if (txtBoxFacilitySize.Text != string.Empty) { loan.FacilitySize = Convert.ToDecimal(txtBoxFacilitySize.Text).ToString("N"); } loan.Bilateral = ddlAddBilateral.SelectedValue == "Yes"; loan.Amortizing = ddlAmortizing.SelectedValue; loan.PP = txtPP.Text; // loan.CreditRating = txtCRating.Text; loan.StructureID = txtStructureID.Text; //Coupon Date and Notional are missing. if (txtCouponDate.SelectedDate != null) { loan.CouponDate = txtCouponDate.SelectedDate.Value.ToShortDateString(); } loan.Notional = Convert.ToDecimal(txtNotional.Text).ToString("N").Trim(); if (ddlAmortizing.SelectedValue == "Yes") { if (txtAmortisationsStartDate.SelectedDate != null) { loan.AmortisationsStartPoint = txtAmortisationsStartDate.SelectedDate.Value.ToShortDateString(); } if (txtAmortisations.Text != string.Empty) { loan.NoOfAmortisationPoint = Convert.ToInt16(txtAmortisations.Text); } } else { loan.Amortizing = "Yes"; DateTime cpnDT; if (txtCouponDate.SelectedDate.ToString() == string.Empty) { cpnDT = AddBusinessDays(DateTime.Now, 10); loan.AmortisationsStartPoint = cpnDT.ToShortDateString(); } else { cpnDT = Convert.ToDateTime(txtCouponDate.SelectedDate); loan.AmortisationsStartPoint = txtCouponDate.SelectedDate.Value.ToShortDateString(); } loan.NoOfAmortisationPoint = 10; LoanScheduleBL loanScheduleBL = new LoanScheduleBL(); DateTime tradeDate = DateTime.Now; DataTable dtSchedule = loanScheduleBL.GenerateTable(15, Convert.ToInt16(loan.NoOfAmortisationPoint), Convert.ToDateTime(loan.AmortisationsStartPoint), loan.CouponFrequency.ToString(), loan.Notional.ToString(), Convert.ToDateTime(loan.Maturity_Date), Convert.ToDateTime(loan.CouponDate), Convert.ToDecimal(loan.Margin), Convert.ToString(loan.Currency), Convert.ToDateTime(tradeDate), AddBusinessDays(Convert.ToDateTime(tradeDate), 10)); Session["LoanSchedule"] = dtSchedule; } DAL.Login login = Session["LogedInUser"] as DAL.Login; loan.CreatedBy = login.Name; loan.LastEdited = DateTime.Now; switch (_operation) { case "Add": if (bll.CheckForLoanCode(ddlAddLoanCode.Text.Trim())) { bll.SaveLoan(loan); login = Session["LogedInUser"] as DAL.Login; LoanHistory loanHistory = new LoanHistory(); LoanHistoryBL historyBL = new LoanHistoryBL(); loanHistory.Action = "Add"; loanHistory.LoanName = loan.CodeName; loanHistory.UserName = login.Name; loanHistory.LastModified = DateTime.Now; historyBL.SaveHistory(loanHistory); // lblAddLoanMessage.Visible = true; on 7-1 CalculateFactors(); LoanScheduleBL loanScheduleBL = new LoanScheduleBL(); if (Session["LoanSchedule"] != null) { dt1 = (DataTable)Session["LoanSchedule"]; } foreach (DataRow dr in dt1.Rows) { LoanSchedule loanSchedule = new LoanSchedule(); loanSchedule.LoanID = loan.ID; loanSchedule.StartDate = Convert.ToDateTime(dr["StartDate"]); loanSchedule.EndDate = Convert.ToDateTime(dr["EndDate"]); loanSchedule.CoupFrac = Convert.ToDecimal(dr["CoupFrac"]); loanSchedule.Notation = Convert.ToDecimal(dr["Notation"]); loanSchedule.Amortisation = Convert.ToDecimal(dr["Amortisation"]); loanSchedule.Factor = Convert.ToDecimal(dr["Factor"]); loanSchedule.Spread = Convert.ToDecimal(dr["Spread"]); loanSchedule.AllInRate = Convert.ToDecimal(dr["AllInRate"]); loanSchedule.CouponPaymentDate = Convert.ToDateTime(dr["CouponPaymentDate"]); loanSchedule.RiskFreeDP1 = Convert.ToDecimal(dr["RiskFreeDP1"]); loanSchedule.RiskFreeDP2 = Convert.ToDecimal(dr["RiskFreeDP2"]); loanSchedule.FloatingRate = Convert.ToDecimal(dr["FloatingRate"]); loanSchedule.Interest = Convert.ToDecimal(dr["Interest"]); loanSchedule.Days = Convert.ToInt16(dr["Days"]); loanSchedule.AmortisationInt = Convert.ToDecimal(dr["AmortisationInt"]); loanSchedule.CreatedOn = DateTime.UtcNow; loanScheduleBL.SaveLoanSchedule(loanSchedule); } //lblMessage.Text = "Loan added Successfully"; //lblMessage.Visible = true; RadWindowManager1.RadAlert(ddlAddLoanCode.Text + " added Successfully", 300, 150, "realedge associates", "alertCallBackFn"); } else { InsertDuplicateLoan(); } break; case "Edit": bll.EditLoan(loan, Convert.ToInt16(Session["EditLoanID"]), 2); login = Session["LogedInUser"] as DAL.Login; LoanHistory loanHis = new LoanHistory(); LoanHistoryBL historiesBL = new LoanHistoryBL(); loanHis.Action = "Edit"; loanHis.LoanName = loan.CodeName; loanHis.UserName = login.Name; loanHis.LastModified = DateTime.Now; historiesBL.SaveHistory(loanHis); CalculateFactors(); LoanScheduleBL scheduleBL = new LoanScheduleBL(); if (Session["LoanSchedule"] != null) { dt1 = (DataTable)Session["LoanSchedule"]; } scheduleBL.EditSchedule(Convert.ToInt16(Session["EditLoanID"]), dt1); // Clear(); //lblMessage.Text = "Loan updated Successfully"; //lblMessage.Visible = true; RadWindowManager1.RadAlert(ddlAddLoanCode.Text + " updated Successfully", 300, 150, "realedge associates", "alertCallBackFn"); //lblConfirm.Text = "Are you sure you want to add this loan to database?"; //_operation = "Add"; //Session.Remove("EditLoanID"); break; default: break; } // all loans List<Loans> allLoans = bll.GetLoans(); BindLoansTab(allLoans); BindLoansData(); BindHistoricalQuotesAndTradesTab(); // check to see if the loan has been added or updated if (isNewLoan) { ApplicationHub.NewLoanAdded(loan); } else { ApplicationHub.RefreshLoans(allLoans); } hdnSaved.Value = "Y"; BindLoanCode(); } catch (Exception ex) { //lblAddLoanMessage.Visible = true; on 7-1 //lblAddLoanMessage.Text = "Loan failed to save"; on 7-1 // lblMessage.Text = "Loan failed to save"; lblMessage.Text = ex.Message; lblMessage.Text = ex.InnerException.Message; lblMessage.Visible = true; LogActivity("New Loan(Unsuccessfull)", "Unable to save the loan", ex.Message); } }
private void BindDuplicateLoansTab(List<DuplicateLoan> lst = null) { if (lst == null) { LoansBLL bll = new LoansBLL(); lst = bll.GetDuplicateLoans(); } grdDuplicateLoans.DataSource = lst; grdDuplicateLoans.DataBind(); }