public List<InstPositionInfo> loadPositionData()
        {
            DataTable tb = new DataTable();

            using (SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\Data_Interface\\MarketDataBase.sdf"))
            using (SqlCeCommand command = connection.CreateCommand())
            {

                command.CommandText = "SELECT KR_CODE , INST_NAME , INST_CODE , INST_TYPE , " +
                                            " BOOKED_DATE , UNBOOKED_DATE , MATURITY_DATE , " +
                                            " FILE_NAME , POSITION_NAME , COUNTERPARTY , " +
                                            " NOTIONAL , CURRENCY , FUND_CODE , FUND_NAME FROM POSITIONMASTER";
                                        

                connection.Open();
                SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command.CommandText, connection);

                dataAdapter.Fill(tb);
            }

            List<InstPositionInfo> positionList = new List<InstPositionInfo>();

            DataLoader loader = new DataLoader();

            DataRow[] resultRows = tb.Select();

            foreach (DataRow item in resultRows)
	        {
                InstPositionInfo instData = new InstPositionInfo(item["KR_CODE"].ToString(),
                                                 item["INST_NAME"].ToString(),
                                                 item["INST_CODE"].ToString(),
                                                 item["INST_TYPE"].ToString(),
                                                 item["BOOKED_DATE"].ToString(),
                                                 item["UNBOOKED_DATE"].ToString(),
                                                 item["MATURITY_DATE"].ToString(),
                                                 item["FILE_NAME"].ToString(),
                                                 item["POSITION_NAME"].ToString(),
                                                 item["COUNTERPARTY"].ToString(),
                                                 item["NOTIONAL"].ToString(),
                                                 item["CURRENCY"].ToString(),
                                                 item["FUND_CODE"].ToString(),
                                                 item["FUND_NAME"].ToString()
                                                 );
                positionList.Add(instData);

	        }

            return positionList;
        }
        public List<ResultMasterInfo> loadResultData()
        {
            DataTable tb = new DataTable();

            using (SqlCeConnection connection = new SqlCeConnection("Data Source=D:\\Project File\\OTCDerivativesCalculatorModule\\Project_CSharp\\RiskMonitor\\Data\\Data_Interface\\MarketDataBase.sdf"))
            using (SqlCeCommand command = connection.CreateCommand())
            {

                command.CommandText = "SELECT KR_CODE , INST_NAME , INST_CODE , CAL_VALUE , " +
                                            " CAL_UNIT_VALUE , REFERENCE_DATE , CALCULATE_DATE , " +
                                            " FILE_NAME , INST_TYPE , RESULT_TYPE FROM RESULTMASTER";
                                        

                connection.Open();
                SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command.CommandText, connection);

                dataAdapter.Fill(tb);
            }

            List<ResultMasterInfo> resultList = new List<ResultMasterInfo>();

            DataLoader loader = new DataLoader();

            DataRow[] resultRows = tb.Select();

            foreach (DataRow item in resultRows)
	        {
                ResultMasterInfo resultData = new ResultMasterInfo(item["KR_CODE"].ToString(),
                                                 item["INST_NAME"].ToString(),
                                                 item["INST_CODE"].ToString(),
                                                 item["CAL_VALUE"].ToString(),
                                                 item["CAL_UNIT_VALUE"].ToString(),
                                                 item["REFERENCE_DATE"].ToString(),
                                                 item["CALCULATE_DATE"].ToString(),
                                                 item["FILE_NAME"].ToString(),
                                                 item["INST_TYPE"].ToString(),
                                                 item["RESULT_TYPE"].ToString()
                                                 );
                resultList.Add(resultData);

	        }

            return resultList;
        }
        public ObservableCollection<PositionBookingInfoVM> loadPositionBookingInfoVM()
        {
            

            DataTable tb = new DataTable();

            using (SqlCeConnection connection = new SqlCeConnection(@"Data Source=D:\Project File\OTCDerivativesCalculatorModule\ExcelOTCManagerAddIn\PositionMasterInformationDB.sdf"))
            using (SqlCeCommand command = connection.CreateCommand())
            {

                command.CommandText = "SELECT " +
                                        "ITEMCODE,"+
                                        "KRCODE,"+
                                        "TEAMCODE,"+
                                        "FUNDCODE,"+
                                        "BOOKID,"+
                                        "EXCELTYPE,"+
                                        "PRODUCTTYPE,"+
                                        "GROUPID,"+
                                        "GROUPSTATE,"+
                                        "ITEMNAME,"+
                                        "SHORTNAME,"+
                                        "ISSUEDATE,"+
                                        "MATURITYDATE,"+
                                        "UNDERLYING,"+
                                        "COUNTERPARTY,"+
                                        "CONTRACTTYPE,"+
                                        "NOTIONAL,"+
                                        "CURRENCY,"+
                                        "BOOKEDORDER,"+
                                        "BOOKINGSTATE,"+
                                        "BOOKINGDATE "+

                                        "FROM MASTERINFO";


                connection.Open();
                SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command.CommandText, connection);

                dataAdapter.Fill(tb);
            }

            ObservableCollection<PositionBookingInfoVM> vmList = new ObservableCollection<PositionBookingInfoVM>();

            DataLoader loader = new DataLoader();

            DataRow[] resultRows = tb.Select();

            foreach (DataRow item in resultRows)
            {
                PositionBookingInfoVM positionData 
                    = new PositionBookingInfoVM(item["ITEMCODE"].ToString(),
                                                item["KRCODE"].ToString(),
                                                item["TEAMCODE"].ToString(),
                                                item["FUNDCODE"].ToString(),
                                                item["BOOKID"].ToString(),
                                                item["EXCELTYPE"].ToString(),
                                                item["PRODUCTTYPE"].ToString(),
                                                item["GROUPID"].ToString(),
                                                item["GROUPSTATE"].ToString(),
                                                item["ITEMNAME"].ToString(),
                                                item["SHORTNAME"].ToString(),
                                                item["ISSUEDATE"].ToString(),
                                                item["MATURITYDATE"].ToString(),
                                                item["UNDERLYING"].ToString(),
                                                item["COUNTERPARTY"].ToString(),
                                                item["CONTRACTTYPE"].ToString(),
                                                item["NOTIONAL"].ToString(),
                                                item["CURRENCY"].ToString(),
                                                item["BOOKEDORDER"].ToString(),
                                                item["BOOKINGSTATE"].ToString(),
                                                item["BOOKINGDATE"].ToString());

                vmList.Add(positionData);

            }

            return vmList;
        }
        public ObservableCollection <PositionBookingInfoVM> loadPositionBookingInfoVM()
        {
            DataTable tb = new DataTable();

            using (SqlCeConnection connection = new SqlCeConnection(@"Data Source=D:\Project File\OTCDerivativesCalculatorModule\ExcelOTCManagerAddIn\PositionMasterInformationDB.sdf"))
                using (SqlCeCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT " +
                                          "ITEMCODE," +
                                          "KRCODE," +
                                          "TEAMCODE," +
                                          "FUNDCODE," +
                                          "BOOKID," +
                                          "EXCELTYPE," +
                                          "PRODUCTTYPE," +
                                          "GROUPID," +
                                          "GROUPSTATE," +
                                          "ITEMNAME," +
                                          "SHORTNAME," +
                                          "ISSUEDATE," +
                                          "MATURITYDATE," +
                                          "UNDERLYING," +
                                          "COUNTERPARTY," +
                                          "CONTRACTTYPE," +
                                          "NOTIONAL," +
                                          "CURRENCY," +
                                          "BOOKEDORDER," +
                                          "BOOKINGSTATE," +
                                          "BOOKINGDATE " +

                                          "FROM MASTERINFO";


                    connection.Open();
                    SqlCeDataAdapter dataAdapter = new SqlCeDataAdapter(command.CommandText, connection);

                    dataAdapter.Fill(tb);
                }

            ObservableCollection <PositionBookingInfoVM> vmList = new ObservableCollection <PositionBookingInfoVM>();

            DataLoader loader = new DataLoader();

            DataRow[] resultRows = tb.Select();

            foreach (DataRow item in resultRows)
            {
                PositionBookingInfoVM positionData
                    = new PositionBookingInfoVM(item["ITEMCODE"].ToString(),
                                                item["KRCODE"].ToString(),
                                                item["TEAMCODE"].ToString(),
                                                item["FUNDCODE"].ToString(),
                                                item["BOOKID"].ToString(),
                                                item["EXCELTYPE"].ToString(),
                                                item["PRODUCTTYPE"].ToString(),
                                                item["GROUPID"].ToString(),
                                                item["GROUPSTATE"].ToString(),
                                                item["ITEMNAME"].ToString(),
                                                item["SHORTNAME"].ToString(),
                                                item["ISSUEDATE"].ToString(),
                                                item["MATURITYDATE"].ToString(),
                                                item["UNDERLYING"].ToString(),
                                                item["COUNTERPARTY"].ToString(),
                                                item["CONTRACTTYPE"].ToString(),
                                                item["NOTIONAL"].ToString(),
                                                item["CURRENCY"].ToString(),
                                                item["BOOKEDORDER"].ToString(),
                                                item["BOOKINGSTATE"].ToString(),
                                                item["BOOKINGDATE"].ToString());

                vmList.Add(positionData);
            }

            return(vmList);
        }