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 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)
            {
            }
        }
Example #3
0
 ///
 /// Insert Duplicate Records
 ///
 public void SaveDuplicateLoan(DuplicateLoan model)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (model.ID > 0)
         {
             context.AddObject("DuplicateLoans", model);
         }
         else
         {
             context.AddToDuplicateLoans(model);
         }
         context.SaveChanges();
     }
 }
Example #4
0
        public void EditLoan(Loans loan, int loanID, int type)
        {
            try
            {
                using (LoanPriceEntities context = new LoanPriceEntities())
                {

                    Loans oldLoan = context.Loans.FirstOrDefault(c => c.ID == loanID);
                    oldLoan.CodeName = loan.CodeName;
                    oldLoan.Borrower = loan.Borrower;
                    oldLoan.Sector = loan.Sector;
                    oldLoan.Signing_Date = loan.Signing_Date;
                    oldLoan.Maturity_Date = loan.Maturity_Date;
                    oldLoan.FixedOrFloating = loan.FixedOrFloating;
                    oldLoan.Margin = loan.Margin;
                    oldLoan.Currency = loan.Currency;
                    oldLoan.PP = loan.PP;
                    oldLoan.CreditRating = loan.CreditRating;
                    oldLoan.Country = loan.Country;
                    oldLoan.CouponFrequency = loan.CouponFrequency;
                    oldLoan.FacilitySize = loan.FacilitySize;
                    oldLoan.Bilateral = loan.Bilateral;
                    oldLoan.Amortizing = loan.Amortizing;

                    oldLoan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                    oldLoan.CouponDate = loan.CouponDate;
                    oldLoan.Notional = loan.Notional;
                    oldLoan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                    oldLoan.CreditRatingFitch = loan.CreditRatingFitch;
                    oldLoan.CreditRatingING = loan.CreditRatingING;
                    oldLoan.CreditRatingModys = loan.CreditRatingModys;
                    oldLoan.CreditRatingSPs = loan.CreditRatingSPs;
                    oldLoan.StructureID = loan.StructureID;

                    oldLoan.LastEdited = loan.LastEdited;
                    oldLoan.CreatedBy = loan.CreatedBy;

                    oldLoan.SummitCreditEntity = loan.SummitCreditEntity;
                    oldLoan.Grid = loan.Grid;
                    oldLoan.Gurantor = loan.Gurantor;
                    context.SaveChanges();

                    //if type == 1 then do not add to DuplicateLoan
                    if (CheckForLoanCode(loan.CodeName, loanID) && type != 1)
                    {
                        DuplicateLoan duplicateLoan = new DuplicateLoan();
                        duplicateLoan.CodeName = loan.CodeName;
                        duplicateLoan.Borrower = loan.Borrower;
                        duplicateLoan.Sector = loan.Sector;
                        duplicateLoan.Signing_Date = loan.Signing_Date;
                        duplicateLoan.Maturity_Date = loan.Maturity_Date;
                        duplicateLoan.FixedOrFloating = loan.FixedOrFloating;
                        duplicateLoan.Margin = loan.Margin;
                        duplicateLoan.Currency = loan.Currency;

                        duplicateLoan.Country = loan.Country;
                        duplicateLoan.CouponFrequency = loan.CouponFrequency;
                        duplicateLoan.FacilitySize = loan.FacilitySize;
                        duplicateLoan.Bilateral = loan.Bilateral;
                        duplicateLoan.Amortizing = loan.Amortizing;

                        duplicateLoan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                        duplicateLoan.CouponDate = loan.CouponDate;
                        duplicateLoan.Notional = loan.Notional;
                        duplicateLoan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                        context.AddToDuplicateLoans(duplicateLoan);
                        context.SaveChanges();
                    }

                }
            }
            catch (Exception)
            {
            }
        }
