コード例 #1
0
        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)
            {

            }
        }
コード例 #2
0
        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)
            {
            }
        }
コード例 #3
0
        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;
                }

            }
        }
コード例 #4
0
        public void UpdateQuote(QuotesAndTrades quote)
        {
            using (LoanPriceEntities context = new LoanPriceEntities())
            {
                QuotesAndTrades model = context.QuotesAndTrades.SingleOrDefault(c => c.ID == quote.ID);
                if (model != null)
                {
                    model.CounterParty = quote.CounterParty;
                    model.BidPrice = quote.BidPrice;
                    model.OfferPrice = quote.OfferPrice;
                    model.BidSpread = quote.BidSpread;
                    model.OfferSpread = quote.OfferSpread;
                    model.Traded = quote.Traded;
                    model.MarketValue = quote.MarketValue;
                    model.Country = quote.Country;
                    model.TimeStamp = quote.TimeStamp;

                    model.LoanName = quote.LoanName;
                    model.AvgLifeDisc = quote.AvgLifeDisc;
                    model.AvgLifeNonDisc = quote.AvgLifeNonDisc;
                    model.AvgLifeRiskDisc = quote.AvgLifeRiskDisc;
                    if (quote.SettlementDate != Convert.ToDateTime("01/01/0001 00:00:00"))
                    {
                        model.SettlementDate = quote.SettlementDate;
                    }
                    model.TradedDate = quote.TradedDate;
                    model.Margin = quote.Margin;
                    context.SaveChanges();
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void SaveQuotesAndTrades(QuotesAndTrades model)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (model.ID > 0)
         {
             context.AddObject("QuotesAndTrades", model);
         }
         else
         {
             context.AddToQuotesAndTrades(model);
         }
         context.SaveChanges();
     }
 }
コード例 #7
0
 /// <summary>
 /// New Quote and trade added
 /// </summary>
 /// <param name="quoteAndTrade"></param>
 public static void NewQuotesAndTradeAdded(QuotesAndTrades quoteAndTrade)
 {
     var context = GlobalHost.ConnectionManager.GetHubContext<ApplicationHub>();
     context.Clients.All.onQuotesAndTradeAdded(quoteAndTrade);
 }
コード例 #8
0
 /// <summary>
 /// Create a new QuotesAndTrades object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static QuotesAndTrades CreateQuotesAndTrades(global::System.Int32 id)
 {
     QuotesAndTrades quotesAndTrades = new QuotesAndTrades();
     quotesAndTrades.ID = id;
     return quotesAndTrades;
 }
コード例 #9
0
 /// <summary>
 /// Deprecated Method for adding a new object to the QuotesAndTrades EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToQuotesAndTrades(QuotesAndTrades quotesAndTrades)
 {
     base.AddObject("QuotesAndTrades", quotesAndTrades);
 }
コード例 #10
0
        private static List<QuotesAndTrades> ExtractQuotesAndTradesList(DataTable csvData, List<string> columnNames)
        {
            List<QuotesAndTrades> importedList = new List<QuotesAndTrades>();
            foreach (DataRow row in csvData.Rows)
            {
                QuotesAndTrades model = new QuotesAndTrades();
                // 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 = typeConverter.ConvertFromString(value.ToString());
                        object propValue = null;
                        if (typeConverter.GetType().FullName == "System.ComponentModel.NullableConverter")
                        {
                            if (value.ToString().Trim() == "Yes")
                            {
                                propValue = typeConverter.ConvertFromString(("True"));
                            }
                            else if (value != "0")
                            {
                                propValue = typeConverter.ConvertFromString((value.ToString()));
                            }
                            else
                            {
                                propValue = typeConverter.ConvertFromString(("False"));
                            }
                        }
                        else
                            propValue = typeConverter.ConvertFromString((value.ToString()));

                        // Set value on the property
                        pInfo.SetValue(model, propValue, null);
                    }
                }
                importedList.Add(model);
            }
            return importedList;
        }