Ejemplo n.º 1
0
        // Method to add to cart
        public void AddCart(int id, int quantity)
        {
            // Open the connection to database
            conn.OpenConnection();

            // SQL Query to insert into my cart table
            string query = $"INSERT INTO Cart (ProductId, Quantity) VALUES ({id}, {quantity})";

            conn.ExecuteQueries(query);

            // Close the connection to database
            conn.CloseConnection();
        }
Ejemplo n.º 2
0
        public static string[] GloLeaderBoard()
        {
            SQLConnection connection = new SQLConnection();

            connection.ExecuteCommand("SELECT users.dcuserid,users.sbuserid,curxp,curlvl,prestige FROM leveluser INNER JOIN users ON users.sbuserid = leveluser.sbuserid ORDER BY prestige DESC, curlvl DESC, curxp DESC LIMIT 3");
            Console.WriteLine(connection.Reader.HasRows);
            List <string> list = new List <string>();
            int           cur  = 0;

            if (connection.Reader.HasRows)
            {
                while (connection.Reader.Read())
                {
                    cur++;
                    list.Add(connection.Reader.GetUInt64("dcuserid").ToString());
                    list.Add(connection.Reader.GetInt32("curlvl").ToString());
                    list.Add(connection.Reader.GetInt32("prestige").ToString());
                }
            }
            Console.WriteLine(cur);
            Console.WriteLine(list.Count);
            connection.CloseConnection();
            connection.Dispose();
            return(list.ToArray());
        }
Ejemplo n.º 3
0
        public async Task AddCommand(string name, [Remainder] string outputtext)
        {
            try
            {
                List <string> Commands = new List <string>();
                SQLConnection con      = new SQLConnection();
                con.ExecuteCommand($"SELECT guildid,name FROM customcommands WHERE guildid = {Context.Guild.Id}");

                if (con.Reader.HasRows)
                {
                    while (con.Reader.Read())
                    {
                        string Name = con.Reader.GetString("name");
                        Commands.Add(Name);
                    }
                }

                if (!Commands.Contains(name))
                {
                    con.ExecuteCommand($"INSERT INTO customcommands (commandid, guildid, name, output) VALUES (NULL, {Context.Guild.Id}, '{name}', '{outputtext}')");
                    await ReplyAsync($"{name} has been added");
                }
                else
                {
                    await ReplyAsync("That command already exists");
                }
                con.CloseConnection();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 4
0
        // Method to Add Product
        public void AddProduct(string name, decimal cost)
        {
            // open the connection to database
            conn.OpenConnection();

            // Query the table by inserting into it
            string query = $"INSERT INTO Product (ProductName, CostPrice) VALUES ('{name}', {cost})";

            conn.ExecuteQueries(query);

            // Close the connection to database
            conn.CloseConnection();
        }
Ejemplo n.º 5
0
        private int checkUserLogin(string username, string password)
        {
            int           i      = 0;
            SQLConnection cmd    = new SQLConnection();
            SqlDataReader reader = cmd.GetReader("SELECT username, password FROM TTools.dbo.Users WHERE username = @0 AND password = @1", username, password);

            if (reader.HasRows)
            {
                i += 1;
            }

            reader.Close();
            cmd.CloseConnection();

            return(i);
        }
Ejemplo n.º 6
0
        private void insertNewUser(string username, string password, string email)
        {
            try
            {
                SQLConnection  cmd    = new SQLConnection();
                SqlDataAdapter reader = cmd.CreateSet("INSERT INTO Users (username, accountTypeId, password, email) VALUES (@0, @1, @2, @3)", username, "2", password, email);
                cmd.CloseConnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an issue, please try again later");
                Reporting.SQLReporting("Error", $"Testing the reporting system {ex}");
            }

            MessageBox.Show("Successfully Signed up");
        }
Ejemplo n.º 7
0
        public async Task BotData()
        {
            EmbedBuilder builder = new EmbedBuilder
            {
                Title = "Bot Statistics"
            };

            SQLConnection Connection = new SQLConnection();

            Connection.ExecuteCommand("");

            builder.AddField("total info", "");

            await ReplyAsync("", false);

            Connection.CloseConnection();
        }
Ejemplo n.º 8
0
        public static void SQLReporting(string errorType, string errorMsg)
        {
            //  Will need to have tables setup on the server
            // Showing any errors that might have occured when testing

            // DateTime d = DateTime.Now;

            try
            {
                SQLConnection  cmd    = new SQLConnection();
                SqlDataAdapter reader = cmd.CreateLoggingSet("errReporting", "INSERT INTO ErrorLogging (username, errorType, errorMsg) VALUES (@0, @1, @2)", "divideddarko", errorType, errorMsg);
                cmd.CloseConnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"error : {ex}");
            }
        }
Ejemplo n.º 9
0
        public static Dictionary <string, string> GetCustomCommands(ulong guildid)
        {
            Dictionary <string, string> Commands = new Dictionary <string, string>();
            SQLConnection connection             = new SQLConnection();

            connection.ExecuteCommand($"SELECT name,output FROM customcommands WHERE guildid = {guildid}");

            if (connection.Reader.HasRows)
            {
                while (connection.Reader.Read())
                {
                    string name   = connection.Reader.GetString("name");
                    string output = connection.Reader.GetString("output");
                    Commands.Add(name, output);
                }
            }

            connection.CloseConnection();

            return(Commands);
        }
Ejemplo n.º 10
0
        private int checkUserName(string email)
        {
            int i = 0;
            // Check to see if the username already exists.
            SQLConnection cmd    = new SQLConnection();
            SqlDataReader reader = cmd.GetReader("SELECT * FROM Users WHERE email = @0", email);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    i += 1;
                }
                emailRegResults.Content = "This email is already in use";
            }

            reader.Close();
            cmd.CloseConnection();

            return(i);
        }