Esempio n. 1
0
        public static bool UpdateGiveaway(Giveaway g)
        {
            try
            {
                using (SQLiteConnection _conn = new SQLiteConnection(connectionString))
                {
                    using (SQLiteCommand cmd = new SQLiteCommand("UPDATE Giveaways SET Name = @p1,Reward = @p2,RewardString = @p3,Type = @p4,Hashtag = @p5,Repeat = @p6,Delay = @p7,StartMessage = @p8,WinnerMessage = @p9,WinnerWhisper = @p10,CodeWhisper = @p11,AnnounceStart = @p12,AutoPickCode = @p13 WHERE Id = @p15", _conn))
                    {
                        cmd.Connection.Open();
                        cmd.Parameters.AddWithValue("@p1", g.Name);
                        cmd.Parameters.AddWithValue("@p2", g.Reward);
                        cmd.Parameters.AddWithValue("@p3", g.RewardString);
                        cmd.Parameters.AddWithValue("@p4", g.Type);
                        cmd.Parameters.AddWithValue("@p5", g.Hashtag);
                        cmd.Parameters.AddWithValue("@p6", g.Repeat);
                        cmd.Parameters.AddWithValue("@p7", g.Delay);
                        cmd.Parameters.AddWithValue("@p8", g.StartMessage);
                        cmd.Parameters.AddWithValue("@p9", g.WinnerMessage);
                        cmd.Parameters.AddWithValue("@p10", g.WinnerWhisper);
                        cmd.Parameters.AddWithValue("@p11", g.CodeWhisper);
                        cmd.Parameters.AddWithValue("@p12", g.AnnounceStart);
                        cmd.Parameters.AddWithValue("@p13", g.AutoPickCode);
                        cmd.Parameters.AddWithValue("@p14", g.Id);

                        if (cmd.ExecuteNonQuery() != 0)
                        {
                            _conn.Close();
                            return(true);
                        }
                        else
                        {
                            _conn.Close();
                            return(false);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error updating giveaway: \n\n" + e.Message);
                return(false);
            }
        }
Esempio n. 2
0
        public static bool CreateGiveaway(Giveaway g)
        {
            try
            {
                using (SQLiteConnection _conn = new SQLiteConnection(connectionString))
                {
                    using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO Giveaways (Name,Reward,RewardString,Type,Hashtag,Repeat,Delay,StartMessage,WinnerMessage,WinnerWhisper,CodeWhisper,AnnounceStart,AutoPickCode) VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12,@p13)", _conn))
                    {
                        cmd.Connection.Open();
                        cmd.Parameters.AddWithValue("@p1", g.Name);
                        cmd.Parameters.AddWithValue("@p2", g.Reward);
                        cmd.Parameters.AddWithValue("@p3", g.RewardString);
                        cmd.Parameters.AddWithValue("@p4", g.Type);
                        cmd.Parameters.AddWithValue("@p5", g.Hashtag);
                        cmd.Parameters.AddWithValue("@p6", g.Repeat);
                        cmd.Parameters.AddWithValue("@p7", g.Delay);
                        cmd.Parameters.AddWithValue("@p8", g.StartMessage);
                        cmd.Parameters.AddWithValue("@p9", g.WinnerMessage);
                        cmd.Parameters.AddWithValue("@p10", g.WinnerWhisper);
                        cmd.Parameters.AddWithValue("@p11", g.CodeWhisper);
                        cmd.Parameters.AddWithValue("@p12", g.AnnounceStart);
                        cmd.Parameters.AddWithValue("@p13", g.AutoPickCode);

                        if (cmd.ExecuteNonQuery() != 0)
                        {
                            _conn.Close();
                            return(true);
                        }
                        else
                        {
                            _conn.Close();
                            return(false);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error creating giveaway: \n\n" + e.Message);
                return(false);
            }
        }