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

            //ExplorerListView_.DataContext = InstExViewModel_;
            ExplorerListView_.ItemsSource = InstExViewModel_.InstHierarchyList_;
            OutputLogViewModel.addResult(new MessageOutput("ExplorerBookInstView : DataContext Changed"));
        }
Example #2
0
        public OutputLogView()
        {
            InitializeComponent();

            OutputLogViewModel.initialize(); //밖에서 initialize함.
            // 미리 에러가 날수 있으므로..

            //OutputLogViewModel.registerLogView(OutputAddTextBlock);
            //this.outputLogList_ = OutputLogViewModel.OutputList_;
            //this.OutputListView_.ItemsSource = this.OutputLogList_;
            this.OutputListView_.ItemsSource = OutputLogViewModel.OutputList_;
            //OutputLogViewModel.addResult("testError");
        }
        public ExplorerBookInstView(MainWindow mainWindow, BookInfoViewModel bookInfoVM)
        {
            InitializeComponent();
            this.mainWindow_ = mainWindow;

            //InstExViewModel_ = new InstrumentExplorerViewModel(mainWindow,bookInfoVM);

            this.DataContextChanged += new DependencyPropertyChangedEventHandler(ViewModelChanged);

            //ExplorerListView_.Height = mainWindow.DocumentPane_.DockHeight.Value;

            OutputLogViewModel.addResult(new MessageOutput("Explore Load Complete"));
        }
        public InstrumentExplorerViewCtrl(MainWindow mainWindow, BookInfoViewModel bookInfoVM)
        {
            InitializeComponent();
            this.mainWindow_ = mainWindow;

            InstExViewModel_ = new InstrumentExplorerViewModel(mainWindow, bookInfoVM);

            ExplorerListView_.DataContext = InstExViewModel_;
            ExplorerListView_.ItemsSource = InstExViewModel_.InstHierarchyList_;
            //ExplorerListView_.Height = mainWindow.DocumentPane_.DockHeight.Value;

            OutputLogViewModel.addResult(new MessageOutput("Explore Load Complete"));
        }
Example #5
0
        public void setFromXml(System.Xml.XmlNode InstNode)
        {
            //DateTime referenceDate = CustomFunction.StrToDate(resultparaXml.SelectSingleNode("pricing/evaluationTime").InnerText);
            //string itemCode = resultparaXml.SelectSingleNode("pricing/itemCode").InnerText;

            //this.Result_.ReferenceDate_ = referenceDate;
            //this.Result_.ItemCode_ = itemCode;

            //XmlNode pricingNode = resultparaXml.SelectSingleNode("pricing");
            //XmlNode resultparaNode = pricingNode.SelectSingleNode("pricingResult");

            OutputLogViewModel.addResult(new ErrorOutput("", ItemCode_, "Result Calulation Not yet"));
        }
