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

            this.rateDateDataGrid_.ItemsSource = this.viewModel_.RateDataViewModel_;

            //scheduleDataGrid_.ItemsSource = this.viewModel_.RedemptionEvents_;
            //this.PayoffStackPanel_.Children.Add(this.viewModel_.ReturnCalculationViewModel_.ReturnCalculationView_);
        }
        private DiscountCurve_paraViewModel discount_paraVM(string itemCode)
        {
            DiscountCurve_paraViewModel discount_paraVM = new DiscountCurve_paraViewModel();
            YieldTermstructureViewModel yieldTSVM       = new YieldTermstructureViewModel();

            yieldTSVM.Type_                  = "ZEROYIELD";
            yieldTSVM.Interpolation_         = "BACKWARDFLAT";
            yieldTSVM.Daycounter_            = "ACT365FIX";
            yieldTSVM.Calendar_              = "NULLCALENDAR";
            yieldTSVM.BusinessDayConvention_ = "Following";

            QueryStr queryStr = new QueryStr(this.discountQueryInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("CURVE_CODE", "S");
            queryStr.VariableMap_.Add("BOND_CLASS_ID", "111001");

            conn_.clearQuery();
            conn_.addQuery("discountCurve", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["discountCurve"];

            foreach (DataRow item in tb.Rows)
            {
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("1", "D", (Convert.ToDouble(item["D001"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("3", "M", (Convert.ToDouble(item["M003"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("6", "M", (Convert.ToDouble(item["M006"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("9", "M", (Convert.ToDouble(item["M009"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("12", "M", (Convert.ToDouble(item["M012"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("18", "M", (Convert.ToDouble(item["M018"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("24", "M", (Convert.ToDouble(item["M024"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("30", "M", (Convert.ToDouble(item["M030"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("36", "M", (Convert.ToDouble(item["M036"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("48", "M", (Convert.ToDouble(item["M048"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("60", "M", (Convert.ToDouble(item["M060"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("84", "M", (Convert.ToDouble(item["M084"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("120", "M", (Convert.ToDouble(item["M120"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("180", "M", (Convert.ToDouble(item["M180"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("240", "M", (Convert.ToDouble(item["M240"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("360", "M", (Convert.ToDouble(item["M360"].ToString()) / 100).ToString()));
            }

            discount_paraVM.YieldTermstructureViewModel_.Add(yieldTSVM);

            return(discount_paraVM);
        }
        public override void buildXml()
        {

            YieldTermstructureViewModel ytvm = new YieldTermstructureViewModel();
            ytvm.CurveType_ = this.curveType_;
            ytvm.Interpolation_ = this.interpolation_;
            ytvm.Daycounter_ = this.daycounter_;
            ytvm.Calendar_ = this.calendar_;
            ytvm.BusinessDayConvention_ = this.businessDC_;

            for (int i = 0; i < tenorArr_.Length ; i++)
            {
                RateDataViewModel rdvm = new RateDataViewModel();
                rdvm.PeriodMultiplier_ = this.tenorArr_[i].Substring(0,this.tenorArr_[i].Length - 1);
                rdvm.Period_ = this.tenorArr_[i].Substring(this.tenorArr_[i].Length - 1);
                rdvm.Data_ = this.dataArr_[i];

                ytvm.RateDataViewModel_.Add(rdvm);

            }

            this.yieldCurveVM_ = ytvm;
            //ytvm.buildXml();
        }
        private DiscountCurve_paraViewModel discount_paraVM(string itemCode)
        {
            DiscountCurve_paraViewModel discount_paraVM = new DiscountCurve_paraViewModel();
            YieldTermstructureViewModel yieldTSVM = new YieldTermstructureViewModel();

            yieldTSVM.Type_ = "ZEROYIELD";
            yieldTSVM.Interpolation_ = "BACKWARDFLAT";
            yieldTSVM.Daycounter_ = "ACT365FIX";
            yieldTSVM.Calendar_ = "NULLCALENDAR";
            yieldTSVM.BusinessDayConvention_ = "Following";

            QueryStr queryStr = new QueryStr(this.discountQueryInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("CURVE_CODE", "S");
            queryStr.VariableMap_.Add("BOND_CLASS_ID","111001");
            
            conn_.clearQuery();
            conn_.addQuery("discountCurve", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["discountCurve"];

            foreach (DataRow item in tb.Rows)
	        {
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("1","D", ( Convert.ToDouble(item["D001"].ToString())/100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("3", "M", ( Convert.ToDouble(item["M003"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("6", "M", ( Convert.ToDouble(item["M006"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("9", "M", ( Convert.ToDouble(item["M009"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("12", "M", ( Convert.ToDouble(item["M012"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("18", "M", ( Convert.ToDouble(item["M018"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("24", "M", ( Convert.ToDouble(item["M024"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("30", "M", ( Convert.ToDouble(item["M030"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("36", "M", ( Convert.ToDouble(item["M036"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("48", "M", ( Convert.ToDouble(item["M048"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("60", "M", ( Convert.ToDouble(item["M060"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("84", "M", ( Convert.ToDouble(item["M084"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("120", "M", ( Convert.ToDouble(item["M120"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("180", "M", ( Convert.ToDouble(item["M180"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("240", "M", ( Convert.ToDouble(item["M240"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("360", "M", ( Convert.ToDouble(item["M360"].ToString()) / 100).ToString() ));

	        }

            discount_paraVM.YieldTermstructureViewModel_.Add(yieldTSVM);

            return discount_paraVM;
        }