⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlstore.cs

📁 小说网(c#)版源程序,学习还是不错滴,大家可以下载下来看看.
💻 CS
📖 第 1 页 / 共 3 页
字号:
    /// <param name="sender">评论者</param>
    /// <param name="content">内容</param>
    /// <param name="ip">ip</param>
    public static void SqlComment(int topicid,string sender,string content,string ip)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_addcomment", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.Parameters.Add("@sender", SqlDbType.NVarChar, 20).Value = sender;
        comm.Parameters.Add("@content", SqlDbType.NVarChar, 2000).Value = content;
        comm.Parameters.Add("@ip", SqlDbType.NVarChar,15).Value = ip;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 我的书窝
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="deltopicid">删除小说ID</param>
    /// <param name="isupdate">是否只查看有更新小说</param>
    /// <returns></returns>
    public static DataTable SqlLike(string username,int deltopicid,bool isupdate)
    {
        DataTable table = new DataTable();
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_like_read", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@deltopicid", SqlDbType.Int).Value = deltopicid;
        comm.Parameters.Add("@isupdate", SqlDbType.Bit).Value = isupdate;
        SqlDataAdapter data = new SqlDataAdapter(comm);
        data.Fill(table);
        data.Dispose();
        SqlConn.Close();
        comm.Dispose();
        return table;
    }
    /// <summary>
    /// 返回小说章节信息
    /// </summary>
    /// <param name="tablename">表名</param>
    /// <param name="topicid">小说ID</param>
    /// <returns></returns>
    public static DataTable SqlChapter(string tablename, int topicid)
    {
        DataTable table = new DataTable();
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_readchapter", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@tablename", SqlDbType.NVarChar, 30).Value = tablename;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        SqlDataAdapter data = new SqlDataAdapter(comm);
        data.Fill(table);
        data.Dispose();
        SqlConn.Close();
        comm.Dispose();
        return table;
    }
    /// <summary>
    /// 推荐小说
    /// </summary>
    /// <param name="topicid">小说id</param>
    public static void SqlCommendNovel(int topicid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_commend_novel", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 隐藏小说
    /// </summary>
    /// <param name="topicid">小说id</param>
    public static void SqlHidden(int topicid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_hidden", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 推荐小说
    /// </summary>
    /// <param name="topicid">小说id</param>
    public static void SqlCommend(int topicid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_commend_commend", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 删除推荐
    /// </summary>
    /// <param name="topicid">小说id</param>
    public static void SqlCommendDel(int topicid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_commend_del", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 删除评论
    /// </summary>
    /// <param name="topicid">评论id</param>
    public static void SqlCommentDel(int commentid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_comment_del", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@commentid", SqlDbType.Int).Value = commentid;
        comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
    }
    /// <summary>
    /// 添加书窝
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="topicid">小说ID</param>
    /// <returns> 值=101,超出100本;  值=111,该书已收藏;  值=1,添加成功</returns>
    public static int SqlLikeAdd(string username,int topicid)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_like_add", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@topicid", SqlDbType.Int).Value = topicid;
        comm.Parameters.Add("@mark", SqlDbType.Int).Direction = ParameterDirection.Output;
        comm.ExecuteNonQuery();
        int mark = (int)comm.Parameters["@mark"].Value;
        comm.Dispose();
        SqlConn.Close();
        return mark;
    }
    /// <summary>
    /// 判断书窝是否有更新
    /// </summary>
    /// <param name="username">用户名</param>
    /// <returns></returns>
    public static bool SqlLikeUpdate(string username)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_like_update", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@isupdate",SqlDbType.Bit).Direction = ParameterDirection.Output;
        comm.ExecuteNonQuery();
        bool isupdate = (bool)comm.Parameters["@isupdate"].Value;
        comm.Dispose();
        SqlConn.Close();
        return isupdate;
    }
    /// <summary>
    /// 发送确认函
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="validate">验证码</param>
    /// <param name="mail">用户注册邮箱</param>
    /// <returns></returns>
    public static string SqlGetPass(string username, string validate)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_user_getpass", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@validate", SqlDbType.NVarChar, 50).Value = validate;
        comm.Parameters.Add("@mail", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output;
        comm.ExecuteNonQuery();
        string mail = (string)comm.Parameters["@mail"].Value;
        comm.Dispose();
        SqlConn.Close();
        return mail;
    }
    /// <summary>
    /// 忘记密码修改页初始时验证链接是否合法
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="validate">验证码</param>
    /// <returns></returns>
    public static bool SqlModifyConfirm(string username, string validate)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("nover_user_modify", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@validate", SqlDbType.NVarChar, 50).Value = validate;
        comm.Parameters.Add("@exist", SqlDbType.Bit).Direction = ParameterDirection.Output;
        comm.ExecuteNonQuery();
        bool exist = (bool)comm.Parameters["@exist"].Value;
        comm.Dispose();
        SqlConn.Close();
        return exist;
    }
    /// <summary>
    /// 忘记密码时修改密码
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="password">密码</param>
    /// <returns></returns>
    public static bool SqlModify(string username, string password)
    {
        SqlConnection SqlConn = new SqlConnection(connection);
        SqlConn.Open();
        SqlCommand comm = new SqlCommand("novel_user_modifypassword", SqlConn);
        comm.CommandType = System.Data.CommandType.StoredProcedure;
        comm.Parameters.Add("@username", SqlDbType.NVarChar, 20).Value = username;
        comm.Parameters.Add("@password", SqlDbType.NVarChar, 20).Value = password;
        int update = comm.ExecuteNonQuery();
        comm.Dispose();
        SqlConn.Close();
        return update == 1 ? true : false;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -