Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 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)
            {
            }
        }