Example #6
0
        //load parameter & result
        public void loadParaResult()
        {
            XmlDocument instXml = new XmlDocument();

            try
            {
                ParaResultXml_.Load(this.paraResultPath(this.ReferenceDate_));
                this.loadParaResultFromXml(this.ParaResultXml_);
            }
            catch (Exception e)
            {
                string errStr = "Source : " + e.Source + "\n" +
                                "Message : " + e.Message + "\n" +
                                "Location : " + e.StackTrace;

                //MessageBoxResult result = MessageBox.Show( , "Exception");

                OutputLogViewModel.addResult(errStr);
                throw;
            }
        }
        private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            //InstrumentHierarchyViewModel item = sender as InstrumentHierarchyViewModel;
            ExploreHirachyInstrumentVMWrapper item = ExplorerListView_.SelectedItem as ExploreHirachyInstrumentVMWrapper;

            if (item != null)
            {
                LayoutDocument layoutDoc = new LayoutDocument();
                //int count = this.Parent.ChildrenCount;
                //LayoutDocumentPane pane = new LayoutDocumentPane();
                Grid grid = new Grid();
                grid.Children.Add(item.view());
                layoutDoc.Content = grid;

                layoutDoc.Title = item.ItemCode_;

                mainWindow_.DocumentPane_.Children.Add(layoutDoc);
                OutputLogViewModel.addResult(new MessageOutput(item.ItemCode_ + " is loaded"));
            }


            //MainWindow.AddCtrlOnMainWindow(item.View_);
        }
        public void loadData()
        {
            OdbcConnection conn = new OdbcConnection();

            conn.ConnectionString = DBConnSetting_.ConnectionStr;
            //DateTime referenceDate = Settings.evaluationDate();
            DateTime referenceDate = ReferenceDate_;

            try
            {
                OdbcCommand sqlCommand = new OdbcCommand();

                conn.Open();

                // ------------------------------------------ Vol & Dividend --------------------------------------------
                sqlCommand.CommandText = "select STD_DATE,STOCK_ID,OTHER_ID,CORR " +
                                         "from otc_td_mrelsstockcorr " +
                                         "where STD_DATE='" + referenceDate.ToString("yyyyMMdd") + "'";

                OdbcDataAdapter dataAdapter = new OdbcDataAdapter(sqlCommand.CommandText, conn);

                DataTable tb = new DataTable();
                dataAdapter.Fill(tb);

                using (SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\MarketDataBase.sdf"))
                    using (SqlCeCommand command = connection.CreateCommand())
                    {
                        //command.CommandText = "INSERT INTO CORRELATION (DATE,   CODE_A,   NAME_A,   CODE_B,   NAME_B,   CORR,   TYPE,   VENDOR,  DESCRIPTION) " +
                        //                                       " VALUES (@pdate, @pcode_a, @pname_a ,@pcode_b, @pname_b, @pcorr, @ptype, @pvendor, @pdescription)" +
                        //                                       " WHERE DATE not in ( select DATE from CORRELATION where DATE='" + ReferenceDate_.ToString("yyyyMMdd") + "')";

                        connection.Open();

                        SqlCeCommand delCommand = connection.CreateCommand();
                        delCommand.CommandText = "DELETE FROM CORRELATION WHERE DATE ='" + ReferenceDate_.ToString("yyyyMMdd") + "'";

                        delCommand.ExecuteNonQuery();

                        command.CommandText = "INSERT INTO CORRELATION (DATE,   CODE_A,   NAME_A,   CODE_B,   NAME_B,   CORR,   TYPE,   VENDOR,  DESCRIPTION) " +
                                              " VALUES (@pdate, @pcode_a, @pname_a ,@pcode_b, @pname_b, @pcorr, @ptype, @pvendor, @pdescription)";

                        command.Parameters.Add("@pdate", SqlDbType.NVarChar);
                        command.Parameters.Add("@pcode_a", SqlDbType.NVarChar);
                        command.Parameters.Add("@pname_a", SqlDbType.NVarChar);
                        command.Parameters.Add("@pcode_b", SqlDbType.NVarChar);
                        command.Parameters.Add("@pname_b", SqlDbType.NVarChar);
                        command.Parameters.Add("@pcorr", SqlDbType.NVarChar);
                        command.Parameters.Add("@ptype", SqlDbType.NVarChar);
                        command.Parameters.Add("@pvendor", SqlDbType.NVarChar);
                        command.Parameters.Add("@pdescription", SqlDbType.NVarChar);



                        //command.ExecuteNonQuery();

                        foreach (DataRow item in tb.Rows)
                        {
                            string code_a = item["STOCK_ID"].ToString();
                            string code_b = item["OTHER_ID"].ToString();

                            if (code_a != code_b)
                            {
                                command.Parameters["@pdate"].Value        = item["STD_DATE"].ToString();
                                command.Parameters["@pcode_a"].Value      = code_a;
                                command.Parameters["@pname_a"].Value      = "null";
                                command.Parameters["@pcode_b"].Value      = code_b;
                                command.Parameters["@pname_b"].Value      = "null";
                                command.Parameters["@pcorr"].Value        = item["CORR"].ToString();
                                command.Parameters["@ptype"].Value        = "History";
                                command.Parameters["@pvendor"].Value      = "MRO";
                                command.Parameters["@pdescription"].Value = "This is test";

                                command.ExecuteNonQuery();
                            }
                        }
                    }

                conn.Close();
            }
            catch (OdbcException e)
            {
                conn.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : MRO DB Load");
                throw;
            }
        }
Example #9
0
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     OutputLogViewModel.clear();
 }
        public void addInstDB(InstPositionWrapperVM wrapperVM)
        {
            SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\Data_Interface\\MarketDataBase.sdf");

            try
            {
                DataTable tb = new DataTable();

                SqlCeCommand command = connection.CreateCommand();
                connection.Open();

                SqlCeCommand delCommand = connection.CreateCommand();
                //delCommand.CommandText = "DELETE FROM CORRELATION WHERE DATE ='" + ReferenceDate_.ToString("yyyyMMdd") + "'";
                //delCommand.ExecuteNonQuery();

                string KR_CODE       = QueryStr.wrapComma(wrapperVM.KRCode_);
                string INST_NAME     = QueryStr.wrapComma(wrapperVM.InstName_);
                string INST_CODE     = QueryStr.wrapComma(wrapperVM.InstCode_);
                string BOOKED_DATE   = QueryStr.wrapComma(wrapperVM.BookedDate_);
                string UNBOOKED_DATE = QueryStr.wrapComma(wrapperVM.UnBookedDate_);
                string MATURITY_DATE = QueryStr.wrapComma(wrapperVM.MaturityDate_);
                string INST_TYPE     = QueryStr.wrapComma(wrapperVM.InstType_);
                string FILE_NAME     = QueryStr.wrapComma(wrapperVM.FileName_);
                string POSITION_NAME = QueryStr.wrapComma(wrapperVM.PositionName_);
                string COUNTERPARTY  = QueryStr.wrapComma(wrapperVM.CounterParty_);
                string NOTIONAL      = QueryStr.wrapComma(wrapperVM.Notional_);
                string CURRENCY      = QueryStr.wrapComma(wrapperVM.Currency_);
                string FUND_CODE     = QueryStr.wrapComma(wrapperVM.FundCode_);
                string FUND_NAME     = QueryStr.wrapComma(wrapperVM.FundName_);

                command.CommandText = "INSERT INTO POSITIONMASTER (KR_CODE,INST_NAME,INST_CODE,BOOKED_DATE,UNBOOKED_DATE," +
                                      " MATURITY_DATE,INST_TYPE,FILE_NAME,POSITION_NAME,COUNTERPARTY," +
                                      " NOTIONAL,CURRENCY,FUND_CODE,FUND_NAME) " +
                                      " VALUES (" + KR_CODE + "," +
                                      INST_NAME + "," +
                                      INST_CODE + "," +
                                      BOOKED_DATE + "," +
                                      UNBOOKED_DATE + "," +
                                      MATURITY_DATE + "," +
                                      INST_TYPE + "," +
                                      FILE_NAME + "," +
                                      POSITION_NAME + "," +
                                      COUNTERPARTY + "," +
                                      NOTIONAL + "," +
                                      CURRENCY + "," +
                                      FUND_CODE + "," +
                                      FUND_NAME + ")";


                //command.ExecuteNonQuery();

                //command.Parameters.Add("@pdate", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcode_a", SqlDbType.NVarChar);
                //command.Parameters.Add("@pname_a", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcode_b", SqlDbType.NVarChar);
                //command.Parameters.Add("@pname_b", SqlDbType.NVarChar);
                //command.Parameters.Add("@pcorr", SqlDbType.NVarChar);
                //command.Parameters.Add("@ptype", SqlDbType.NVarChar);
                //command.Parameters.Add("@pvendor", SqlDbType.NVarChar);
                //command.Parameters.Add("@pdescription", SqlDbType.NVarChar);

                //foreach (DataRow item in tb.Rows)
                //{
                //    string code_a = item["STOCK_ID"].ToString();
                //    string code_b = item["OTHER_ID"].ToString();

                //    if (code_a != code_b)
                //    {
                //        command.Parameters["@pdate"].Value = item["STD_DATE"].ToString();
                //        command.Parameters["@pcode_a"].Value = code_a;
                //        command.Parameters["@pname_a"].Value = "null";
                //        command.Parameters["@pcode_b"].Value = code_b;
                //        command.Parameters["@pname_b"].Value = "null";
                //        command.Parameters["@pcorr"].Value = item["CORR"].ToString();
                //        command.Parameters["@ptype"].Value = "History";
                //        command.Parameters["@pvendor"].Value = "MRO";
                //        command.Parameters["@pdescription"].Value = "This is test";

                //        command.ExecuteNonQuery();
                //    }
                //}

                command.ExecuteNonQuery();

                connection.Close();
            }
            catch (SqlCeException e)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : MRO DB Load");
                throw;
            }
        }
        public void addInstDB(string tableName,
                              List <string> fieldName,
                              List <string> fieldValue)
        {
            // error fieldName Count != fieldValue;
            // table의 columnNum 와 filedNameCount 는 같아야함

            int fieldNameNum = fieldName.Count;

            SqlCeConnection connection = new SqlCeConnection(@"Data Source=D:\Project File\OTCDerivativesCalculatorModule\ExcelOTCManagerAddIn\PositionMasterInformationDB.sdf");

            List <string> wrappingFieldValue = new List <string>();

            foreach (var item in fieldValue)
            {
                wrappingFieldValue.Add(QueryStr.wrapComma(item));
            }

            try
            {
                StringBuilder sb = new StringBuilder();

                DataTable tb = new DataTable();

                SqlCeCommand command = connection.CreateCommand();
                connection.Open();

                SqlCeCommand delCommand = connection.CreateCommand();

                sb.Append("INSERT INTO " + tableName + " ( ");

                for (int i = 0; i < fieldNameNum; i++)
                {
                    sb.Append(fieldName[i]);

                    if (i != fieldNameNum - 1)
                    {
                        sb.Append(", ");
                    }
                }

                sb.Append(") ");

                sb.Append("VALUES (");

                for (int i = 0; i < fieldNameNum; i++)
                {
                    sb.Append(wrappingFieldValue[i]);

                    if (i != fieldNameNum - 1)
                    {
                        sb.Append(", ");
                    }
                }

                sb.Append(") ");

                command.CommandText = sb.ToString();

                command.ExecuteNonQuery();

                connection.Close();
            }
            catch (SqlCeException e)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : MRO DB Load");
                throw;
            }
        }