private void UpdateQuotes() { try { QuotesAndTradesBLL quotesAndTradeBLL = new QuotesAndTradesBLL(); QuotesAndTrades quotesAndTrades = new QuotesAndTrades(); quotesAndTrades.ID = Convert.ToInt32(Session["EditQuoteID"]); quotesAndTrades.LoanName = ddlQuotesLoanName.SelectedValue; quotesAndTrades.CounterParty = txtQuotesCounterParty.Text; if (txtQuoteBidPrice.Text != "") { quotesAndTrades.BidPrice = Convert.ToDecimal(txtQuoteBidPrice.Text); } if (txtQuoteBidSpreadPrice.Text != "") { quotesAndTrades.BidSpread = Convert.ToDecimal(txtQuoteBidSpreadPrice.Text); } if (txtQuoteOfferPrice.Text != "") { quotesAndTrades.OfferPrice = Convert.ToDecimal(txtQuoteOfferPrice.Text); } if (txtQuoteOfferSpread.Text != "") { quotesAndTrades.OfferSpread = Convert.ToDecimal(txtQuoteOfferSpread.Text); } quotesAndTrades.Traded = chkIsTraded.Checked; if (txtQuoteMarketValue.Text != "") { quotesAndTrades.MarketValue = Convert.ToDecimal(txtQuoteMarketValue.Text); } quotesAndTrades.Country = ddlQuoteCountry.Text; quotesAndTrades.TimeStamp = DateTime.UtcNow; //quotesAndTradeBLL.SaveQuote(quotesAndTrades); quotesAndTradeBLL.UpdateQuote(quotesAndTrades); lblQuotesTradesMessage.Visible = true; Session.Remove("EditQuoteID"); lblQuotesTradesMessage.Text = "Quotes and Trades Updated Successfully"; LogActivity("Quotes and Trades Updated Successfully", "Edit Quotes and Trades", string.Empty); } catch (Exception) { } }
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 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 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 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"); } }
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 FillQuoteData() { if (Session["EditQuoteID"] != null) { QuotesAndTradesBLL quotesAndTradeBLL = new QuotesAndTradesBLL(); QuotesAndTrades quotes = new QuotesAndTrades(); quotes = quotesAndTradeBLL.GetQuoteAndTrade(Convert.ToInt32(Session["EditQuoteID"])); ddlQuotesLoanName.SelectedValue = quotes.LoanName; txtQuotesCounterParty.Text = quotes.CounterParty.ToString(); if (quotes.BidPrice != null) { txtQuoteBidPrice.Text = quotes.BidPrice.Value.ToString(); } if (quotes.OfferPrice != null) { txtQuoteOfferPrice.Text = quotes.OfferPrice.Value.ToString(); } if (quotes.BidSpread != null) { txtQuoteBidSpreadPrice.Text = quotes.BidSpread.Value.ToString(); } if (quotes.OfferSpread != null) { txtQuoteOfferSpread.Text = quotes.OfferSpread.Value.ToString(); } if (quotes.Traded != null) { chkIsTraded.Checked = quotes.Traded.Value; } if (quotes.MarketValue != null) { txtQuoteMarketValue.Text = quotes.MarketValue.Value.ToString(); } bindCountry(); if (quotes.Country != null) { // ddlQuoteCountry.SelectedItem.Text = quotes.Country; ddlQuoteCountry.SelectedValue = quotes.Country; } } }
private void BindHistoricalQuotesAndTradesTab(List<QuotesAndTrades> lst = null) { if (lst == null) { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); lst = bll.GetQuotesAndTrades(); } grdQuotesAndTrades.DataSource = lst; grdQuotesAndTrades.DataBind(); }
public List<QuotesAndTrades> BindQuotesAndTradesData() { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); List<QuotesAndTrades> lst = bll.GetQuotesAndTrades(); return lst; }
protected void grdQuotesAndTrades_UpdateCommand(object sender, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; QuotesAndTradesBLL quotesAndTradeBLL = new QuotesAndTradesBLL(); Hashtable newValues = new Hashtable(); e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); QuotesAndTrades quotesAndTrades = new QuotesAndTrades(); quotesAndTrades.BidPrice = Convert.ToDecimal(newValues["BidPrice"]); quotesAndTrades.BidSpread = Convert.ToDecimal(newValues["BidSpread"]); RadDropDownList ddlParty = (RadDropDownList)editedItem.FindControl("ddlQCounterParty"); quotesAndTrades.CounterParty = ddlParty.SelectedValue; RadDropDownList ddlCountry = (RadDropDownList)editedItem.FindControl("ddlQCountry"); quotesAndTrades.Country = ddlCountry.SelectedValue; //quotesAndTrades.Country = Convert.ToString(newValues["Country"]); quotesAndTrades.LoanName = Convert.ToString(newValues["LoanName"]); quotesAndTrades.MarketValue = Convert.ToDecimal(newValues["MarketValue"]); quotesAndTrades.OfferPrice = Convert.ToDecimal(newValues["OfferPrice"]); quotesAndTrades.OfferSpread = Convert.ToDecimal(newValues["OfferSpread"]); quotesAndTrades.TimeStamp = Convert.ToDateTime(newValues["TimeStamp"]); quotesAndTrades.Traded = Convert.ToBoolean(newValues["Traded"]); quotesAndTrades.ID = Convert.ToInt32(grdQuotesAndTrades.MasterTableView.Items[0].GetDataKeyValue("ID")); quotesAndTrades.AvgLifeNonDisc = Convert.ToDecimal(newValues["AvgLifeNonDisc"]); quotesAndTrades.AvgLifeDisc = Convert.ToDecimal(newValues["AvgLifeDisc"]); quotesAndTrades.AvgLifeRiskDisc = Convert.ToDecimal(newValues["AvgLifeRiskDisc"]); quotesAndTrades.TimeStamp = DateTime.UtcNow; quotesAndTrades.SettlementDate = Convert.ToDateTime(newValues["SettlementDate"]); quotesAndTrades.Margin = Convert.ToString(newValues["Margin"]); quotesAndTrades.TradedDate = Convert.ToDateTime(newValues["TradedDate"]); //quotesAndTradeBLL.SaveQuote(quotesAndTrades); quotesAndTradeBLL.UpdateQuote(quotesAndTrades); BindHistoricalQuotesAndTradesTab(); LogActivity("Quotes and Trades Updated Successfully", "Edit Quotes and Trades", string.Empty); }
protected void grdQuotesAndTrades_ItemCommand(object sender, GridCommandEventArgs e) { //if (e.CommandName == "Edit") //{ // int id = Convert.ToInt32(e.CommandArgument); // RadTab rootTab = RadTabStrip1.FindTabByText("Edit Historical Quotes & Trades"); // rootTab.Visible = true; // Session.Add("EditQuoteID", id); // Response.Redirect("default.aspx?page=edithistoricalquotes"); //} else if (e.CommandName == "Delete") { int id = Convert.ToInt32(e.CommandArgument); QuotesAndTradesBLL quotesBLL = new QuotesAndTradesBLL(); quotesBLL.RemoveQuote(id); } BindHistoricalQuotesAndTradesTab(); }
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 btnRemoveQuotes_Click(object sender, EventArgs e) { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); bool result = bll.RemoveAllQuotesAndTrades(); if (result) { List<QuotesAndTrades> lst = bll.GetQuotesAndTrades(); ApplicationHub.RefreshQuotesAndTrade(lst); ShowMessage("Message", "All quotes and trades deleted successfully"); LogActivity("Delete All QuotesAndTrades", "Remove all the quotes and trades", string.Empty); } else { LogActivity("Delete All QuotesAndTrades(Unsuccessfull)", "Remove all the quotes and trades", string.Empty); lblRemoveQuotesMessage.Text = "Unable to delete the quotes"; } }
protected void Import() { try { string filename = Path.GetFileName(fuFile.FileName); string csv_file_path = Server.MapPath("~/Temp/tempfile.csv"); //fuFile.SaveAs(csv_file_path); DataTable csvData = null; List<string> columnNames = null; if (ddlImportType.SelectedValue != "EUR Curve" || ddlImportType.SelectedValue != "US Curve") { csvData = CSVHelper.GetDataTabletFromCSVFile(csv_file_path, GetDelimeters()); // Get Header column names list columnNames = csvData.Columns.Cast<DataColumn>().Select(c => c.ColumnName).ToList(); LogActivity("File Uploaded", "Upload the file to import loan/quotesAndtrades", string.Empty); } if (ddlImportType.SelectedValue == "Loan") { //ExtractLoanList(csvData, columnNames); List<Loans> importedList = ExtractLoanList(csvData, columnNames); // ExtractLoanList(csvData, columnNames); // Save it to database ApplicationHub.RefreshLoans(importedList); LogActivity("Loans Imported", "Import the loans", string.Empty); } else if (ddlImportType.SelectedValue == "Quotes") { List<QuotesAndTrades> importedList = ExtractQuotesAndTradesList(csvData, columnNames); // Save it to database if (importedList.Count > 0) { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); bll.AddImportedQuotesAndTrades(importedList); ApplicationHub.RefreshQuotesAndTrade(importedList); LogActivity("QuotesAndTrades Imported", "Import the quotesAndtrades", string.Empty); } else { RadWindowManager1.RadAlert("No Data found", 330, 180, "realedge associates", "alertCallBackFn"); return; } } else if (ddlImportType.SelectedValue == "Counterparties") { List<CounterParty> importedList = ExtractCounterPartyList(csvData, columnNames); if (importedList.Count > 0) { CounterPartyBL bll = new CounterPartyBL(); bll.AddImportedQuotesAndTrades(importedList); LogActivity("Counterparties Imported", "Counterparties", string.Empty); } else { RadWindowManager1.RadAlert("No Data found", 330, 180, "realedge associates", "alertCallBackFn"); return; } } else if (ddlImportType.SelectedValue == "EUR Curve") { //importdatafromexcel(csv_file_path); List<EURCurve> importedList = ExtractEURCurveList(csvData, columnNames); if (importedList.Count > 0) { EURCurvesBL bll = new EURCurvesBL(); bll.UpdateCurve(); bll.ImportEURCurves(importedList); LogActivity("EURCurves Imported", "EURCurves", string.Empty); } else { RadWindowManager1.RadAlert("No Data found", 330, 180, "realedge associates", "alertCallBackFn"); return; } } else if (ddlImportType.SelectedValue == "US Curve") { List<USDCurve> importedList = ExtractUSDCurveList(csvData, columnNames); if (importedList.Count > 0) { USDCurveBL bll = new USDCurveBL(); bll.UpdateCurve(); bll.ImportUSDCurves(importedList); LogActivity("USDCurve Imported", "USDCurves", string.Empty); } else { RadWindowManager1.RadAlert("No Data found", 330, 180, "realedge associates", "alertCallBackFn"); return; } } //ShowMessage("Message", "Data has been imported successfully"); RadWindowManager1.RadAlert("Data has been imported successfully", 330, 180, "realedge associates", "alertCallBackFn"); } catch (Exception ex) { LogActivity("File Upload(Unsuccessfull)", "Unable to upload the file", ex.Message); //lblImportStatus.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; RadWindowManager1.RadAlert("Data import failed", 330, 180, "realedge associates", "alertCallBackFn"); } }