Example #1
0
        public void userUpdateBuy(string email, float price, string howMuch, string currency)
        {
            string      query = "UPDATE `users` SET `PLN`=`PLN`-" + (int)price + ",`" + currency + "`=`" + currency + "`+" + howMuch + " WHERE `email` = '" + email + "';";
            ConnectToDb go    = new ConnectToDb();

            go.connectToDb();

            MySqlCommand cmd1 = new MySqlCommand(query, connector);

            connector.Open();
            cmd1.ExecuteNonQuery();
            go.closeConnectToDb();
            connector.Close();

            string      query1 = "UPDATE `cantorstock` SET `" + currency + "`=`" + currency + "`-" + howMuch + " where `id` = 1;";
            ConnectToDb go1    = new ConnectToDb();

            go1.connectToDb();

            MySqlCommand cmd = new MySqlCommand(query1, connector);

            connector.Open();
            cmd.ExecuteNonQuery();
            go1.closeConnectToDb();
        }
Example #2
0
        public void addUser(string data)
        {
            String insert = "INSERT INTO Users(firstName, lastName, nick, email, password,USD,EUR,CHF,RUB,CZK,GBP,PLN) VALUES(" + data + ")";

            ConnectToDb go = new ConnectToDb();

            go.connectToDb();

            MySqlCommand cmd = new MySqlCommand(insert, connector);

            cmd.ExecuteNonQuery();
            go.closeConnectToDb();
        }
Example #3
0
        public void addcurriences(String query)
        {
            String insert = "INSERT INTO cantorcurrencies(date, USD_PURCASE, USD_SELL, EUR_PURCASE, EUR_SELL, CHF_PURCASE, CHF_SELL, RUB_PURCASE, RUB_SELL, CZK_PURCASE, CZK_SELL, GBP_PURCASE, GBP_SELL) VALUES(" + query + ")";

            ConnectToDb go = new ConnectToDb();

            go.connectToDb();

            MySqlCommand cmd = new MySqlCommand(insert, connector);

            cmd.ExecuteNonQuery();
            go.closeConnectToDb();
        }
Example #4
0
 public void mysqlConnector()
 {
     Models.DataBase.ConnectToDb connect = new DataBase.ConnectToDb();
     this.connector = connect;
 }
Example #5
0
        public void checkTable()
        {
            string queryTable = string.Format(@"CREATE TABLE `{0}` (
                                `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
                                `firstName` text  DEFAULT '',
                                `lastName` text  DEFAULT '',
                                `nick` text NOT NULL,
                                `email` text ,
                                `password` text NOT NULL,
                                `USD` text NOT NULL DEFAULT '',
                                `EUR` text NOT NULL DEFAULT '',
                                `CHF` text NOT NULL,
                                `RUB` text NOT NULL,
                                `CZK` text NOT NULL,
                                `GBP` text NOT NULL,
                                `PLN` text NOT NULL,                              
                                PRIMARY KEY (`id`))
                                ENGINE = MyISAM AUTO_INCREMENT = 1 ;", "Users");

            string queryTable1 = string.Format(@"CREATE TABLE `{0}` (
                                `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
                                `date` text DEFAULT '',
                                `USD_PURCASE` text DEFAULT '',
                                `USD_SELL` text DEFAULT '',
                                `EUR_PURCASE` text DEFAULT '',
                                `EUR_SELL` text DEFAULT '',
                                `CHF_PURCASE` text DEFAULT '',
                                `CHF_SELL` text DEFAULT '',
                                `RUB_PURCASE` text DEFAULT '',
                                `RUB_SELL` text DEFAULT '',
                                `CZK_PURCASE` text DEFAULT '',
                                `CZK_SELL` text DEFAULT '',
                                `GBP_PURCASE` text DEFAULT '',
                                `GBP_SELL` text DEFAULT '',
                                PRIMARY KEY (`id`))
                                ENGINE = MyISAM AUTO_INCREMENT = 1 ;", "cantorcurrencies");

            string queryTable2 = string.Format(@"CREATE TABLE `{0}` (
                                `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
                                `USD` INT DEFAULT '20000',
                                `EUR` INT DEFAULT '20000',
                                `CHF` INT DEFAULT '20000',
                                `RUB` INT DEFAULT '20000',
                                `CZK` INT DEFAULT '20000',
                                `GBP` INT DEFAULT '20000',                     
                                PRIMARY KEY (`id`))
                                ENGINE = MyISAM AUTO_INCREMENT = 1 ;", "cantorstock");

            ConnectToDb go = new ConnectToDb();

            go.connectToDb();
            MySqlCommand createTable = new MySqlCommand(queryTable, connector);

            try
            {
                createTable.ExecuteNonQuery();
            }catch (MySqlException err)
            {
                Console.WriteLine("this table exist");
            }

            MySqlCommand createTable1 = new MySqlCommand(queryTable1, connector);

            try
            {
                createTable1.ExecuteNonQuery();
            }
            catch (MySqlException err)
            {
                Console.WriteLine("this table exist");
            }

            MySqlCommand createTable2 = new MySqlCommand(queryTable2, connector);

            try
            {
                createTable2.ExecuteNonQuery();

                String insert = "INSERT INTO cantorstock(USD,EUR,CHF,RUB,CZK,GBP) VALUES('20000','20000','20000','20000','20000','20000')";

                MySqlCommand cmd = new MySqlCommand(insert, connector);
                cmd.ExecuteNonQuery();
                go.closeConnectToDb();
            }
            catch (MySqlException err)
            {
                Console.WriteLine("this table exist");
            }


            go.closeConnectToDb();
        }