Exemple #1
0
        //insert
        public static int addPost(string title, string writername, string content, string image, int platformid, int categoryid)
        {
            string sql = "INSERT INTO [dbo].[Post] ([title] , [writtername] , [content] , [image]  , [upvote] , " +
                         " [platformid] , [categoryid] , [datecreated] , [isApprove]) " +
                         " VALUES ( @title, @writername, @content, @image, 0, @platformid, @categoryid, GETDATE(), 0 )";
            SqlParameter p1 = new SqlParameter("@title", SqlDbType.VarChar);

            p1.Value = title;
            SqlParameter p2 = new SqlParameter("@writername", SqlDbType.VarChar);

            p2.Value = writername;
            SqlParameter p3 = new SqlParameter("@content", SqlDbType.VarChar);

            p3.Value = content;
            SqlParameter p4 = new SqlParameter("@image", SqlDbType.VarChar);

            p4.Value = image;
            SqlParameter p5 = new SqlParameter("@platformid", SqlDbType.Int);

            p5.Value = platformid;
            SqlParameter p6 = new SqlParameter("@categoryid", SqlDbType.Int);

            p6.Value = categoryid;

            return(DAO.ExecuteSQLWithParameters(sql, p1, p2, p3, p4, p5, p6));
        }
Exemple #2
0
        //update
        public static int approvePostbyID(int id)
        {
            string       sql = "UPDATE [dbo].[Post] SET [isApprove] = 1 WHERE [Post].postid = @id";
            SqlParameter p1  = new SqlParameter("@id", SqlDbType.Int);

            p1.Value = id;
            return(DAO.ExecuteSQLWithParameters(sql, p1));
        }
Exemple #3
0
        //insert
        public static int addNewCategory(string name)
        {
            string       sql = "INSERT INTO [dbo].Category (categoryname) VALUES (@name) ";
            SqlParameter p1  = new SqlParameter("@name", SqlDbType.VarChar);

            p1.Value = name;
            return(DAO.ExecuteSQLWithParameters(sql, p1));
        }
Exemple #4
0
        public static int deletePostByID(int id)
        {
            string       sql = "delete [Post] where [Post].postid = @id ";
            SqlParameter p1  = new SqlParameter("@id", SqlDbType.Int);

            p1.Value = id;
            return(DAO.ExecuteSQLWithParameters(sql, p1));
        }
Exemple #5
0
        //insert
        public static int addNewPlatform(string name)
        {
            string       sql = "INSERT INTO [dbo].[Platform] ([platformname]) VALUES (@name) ";
            SqlParameter p1  = new SqlParameter("@name", SqlDbType.VarChar);

            p1.Value = name;
            return(DAO.ExecuteSQLWithParameters(sql, p1));
        }
Exemple #6
0
        //delete acc
        public static int deleteAccByUsername(string username)
        {
            string       sql = " delete [Account] where Account.username = @name ";
            SqlParameter p1  = new SqlParameter("@name", SqlDbType.VarChar);

            p1.Value = username;
            return(DAO.ExecuteSQLWithParameters(sql, p1));
        }
Exemple #7
0
        public static int updatePasswordAccount(string username, string password)
        {
            string       sql = "update [Account] set [Account].password = @password where [Account].username = @username ";
            SqlParameter p1  = new SqlParameter("@password", SqlDbType.VarChar);

            p1.Value = password;
            SqlParameter p2 = new SqlParameter("@username", SqlDbType.VarChar);

            p2.Value = username;
            return(DAO.ExecuteSQLWithParameters(sql, p1, p2));
        }
Exemple #8
0
        public static int updateImageOfavaterAccount(string imagename, string username)
        {
            string       sql = "update [Account] set [Account].avatar = @image where [Account].username = @username ";
            SqlParameter p1  = new SqlParameter("@image", SqlDbType.VarChar);

            p1.Value = imagename;
            SqlParameter p2 = new SqlParameter("@username", SqlDbType.VarChar);

            p2.Value = username;
            return(DAO.ExecuteSQLWithParameters(sql, p1, p2));
        }
Exemple #9
0
        //update
        public static int activeWriter(string username, int bit)
        {
            string       sql = @"update [Account] set [Account].isWriter = @bit where [Account].username = @username ";
            SqlParameter p1  = new SqlParameter("@bit", SqlDbType.Int);

            p1.Value = bit;
            SqlParameter p2 = new SqlParameter("@username", SqlDbType.VarChar);

            p2.Value = username;

            return(DAO.ExecuteSQLWithParameters(sql, p1, p2));
        }
Exemple #10
0
        public static int updatePostByID(int id, string title, string content, string imagepath)
        {
            string sql = "UPDATE [dbo].[Post] SET [title] = @title ,[content] =  @content ," +
                         "[image] =  @image , [isApprove] = 0 WHERE [Post].postid = @id ";
            SqlParameter p1 = new SqlParameter("@title", SqlDbType.VarChar);

            p1.Value = title;
            SqlParameter p2 = new SqlParameter("@content", SqlDbType.VarChar);

            p2.Value = content;
            SqlParameter p3 = new SqlParameter("@image", SqlDbType.VarChar);

            p3.Value = imagepath;
            SqlParameter p4 = new SqlParameter("@id", SqlDbType.Int);

            p4.Value = id;

            return(DAO.ExecuteSQLWithParameters(sql, p1, p2, p3, p4));
        }