private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this.viewModel_ = this.DataContext as Excel_choiceUnderlyingCalcIDViewModel;

            this.underlyingSelectListView_.ItemsSource = this.viewModel_.Excel_selectedUnderlyingViewModel_;

        }
        public override Excel_underlyingCalcIDViewModel Clone()
        {
            Excel_choiceUnderlyingCalcIDViewModel clone = new Excel_choiceUnderlyingCalcIDViewModel();

            foreach (var item in this.excel_selectedUnderlyingViewModel_)
            {
                clone.excel_selectedUnderlyingViewModel_ = new ObservableCollection <Excel_selectedUnderlyingViewModel>();
                clone.excel_selectedUnderlyingViewModel_.Add(item.Clone());
            }

            clone.EventDate_   = this.eventDate_;
            clone.AverageDays_ = this.averageDays_;

            return(clone);
        }
        private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this.viewModel_ = this.DataContext as Excel_choiceUnderlyingCalcIDViewModel;

            this.underlyingSelectListView_.ItemsSource = this.viewModel_.Excel_selectedUnderlyingViewModel_;
        }
        public void addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                DateTime calculationEndDate,
                                                DateTime payoffDate,
                                                List<double> lowerRngList,
                                                List<string> referenceUnderCodeList,
                                                List<double> upperRngList,
                                                double fixedRate)
        {
            Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                    = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

            e_mc_mr_sacsvm.EventDate_ = payoffDate;

            e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
            e_mc_mr_sacsvm.CalculationEndDate_ = calculationEndDate;
            e_mc_mr_sacsvm.PayoffDate_ = payoffDate;

            int rangeCount = lowerRngList.Count;

            Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

            for (int i = 0; i < rangeCount; i++)
            {
                Range1DViewModel accRng1D = new Range1DViewModel();

                accRng1D.LowerBound_ = lowerRngList[i].ToString();

                DateTime effDate = this.instVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;
                
                //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                this.addUnderlying(effDate, referenceUnderCodeList[i]);

                Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                choiceUnderCalcIDVM.EventDate_ = payoffDate;

                Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                selectedUnder.Code_ = referenceUnderCodeList[i];
                selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                selectedUnder.Checked_ = true;

                choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                accRng1D.UpperBound_ = upperRngList[i].ToString();

                e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
            }

            e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

            Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

            e_crcvm.ConstReturn_ = fixedRate.ToString();

            e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

            //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

            Excel_structuredBondViewModel e_sbvm = this.instVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

            e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

            //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;
        }
        public string addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                DateTime calculationEndDate,
                                                DateTime payoffDate,
                                                List<double> lowerRngList,
                                                List<string> referenceUnderCodeList,
                                                List<double> upperRngList,
                                                double fixedRate)
        {
            try
            {
                #region CheckParameter

                if (calculationStartDate >= calculationEndDate)
                    throw new Exception("startDate must be earlier than endDate");

                //// check underlying 
                //if ( !this.hasUnderlyings(underlyings))
                //    throw new Exception(underlyings + " does not exist. add underlying first.");


                #endregion

                Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                        = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

                e_mc_mr_sacsvm.EventDate_ = payoffDate;

                e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
                e_mc_mr_sacsvm.CalculationEndDate_ = calculationEndDate;
                e_mc_mr_sacsvm.PayoffDate_ = payoffDate;

                int rangeCount = lowerRngList.Count;

                Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

                for (int i = 0; i < rangeCount; i++)
                {
                    Range1DViewModel accRng1D = new Range1DViewModel();

                    accRng1D.LowerBound_ = lowerRngList[i].ToString();

                    DateTime effDate = this.InstVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;

                    //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                    this.addUnderlying(referenceUnderCodeList[i]);

                    Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                    choiceUnderCalcIDVM.EventDate_ = payoffDate;

                    Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                    selectedUnder.Code_ = referenceUnderCodeList[i];
                    selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                    selectedUnder.Checked_ = true;

                    choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                    accRng1D.UpperBound_ = upperRngList[i].ToString();

                    e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                    e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
                }

                e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.ConstReturn_ = fixedRate.ToString();

                e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

                //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

                Excel_structuredBondViewModel e_sbvm = this.InstVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

                e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

                //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;

                return "OK";
            }
            catch (Exception)
            {
                return "singleConditionDualRangAccrualFixedCoupon Add Fail";
            }
        }
        public void addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                                 DateTime calculationEndDate,
                                                                 DateTime payoffDate,
                                                                 List <double> lowerRngList,
                                                                 List <string> referenceUnderCodeList,
                                                                 List <double> upperRngList,
                                                                 double fixedRate)
        {
            Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

            e_mc_mr_sacsvm.EventDate_ = payoffDate;

            e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
            e_mc_mr_sacsvm.CalculationEndDate_   = calculationEndDate;
            e_mc_mr_sacsvm.PayoffDate_           = payoffDate;

            int rangeCount = lowerRngList.Count;

            Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

            for (int i = 0; i < rangeCount; i++)
            {
                Range1DViewModel accRng1D = new Range1DViewModel();

                accRng1D.LowerBound_ = lowerRngList[i].ToString();

                DateTime effDate = this.instVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;

                //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                this.addUnderlying(effDate, referenceUnderCodeList[i]);

                Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                choiceUnderCalcIDVM.EventDate_ = payoffDate;

                Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                selectedUnder.Code_      = referenceUnderCodeList[i];
                selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                selectedUnder.Checked_   = true;

                choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                accRng1D.UpperBound_ = upperRngList[i].ToString();

                e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
            }

            e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

            Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

            e_crcvm.ConstReturn_ = fixedRate.ToString();

            e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

            //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

            Excel_structuredBondViewModel e_sbvm = this.instVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

            e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

            //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;
        }
        public override Excel_underlyingCalcIDViewModel Clone()
        {
            Excel_choiceUnderlyingCalcIDViewModel clone = new Excel_choiceUnderlyingCalcIDViewModel();

            foreach (var item in this.excel_selectedUnderlyingViewModel_)
            {
                clone.excel_selectedUnderlyingViewModel_ = new ObservableCollection<Excel_selectedUnderlyingViewModel>();
                clone.excel_selectedUnderlyingViewModel_.Add(item.Clone());
            }

            clone.EventDate_ = this.eventDate_;
            clone.AverageDays_ = this.averageDays_;

            return clone;
            
        }