Esempio n. 1
0
        public bool CheckDuplicateMapping(clsBrokerInstrumentMapping model)
        {
            // We use these three SQLite objects:
            SQLiteConnection sqlite_conn;
            SQLiteCommand    sqlite_cmd;
            SQLiteDataReader sqlite_datareader;

            // create a new database connection:

            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
            // open the connection:
            sqlite_conn.Open();
            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // First lets build a SQL-Query again:
            sqlite_cmd.CommandText = $"SELECT Id FROM tblBrokerInstrumentMapping where BrokerId={model.BrokerId} and InstrumentId={model.InstrumentId}";
            // Now the SQLiteCommand object can give us a DataReader-Object:
            sqlite_datareader = sqlite_cmd.ExecuteReader();
            // The SQLiteDataReader allows us to run through the result lines:
            while (sqlite_datareader.Read()) // Read() returns false if there is still a result line to read
            {
                DisposeConnection(sqlite_conn, sqlite_cmd, sqlite_datareader);
                return(false);
            }

            // We are ready, now lets cleanup and close our connection:
            DisposeConnection(sqlite_conn, sqlite_cmd, sqlite_datareader);
            return(true);
        }
Esempio n. 2
0
        public void UpdateMapping(clsBrokerInstrumentMapping model, bool duplicate)
        {
            // We use these three SQLite objects:

            SQLiteConnection sqlite_conn;
            SQLiteCommand    sqlite_cmd;

            // create a new database connection:

            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
            // open the connection:
            sqlite_conn.Open();
            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // Lets insert something into our new table:
            if (duplicate)
            {
                sqlite_cmd.CommandText = $"Update tblBrokerInstrumentMapping set BrokerInstrumentCode='{model.BrokerInstrumentCode}',FeedPrices='{model.FeedPrices}',FeedTrades='{model.FeedTrades}' where Id={model.Id};";
            }
            else
            {
                sqlite_cmd.CommandText = $"Update tblBrokerInstrumentMapping set BrokerId={model.BrokerId},InstrumentId={model.InstrumentId},BrokerInstrumentCode='{model.BrokerInstrumentCode}',FeedPrices='{model.FeedPrices}',FeedTrades='{model.FeedTrades}' where Id={model.Id};";
            }

            // And execute this again ;D
            sqlite_cmd.ExecuteNonQuery();
            // We are ready, now lets cleanup and close our connection:
            sqlite_conn.Close();
            sqlite_conn.Dispose();
            sqlite_cmd.Dispose();
        }
Esempio n. 3
0
 public frmBrokerInstrumentMapping(MDIParentForm parent)
 {
     InitializeComponent();
     instrumentMapping       = new BrokerInstrumentMapping();
     brokerInstrumentMapping = new clsBrokerInstrumentMapping();
     brokerUpdateMapping     = new clsBrokerInstrumentMapping();
     this.parent             = parent;
 }
Esempio n. 4
0
        public void AddBrokerInstrumentMapping(clsBrokerInstrumentMapping model)
        {
            // We use these three SQLite objects:

            SQLiteConnection sqlite_conn;
            SQLiteCommand    sqlite_cmd;

            // create a new database connection:

            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
            // open the connection:
            sqlite_conn.Open();
            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // Lets insert something into our new table:
            sqlite_cmd.CommandText = $"INSERT INTO tblBrokerInstrumentMapping (BrokerId,InstrumentId,BrokerInstrumentCode,FeedPrices,FeedTrades) VALUES ({model.BrokerId},{model.InstrumentId},'{model.BrokerInstrumentCode}','{model.FeedPrices}','{model.FeedTrades}');";
            // And execute this again ;D
            sqlite_cmd.ExecuteNonQuery();
            // We are ready, now lets cleanup and close our connection:
            sqlite_conn.Close();
            sqlite_conn.Dispose();
            sqlite_cmd.Dispose();
        }