Пример #1
0
        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)
            {
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        private void CheckNodes(RadDropDownTree treeView, Loans loan)
        {
            //RadTreeNode nodeCollection = treeView.Nodes[0];
            //foreach (var item in nodeCollection.Nodes)
            //{
            //    switch (((Telerik.Web.UI.RadTreeNode)(item)).Text)
            //    {
            //        case "Moody's":
            //            foreach (var node in nodeCollection.Nodes.FindNodeByText("Moody's").Nodes)
            //            {
            //                if (((Telerik.Web.UI.RadTreeNode)(node)).Text == loan.CreditRatingModys)
            //                {
            //                    ((Telerik.Web.UI.RadTreeNode)(node)).Checked = true;
            //                }
            //            }
            //            break;
            //        case "ING":
            //            foreach (var node in nodeCollection.Nodes.FindNodeByText("ING").Nodes)
            //            {
            //                if (((Telerik.Web.UI.RadTreeNode)(node)).Text == loan.CreditRatingING)
            //                {
            //                    ((Telerik.Web.UI.RadTreeNode)(node)).Checked = true;
            //                }
            //            }
            //            break;
            //        case "S&P's":
            //            foreach (var node in nodeCollection.Nodes.FindNodeByText("S&P's").Nodes)
            //            {
            //                if (((Telerik.Web.UI.RadTreeNode)(node)).Text == loan.CreditRatingSPs)
            //                {
            //                    ((Telerik.Web.UI.RadTreeNode)(node)).Checked = true;
            //                }
            //            }
            //            break;
            //        case "Fitch":
            //            foreach (var node in nodeCollection.Nodes.FindNodeByText("Fitch").Nodes)
            //            {
            //                if (((Telerik.Web.UI.RadTreeNode)(node)).Text == loan.CreditRatingFitch)
            //                {
            //                    ((Telerik.Web.UI.RadTreeNode)(node)).Checked = true;
            //                }
            //            }
            //            break;
            //        default:
            //            break;
            //    }
            //}
            string[] child = new string[100];
            string[] parent = new string[100];
            int i = 0, j = 0;
            string strSelectedText = string.Empty;
            foreach (RadTreeNode node in treeView.EmbeddedTree.Nodes)
            {
                parent[j] = node.Text;
                j++;
                switch (node.Text)
                {
                    case "Moody's":
                        if (node.GetAllNodes().Count != 0)
                        {
                            foreach (RadTreeNode subnode in node.GetAllNodes())
                            {
                                child[i] = subnode.Text;
                                if (subnode.Text == loan.CreditRatingModys)
                                {
                                    subnode.Checked = true;
                                    if (strSelectedText == string.Empty)
                                        strSelectedText = subnode.Text;
                                    else
                                        strSelectedText = strSelectedText + ";" + subnode.Text;

                                }

                                i++;
                            }
                        }
                        break;
                    case "ING":
                        if (node.GetAllNodes().Count != 0)
                        {
                            foreach (RadTreeNode subnode in node.GetAllNodes())
                            {
                                child[i] = subnode.Text;
                                if (subnode.Text == loan.CreditRatingING)
                                {
                                    subnode.Checked = true;
                                    if (strSelectedText == string.Empty)
                                        strSelectedText = subnode.Text;
                                    else
                                        strSelectedText = strSelectedText + ";" + subnode.Text;
                                }

                                i++;
                            }
                        }
                        break;
                    case "S&P's":
                        if (node.GetAllNodes().Count != 0)
                        {
                            foreach (RadTreeNode subnode in node.GetAllNodes())
                            {
                                child[i] = subnode.Text;
                                if (subnode.Text == loan.CreditRatingSPs)
                                {
                                    subnode.Checked = true;
                                    if (strSelectedText == string.Empty)
                                        strSelectedText = subnode.Text;
                                    else
                                        strSelectedText = strSelectedText + ";" + subnode.Text;
                                }

                                i++;
                            }
                        }
                        break;
                    case "Fitch":
                        if (node.GetAllNodes().Count != 0)
                        {
                            foreach (RadTreeNode subnode in node.GetAllNodes())
                            {
                                child[i] = subnode.Text;
                                if (subnode.Text == loan.CreditRatingFitch)
                                {
                                    subnode.Checked = true;
                                    if (strSelectedText == string.Empty)
                                        strSelectedText = subnode.Text;
                                    else
                                        strSelectedText = strSelectedText + ";" + subnode.Text;
                                }

                                i++;
                            }
                        }
                        break;
                }

                treeView.SelectedText = strSelectedText;
            }
        }
Пример #4
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)
            {
            }
        }
Пример #5
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)
            {
            }
        }
Пример #6
0
 public void SaveLoan(Loans model)
 {
     using (LoanPriceEntities context = new LoanPriceEntities())
     {
         if (model.ID > 0)
         {
             context.AddObject("Loans", model);
         }
         else
         {
             context.AddToLoans(model);
         }
         context.SaveChanges();
     }
 }
Пример #7
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;
        }
Пример #8
0
 /// <summary>
 /// New loan get added
 /// </summary>
 /// <param name="loan"></param>
 public static void NewLoanAdded(Loans loan)
 {
     var context = GlobalHost.ConnectionManager.GetHubContext<ApplicationHub>();
     context.Clients.All.onLoanAdded(loan);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Loans EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLoans(Loans loans)
 {
     base.AddObject("Loans", loans);
 }
 /// <summary>
 /// Create a new Loans object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Loans CreateLoans(global::System.Int32 id)
 {
     Loans loans = new Loans();
     loans.ID = id;
     return loans;
 }
        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;
        }