예제 #1
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;
        }
예제 #2
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);
        }