public bool GetCanBeIgnored(string stockCode) { string connectionString = null; connectionString = ConfigurationManager.ConnectionStrings["MySqlConn"].ConnectionString; database.Connection = new MySqlConnection(connectionString); DbCommand command = database.Command; command.CommandType = CommandType.Text; command.CommandText = SqlBuilder.GetSelectCanBeIgnoredFlag(stockCode); bool canBeIgnored = false; try { command.Connection.Open(); reader = command.ExecuteReader(); canBeIgnored = DataLayerHelper.MapReaderToCanBeIgnored(reader); } catch (Exception e) { throw new Exception(e.Message); } finally { if (reader != null) { reader.Close(); } if ((command.Connection.State & ConnectionState.Open) != 0) { command.Connection.Close(); } } return(canBeIgnored); }
public List <Stock> GetAllMyStocksFromInventory(byte testNo = 0) { string connectionString = null; connectionString = ConfigurationManager.ConnectionStrings["MySqlConn"].ConnectionString; database.Connection = new MySqlConnection(connectionString); DbCommand command = database.Command; command.CommandType = CommandType.Text; command.CommandText = SqlBuilder.GetSelectMyStockInventory(); List <Stock> stocks = new List <Stock>(); try { command.Connection.Open(); reader = command.ExecuteReader(); stocks = DataLayerHelper.MapReaderToStocksInventory(reader); } catch (Exception e) { throw new Exception(e.Message); } finally { if (reader != null) { reader.Close(); } if ((command.Connection.State & ConnectionState.Open) != 0) { command.Connection.Close(); } } return(stocks); }
public List <Decimal> GetLastInsertedStocks(string stockCode, int take = 2, Boolean fromBackup = false) { string connectionString = null; if (fromBackup) { connectionString = ConfigurationManager.ConnectionStrings["BackupMySqlConn"].ConnectionString; } else { connectionString = ConfigurationManager.ConnectionStrings["MySqlConn"].ConnectionString; } database.Connection = new MySqlConnection(connectionString); DbCommand command = database.Command; command.CommandType = CommandType.Text; command.CommandText = SqlBuilder.GetLastInsertedStocks(stockCode, take); List <Decimal> rateCurrencyRates = new List <decimal>(); try { command.Connection.Open(); reader = command.ExecuteReader(); rateCurrencyRates = DataLayerHelper.MapReaderToRateCurrencyRate(reader); } catch (Exception e) { throw new Exception(e.Message); } finally { if ((command.Connection.State & ConnectionState.Open) != 0) { command.Connection.Close(); } } return(rateCurrencyRates); }