Example #5
0
        public string AddImportedLoans(Loans item)
        {
            LogsBLL logBL = new LogsBLL();
            string str = "";
            try
            {
                using (LoanPriceEntities context = new LoanPriceEntities())
                {
                    string codeName = item.CodeName;
                    if (CheckForLoanCode(item.CodeName))
                    {

                        context.AddToLoans(item);
                        context.SaveChanges();
                        //item = GetLoanByCode(codeName);

                        LoanScheduleBL loanScheduleBL = new LoanScheduleBL();
                        string couponDT = item.CouponDate.ToString();
                        DateTime cpnDT;
                        if (couponDT == string.Empty)
                            cpnDT = AddBusinessDays(DateTime.Now, 10);
                        else
                            cpnDT = Convert.ToDateTime(item.CouponDate);
                        DateTime tradeDate = DateTime.Now;
                        DataTable dtSchedule = loanScheduleBL.GenerateTable(15, Convert.ToInt16(item.NoOfAmortisationPoint), Convert.ToDateTime(item.AmortisationsStartPoint), item.CouponFrequency.ToString(), item.Notional.ToString(), Convert.ToDateTime(item.Maturity_Date), Convert.ToDateTime(item.CouponDate), Convert.ToDecimal(item.Margin), Convert.ToString(item.Currency), Convert.ToDateTime(tradeDate), AddBusinessDays(Convert.ToDateTime(tradeDate), 10));
                        if (dtSchedule != null)
                        {
                            try
                            {
                                foreach (DataRow dr in dtSchedule.Rows)
                                {
                                    LoanSchedule loanSchedule = new LoanSchedule();
                                    loanSchedule.LoanID = item.ID;
                                    loanSchedule.StartDate = Convert.ToDateTime(dr["StartDate"]);
                                    loanSchedule.EndDate = Convert.ToDateTime(dr["EndDate"]);
                                    loanSchedule.Notation = Convert.ToDecimal(dr["Notation"]);
                                    loanSchedule.CoupFrac = Convert.ToDecimal(dr["CoupFrac"]);
                                    loanSchedule.Amortisation = Convert.ToDecimal(dr["Amortisation"]);
                                    loanSchedule.Factor = Convert.ToDecimal(dr["Factor"]);
                                    loanSchedule.CouponPaymentDate = Convert.ToDateTime(dr["CouponPaymentDate"]);
                                    loanSchedule.Spread = Convert.ToDecimal(dr["Spread"]);
                                    loanSchedule.RiskFreeDP1 = Convert.ToDecimal(dr["RiskFreeDP1"]);
                                    loanSchedule.RiskFreeDP2 = Convert.ToDecimal(dr["RiskFreeDP2"]);
                                    loanSchedule.FloatingRate = Convert.ToDecimal(dr["FloatingRate"]);
                                    loanSchedule.AllInRate = Convert.ToDecimal(dr["AllInRate"]);
                                    loanSchedule.Interest = Convert.ToDecimal(dr["Interest"]);
                                    loanSchedule.Days = Convert.ToInt16(dr["Days"]);
                                    loanSchedule.AmortisationInt = Convert.ToDecimal(dr["AmortisationInt"]);
                                    loanScheduleBL.SaveLoanSchedule(loanSchedule);
                                }
                            }
                            catch (Exception ex)
                            {
                                str = ex.Message;
                                //  str = ex.Message;
                            }
                        }
                    }
                    else
                    {
                        DuplicateLoan loan = new DuplicateLoan();
                        loan.CodeName = item.CodeName;
                        loan.Borrower = item.Borrower;
                        loan.Country = item.Country;
                        loan.Sector = item.Sector;
                        loan.Maturity_Date = item.Maturity_Date;
                        loan.Signing_Date = item.Signing_Date;
                        loan.FixedOrFloating = item.FixedOrFloating;
                        loan.Margin = item.Margin;
                        loan.Currency = item.Currency;
                        loan.CouponFrequency = item.CouponFrequency;
                        loan.FacilitySize = item.FacilitySize;
                        loan.Bilateral = item.Bilateral;
                        loan.Amortizing = item.Amortizing;

                        loan.AmortisationsStartPoint = loan.AmortisationsStartPoint;
                        loan.CouponDate = loan.CouponDate;
                        loan.Notional = loan.Notional;
                        loan.NoOfAmortisationPoint = loan.NoOfAmortisationPoint;

                        context.AddToDuplicateLoans(loan); context.SaveChanges();
                    }

                }
            }
            catch (Exception ex)
            {

                str = ex.Message;
                if (ex.InnerException != null)
                {
                    str = str + " :: " + ex.InnerException.Message;
                }
            }
            return str;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the DuplicateLoans EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDuplicateLoans(DuplicateLoan duplicateLoan)
 {
     base.AddObject("DuplicateLoans", duplicateLoan);
 }
 /// <summary>
 /// Create a new DuplicateLoan object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static DuplicateLoan CreateDuplicateLoan(global::System.Int32 id)
 {
     DuplicateLoan duplicateLoan = new DuplicateLoan();
     duplicateLoan.ID = id;
     return duplicateLoan;
 }