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

📄 lmmanage.cs

📁 具体功能质量高得到以后可以到我的博客去看看你能收获很多
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.OleDb;

//using LeaveMessageMVC.MVC.BusinessLogicLayer.ParameterInformation;
//using LeaveMessageMVC.MVC.DataBaseControlLayer;

/// <summary>
/// LMManage 的摘要说明
/// </summary>
/// 
namespace guihua.App_Code
{
    public static class LMManage
    {
        public static string Tables = "LM01";
        /// <summary>
        /// 向数据库 添加 一个新的留言记录
        /// </summary>
        /// <param name="nlm"></param>
        /// <returns>返回是否添加成功</returns>
        public static bool AddNewLeaveMessage(LeaveMessagePara nlm)
        {
            bool AddSuccess = true;

            string NewLMsql = "INSERT INTO " + Tables + " VALUES("      //SQL 插入语句
            + "'" + nlm.ID + "',"
                //+ "'" + nlm.User + "',"
                //+ "'" + nlm.QQMSN + "',"
            + "'" + nlm.Title + "',"
            + "'" + nlm.Contents + "',"
            + "'" + nlm.WriteBack + "',"                               //回复信息,对新留言是空的
            + "'" + nlm.SubmitTime + "',"
            + "'" + nlm.Comment + "');";

            if (DBControl.DBExcuteIUD(NewLMsql) <= 0)                   //执行向 DB 插入语句
            {
                AddSuccess = false;                                     //插入失败
            }

            return AddSuccess;
        }

        /// <summary>
        /// (1)更新留言信息——管理员更新信息
        /// </summary>
        /// <param name="wb"></param>
        /// <returns>返回是否更新成功</returns>
        public static bool UpdateLeaveMessageAll(LeaveMessagePara wb)
        {
            bool UpdateSuccess = true;

            string LMsql = "UPDATE " + Tables                            //SQL 更新语句
            + " SET Title = '" + wb.Title + "',"
            + " Contents = '" + wb.Contents + "',"
            + " WriteBack = '" + wb.WriteBack + "' "
            + " WHERE ID = '" + wb.ID + "';";

            if (DBControl.DBExcuteIUD(LMsql) <= 0)                      //执行向 DB 更新语句
                UpdateSuccess = false;                                  //更新失败

            return UpdateSuccess;
        }

        /// <summary>
        /// (2)更新留言信息——更新回复信息
        /// </summary>
        /// <param name="wb"></param>
        /// <returns>返回是否更新成功</returns>
        public static bool UpdateLeaveMessage(LeaveMessagePara wb)
        {
            bool UpdateSuccess = true;

            string LMsql = "UPDATE " + Tables                            //SQL 更新语句
            + " SET WriteBack = '" + wb.WriteBack + "' "
            + " WHERE ID = '" + wb.ID + "';";

            if (DBControl.DBExcuteIUD(LMsql) <= 0)                      //执行向 DB 更新语句
                UpdateSuccess = false;                                  //更新失败

            return UpdateSuccess;
        }

        public static bool DeleteLeaveMessage(params string[] lmid)
        {
            bool DeleteSuccess = true;

            string DeleteLMs = "create table #tempTable([ID] varchar(18));   ";
            for (int i = 0; i < lmid.Length; i++)
            {
                DeleteLMs += "insert into #tempTable values('" + lmid[i] + "');   ";
            }
            DeleteLMs += "delete from " + Tables + " where [ID] in (select * from #tempTable);  drop table #tempTable;";

            if (DBControl.DBExcuteIUD(DeleteLMs) <= 0)                      //执行向 DB 更新语句
                DeleteSuccess = false;

            return DeleteSuccess;
        }

        //--------------------------------------------------------------

        /// <summary>
        /// 获取(某表/具体页面)的所有留言记录信息 for SQL Server
        /// </summary>
        /// <param name="n">获取数据表前n行数据,0为获取全部</param>
        /// <returns></returns>
        public static DataSet GetLeaveMessage1(int n)
        {
            DataSet GetLMTable = new DataSet();

            string GetLM = "";
            if (n > 0)
                GetLM = "SELECT top " + n + " * FROM " + Tables + " ORDER BY SubmitTime DESC;";
            else
                GetLM = "SELECT * FROM " + Tables + " ORDER BY SubmitTime DESC;";

            GetLMTable = DBControl.DBSelect1(GetLM);
            return GetLMTable;
        }

        //--------------------------------------------------------------

        /// <summary>
        /// 获取(某表/具体页面)的所有留言记录信息 for SQL Server
        /// </summary>
        /// <param name="n">获取数据表前n行数据,0为获取全部</param>
        /// <returns></returns>
        public static SqlDataReader GetLeaveMessage(int n)
        {
            SqlDataReader GetLMTable = null;

            string GetLM = "";
            if (n > 0)
                GetLM = "SELECT top " + n + " * FROM " + Tables + " ORDER BY SubmitTime DESC;";
            else
                GetLM = "SELECT * FROM " + Tables + " ORDER BY SubmitTime DESC;";

            GetLMTable = DBControl.DBSelect(GetLM);
            return GetLMTable;
        }

        //--------------------------------------------------------------

        /// <summary>
        /// 从DB获取指定的留言记录信息 for SQL Server
        /// </summary>
        /// <returns></returns>
        public static SqlDataReader GetLM(string OwnerID)
        {
            SqlDataReader GetLMTable = null;
            string GetLM = "SELECT * FROM " + Tables + " WHERE ID = '" + OwnerID + "';";
            GetLMTable = DBControl.DBSelect(GetLM);
            return GetLMTable;
        }


        //public LMManage()
        //{
        //
        // TODO: 在此处添加构造函数逻辑
        //
        //}
    }
}

⌨️ 快捷键说明

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