예제 #1
0
        public void setExportCode()
        {
            SqlCeConnection connection = new SqlCeConnection(connectionStr_);

            if (this.export_itemcode_ == null)
            {
                OutputLogViewModel.addResult("null input!");
                return;
            }


            try
            {
                DataTable tb = new DataTable();

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

                string itemCode           = QueryStr.wrapComma(this.item_code_);
                string exportItemCodeWrap = QueryStr.wrapComma(this.export_itemcode_);

                updateCommand.CommandText = "UPDATE MASTERINFORMATION SET EXPORT_ITEMCODE = " + exportItemCodeWrap +
                                            " WHERE ITEM_CODE = " + itemCode;

                updateCommand.ExecuteNonQuery();

                connection.Close();
            }
            catch (SqlCeException)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : DB Load");
                throw;
            }
        }
예제 #2
0
        public void insertHistoryDB()
        {
            INDEX_DATA_Table_DAO dao = new INDEX_DATA_Table_DAO();

            dao.INDEX_CODE_ = this.Code_;
            dao.INDEX_NAME_ = this.Name_;

            try
            {
                dao.deleteIndex(DataBaseConnectManager.ConnectionFactory("myDB"));

                foreach (var item in this.TimeSeries_)
                {
                    dao.INDEX_DATE_  = QueryStr.wrapComma(item.Key);
                    dao.INDEX_VALUE_ = QueryStr.wrapComma(item.Value);

                    dao.insert(DataBaseConnectManager.ConnectionFactory("myDB"));
                }
            }
            catch (SqlCeException)
            {
                OutputLogViewModel.addResult("DataBase Connection Error : DB Load");
                throw;
            }
        }
예제 #3
0
        public int deleteDefinedIndex(string nameStr)
        {
            SqlCeConnection connection = new SqlCeConnection(this.connectionStr_);

            try
            {
                DataTable tb = new DataTable();

                connection.Open();

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

                string name = QueryStr.wrapComma(nameStr);

                delCommand.CommandText = "DELETE FROM INDEX_TICKER_INFO WHERE NAME=" + name;

                delCommand.ExecuteNonQuery();

                delCommand.CommandText = "DELETE FROM INDEXDATA WHERE NAME=" + name;

                delCommand.ExecuteNonQuery();

                connection.Close();

                return(0);
            }
            catch (SqlCeException e)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : DB Load" + e.Errors);
                return(1);
            }
        }
예제 #4
0
        public IndexTickerInfo loadDefinedIndex(string nameStr)
        {
            SqlCeConnection connection = new SqlCeConnection(this.connectionStr_);

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

                string wrapName = QueryStr.wrapComma(nameStr);

                command.CommandText = "SELECT * FROM INDEX_TICKER_INFO WHERE NAME=" + wrapName;

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

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

                IndexTickerInfo loadITI = new IndexTickerInfo();

                foreach (DataRow row in tb.Rows)
                {
                    string name             = row["NAME"].ToString();
                    string krcode           = row["KRCODE"].ToString();
                    string yahoo_ticker     = row["YAHOO_TICKER"].ToString();
                    string bloomberg_ticker = row["BLOOMBERG_TICKER"].ToString();
                    string kap_ticker       = row["KAP_TICKER"].ToString();
                    string kis_ticker       = row["KIS_TICKER"].ToString();
                    string datasource       = row["DATASOURCE"].ToString();
                    string time_download    = row["TIME_DOWNLOAD"].ToString();
                    string index_type       = row["INDEX_TYPE"].ToString();

                    loadITI = new IndexTickerInfo(name, krcode, yahoo_ticker,
                                                  bloomberg_ticker,
                                                  kap_ticker,
                                                  kis_ticker,
                                                  datasource,
                                                  time_download,
                                                  index_type
                                                  );
                }

                connection.Close();

                return(loadITI);
            }
            catch (SqlCeException)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : DB Load");
                throw;
            }
        }
예제 #5
0
        public int updateDefinedIndex(IndexTickerInfo iti)
        {
            SqlCeConnection connection = new SqlCeConnection(this.connectionStr_);

            try
            {
                DataTable tb = new DataTable();

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

                //delCommand.CommandText = "DELETE FROM CORRELATION WHERE DATE ='" + ReferenceDate_.ToString("yyyy-MM-dd") + "'";
                //delCommand.ExecuteNonQuery();

                string name             = QueryStr.wrapComma(iti.Name_);
                string krcode           = QueryStr.wrapComma(iti.KrCode_);
                string yahoo_ticker     = QueryStr.wrapComma(iti.Yahoo_ticker_);
                string bloomberg_ticker = QueryStr.wrapComma(iti.Bloomberg_ticker_);
                string kap_ticker       = QueryStr.wrapComma(iti.Kap_ticker_);
                string kis_ticker       = QueryStr.wrapComma(iti.Kis_ticker_);
                string datasource       = QueryStr.wrapComma(iti.Datasource_);
                string time_download    = QueryStr.wrapComma(iti.Time_download_);
                string index_type       = QueryStr.wrapComma(iti.Index_type_);

                command.CommandText = "DELETE FROM INDEX_TICKER_INFO WHERE NAME=" + name;

                command.ExecuteNonQuery();

                command.CommandText = "INSERT INTO INDEX_TICKER_INFO (NAME,KRCODE,YAHOO_TICKER,BLOOMBERG_TICKER," +
                                      "KAP_TICKER,KIS_TICKER,DATASOURCE,TIME_DOWNLOAD,INDEX_TYPE) " +
                                      " VALUES (" + name + "," +
                                      krcode + "," +
                                      yahoo_ticker + "," +
                                      bloomberg_ticker + "," +
                                      kap_ticker + "," +
                                      kis_ticker + "," +
                                      datasource + "," +
                                      time_download + "," +
                                      index_type + ")";

                command.ExecuteNonQuery();

                connection.Close();

                return(0);
            }
            catch (SqlCeException)
            {
                connection.Close();
                OutputLogViewModel.addResult("DataBase Connection Error : DB Load");
                return(1);
            }
        }