Exemple #1
0
        /// <summary>
        /// 查看单个
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public Job Get_SingJob(int nID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList = { sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID) };
            SqlDataReader       rec       = null;

            try
            {
                sqlHelper.RunProc("Get_SingJob", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Job job = new Job();

            while (rec.Read())
            {
                job.ID         = Int32.Parse(rec["ID"].ToString());
                job.Title      = rec["Title"].ToString();
                job.Content    = rec["Content"].ToString();
                job.Updatatime = DateTime.Parse(rec["Updatatime"].ToString());
                job.Click      = Int32.Parse(rec["Click"].ToString());
            }
            return(job);
        }
Exemple #2
0
        /// <summary>
        /// 查看全部
        /// </summary>
        /// <returns></returns>
        public List <Admin> Get_Admin()
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlDataReader       rec       = null;

            try
            {
                sqlHelper.RunProc("Get_Admin", out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <Admin> List_Admin = new List <Admin>();

            while (rec.Read())
            {
                Admin admin = new Admin();
                admin.ID            = Int32.Parse(rec["ID"].ToString());
                admin.UserName      = rec["UserName"].ToString();
                admin.Password      = rec["Password"].ToString();
                admin.LastLoginIP   = rec["LastLoginIP"].ToString();
                admin.LastLoginTime = DateTime.Parse(rec["LastLoginTime"].ToString());
                List_Admin.Add(admin);
                admin = null;
            }
            return(List_Admin);
        }
Exemple #3
0
        /// <summary>
        /// 查看单个商品
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public Product Get_SingProduct(int nID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_SingProduct", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Product product = new Product();

            while (rec.Read())
            {
                ProductClass    productClass    = new ProductClass();
                ProductClassSQL productClassSQL = new ProductClassSQL();
                productClass         = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString()));
                product.productClass = productClass;
                product.ID           = Int32.Parse(rec["ID"].ToString());
                product.Pro_Name     = rec["Pro_Name"].ToString();
                product.Pic          = rec["Pic"].ToString();
                product.Content      = rec["Content"].ToString();
                product.Updatatime   = DateTime.Parse(rec["Updatatime"].ToString());
                product.Click        = Int32.Parse(rec["Click"].ToString());
            }
            return(product);
        }
Exemple #4
0
        /// <summary>
        /// 查看全部
        /// </summary>
        /// <param name="nstartIndex"></param>
        /// <param name="endIndex"></param>
        /// <returns></returns>
        public List <Job> Get_Job(int nstartIndex, int nendIndex)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@startIndex", SqlDbType.Int, 4, nstartIndex),
                sqlHelper.CreateInParam("@endIndex",   SqlDbType.Int, 4, nendIndex),
                sqlHelper.CreateInParam("@docount",    SqlDbType.Bit, 1, 0)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_Job", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <Job> List_Job = new List <Job>();

            while (rec.Read())
            {
                Job job = new Job();
                job.ID         = Int32.Parse(rec["ID"].ToString());
                job.Title      = rec["Title"].ToString();
                job.Content    = rec["Content"].ToString();
                job.Updatatime = DateTime.Parse(rec["Updatatime"].ToString());
                job.Click      = Int32.Parse(rec["Click"].ToString());
                List_Job.Add(job);
                job = null;
            }
            return(List_Job);
        }
Exemple #5
0
        public SqlDataReader GetSingleUser(int nUserID)
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///定义保存从数据库获取的结果的DataReader
            SqlDataReader dr = null;

            ///创建访问数据库的参数
            SqlParameter[] paramList =
            {
                sqlHelper.CreateInParam("@UserID", SqlDbType.Int, 4, nUserID)
            };

            try
            {
                ///执行存储过程
                sqlHelper.RunProc("Pr_GetSingleUser", paramList, out dr);
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }

            ///返回从数据库获取的结果
            return(dr);
        }
Exemple #6
0
        public SqlDataReader GetUserLogin(string sUserName, string sPassword)
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///定义保存从数据库获取的结果的DataReader
            SqlDataReader dr = null;

            ///创建访问数据库的参数
            SqlParameter[] paramList =
            {
                sqlHelper.CreateInParam("@UserName", SqlDbType.VarChar, 200, sUserName),
                sqlHelper.CreateInParam("@Password", SqlDbType.VarChar, 255, sPassword)
            };

            try
            {
                ///执行存储过程
                sqlHelper.RunProc("Pr_GetUserLogin", paramList, out dr);
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }

            ///返回从数据库获取的结果
            return(dr);
        }
        /// <summary>
        /// 查看分类
        /// </summary>
        /// <param name="nParentID"></param>
        /// <returns></returns>
        public List <ProductClass> Get_ProductClass(int nParentID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ParentID", SqlDbType.Int, 4, nParentID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ProductClass", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <ProductClass> List_ProductClass = new List <ProductClass>();

            while (rec.Read())
            {
                Model.ProductClass productClass = new ProductClass();
                productClass.ClassID     = Int32.Parse(rec["ClassID"].ToString());
                productClass.ClassName   = rec["ClassName"].ToString();
                productClass.ParentID    = Int32.Parse(rec["ParentID"].ToString());
                productClass.ParentOrder = Int32.Parse(rec["ParentOrder"].ToString());
                List_ProductClass.Add(productClass);
                productClass = null;
            }
            return(List_ProductClass);
        }
Exemple #8
0
        /// <summary>
        /// 用户是否存在
        /// </summary>
        /// <param name="sUserName"></param>
        /// <returns></returns>
        public bool Login_Admin(string sUserName)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList = { sqlHelper.CreateInParam("@UserName", SqlDbType.NVarChar, 50, sUserName) };
            SqlDataReader       rec       = null;

            try
            {
                sqlHelper.RunProc("Login_Admin", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            bool Bool = false;

            while (rec.Read())
            {
                if (sUserName == rec["UserName"].ToString())
                {
                    Bool = true;
                }
            }
            return(Bool);
        }
Exemple #9
0
        /// <summary>
        /// 查看单个
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public Admin Get_SingAdmin(string sUserName)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList = { sqlHelper.CreateInParam("@UserName", SqlDbType.NVarChar, 50, sUserName) };
            SqlDataReader       rec       = null;

            try
            {
                sqlHelper.RunProc("Get_SingAdmin", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Admin admin = new Admin();

            while (rec.Read())
            {
                admin.ID            = Int32.Parse(rec["ID"].ToString());
                admin.UserName      = rec["UserName"].ToString();
                admin.Password      = rec["Password"].ToString();
                admin.LastLoginIP   = rec["LastLoginIP"].ToString();
                admin.LastLoginTime = DateTime.Parse(rec["LastLoginTime"].ToString());
            }
            return(admin);
        }
Exemple #10
0
        /// <summary>
        /// 查看单个
        /// </summary>
        /// <param name="nClassid"></param>
        /// <returns></returns>
        public NewClass Get_SintNewClass(int nClassid)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@Classid", SqlDbType.Int, 4, nClassid)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_SintNewClass", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            NewClass newClass = new NewClass();

            while (rec.Read())
            {
                newClass.ClassID     = Int32.Parse(rec["ClassID"].ToString());
                newClass.ClassName   = rec["ClassName"].ToString();
                newClass.ParentID    = Int32.Parse(rec["ParentID"].ToString());
                newClass.ParentOrder = Int32.Parse(rec["ParentOrder"].ToString());
            }
            return(newClass);
        }
Exemple #11
0
        public int AddUser(string sUserName, string sPassword, string sEmail, int nRoleID)
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///创建访问数据库的参数
            SqlParameter[] paramList =
            {
                sqlHelper.CreateInParam("@UserName", SqlDbType.VarChar, 200, sUserName),
                sqlHelper.CreateInParam("@Password", SqlDbType.VarChar, 255, sPassword),
                sqlHelper.CreateInParam("@Email",    SqlDbType.VarChar, 200, sEmail),
                sqlHelper.CreateInParam("@RoleID",   SqlDbType.Int,       4, nRoleID)
            };

            try
            {
                ///执行存储过程
                return(sqlHelper.RunProc("Pr_AddUser", paramList));
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
        }
Exemple #12
0
        /// <summary>
        /// 按分类查看总数
        /// </summary>
        /// <param name="nClassID"></param>
        /// <returns></returns>
        public int Get_NewsNum(int nClassID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@startIndex", SqlDbType.Int, 4,        1),
                sqlHelper.CreateInParam("@endIndex",   SqlDbType.Int, 4,        1),
                sqlHelper.CreateInParam("@Classid",    SqlDbType.Int, 4, nClassID),
                sqlHelper.CreateInParam("@docount",    SqlDbType.Bit, 1, 1)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ClassNews", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            int Num = 0;

            while (rec.Read())
            {
                Num = Int32.Parse(rec["Counts"].ToString());
            }
            return(Num);
        }
Exemple #13
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="nID"></param>
 public void Delete_Admin(int nID)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList = { sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID) };
     try
     {
         sqlHelper.RunProc("Delete_Admin", ParamList);
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
 /// <summary>
 /// 添加产品分类
 /// </summary>
 /// <param name="productClass"></param>
 /// <returns></returns>
 public int Add_ProductClass(ProductClass productClass)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@ParentID",  SqlDbType.Int,       4, productClass.ParentID),
         sqlHelper.CreateInParam("@ClassName", SqlDbType.NVarChar, 50, productClass.ClassName)
     };
     try
     {
         return(sqlHelper.RunProc("Add_ProductClass", ParamList));
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #15
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="config"></param>
 public void Update_Config(Config config)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@About",   SqlDbType.NText, 0, config.About),
         sqlHelper.CreateInParam("@Contact", SqlDbType.NText, 0, config.Contact)
     };
     try
     {
         sqlHelper.RunProc("Update_Config", ParamList);
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #16
0
        /// <summary>
        /// 按分类查看
        /// </summary>
        /// <param name="nstartIndex"></param>
        /// <param name="nendIndex"></param>
        /// <param name="nClassID"></param>
        /// <returns></returns>
        public List <News> Get_News(int nstartIndex, int nendIndex, int nClassID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@startIndex", SqlDbType.Int, 4, nstartIndex),
                sqlHelper.CreateInParam("@endIndex",   SqlDbType.Int, 4, nendIndex),
                sqlHelper.CreateInParam("@Classid",    SqlDbType.Int, 4, nClassID),
                sqlHelper.CreateInParam("@docount",    SqlDbType.Bit, 1, 0)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ClassNews", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <News> List_News = new List <News>();

            while (rec.Read())
            {
                News        news        = new News();
                NewClass    newClass    = new NewClass();
                NewClassSQL newClassSQl = new NewClassSQL();
                newClass        = newClassSQl.Get_SintNewClass(Int32.Parse(rec["ClassID"].ToString()));
                news.NewClass   = newClass;
                news.ID         = Int32.Parse(rec["ID"].ToString());
                news.Title      = rec["Title"].ToString();
                news.Source     = rec["Source"].ToString();
                news.Author     = rec["Author"].ToString();
                news.Content    = rec["Content"].ToString();
                news.Updatatime = DateTime.Parse(rec["Updatatime"].ToString());
                news.Click      = Int32.Parse(rec["Click"].ToString());
                List_News.Add(news);
                news     = null;
                newClass = null;
            }
            return(List_News);
        }
Exemple #17
0
 /// <summary>
 /// 修改新闻分类
 /// </summary>
 /// <param name="newClass"></param>
 public void Update_NewClass(NewClass newClass)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@Classid",   SqlDbType.Int,       4, newClass.ClassID),
         sqlHelper.CreateInParam("@ParentID",  SqlDbType.Int,       4, newClass.ParentID),
         sqlHelper.CreateInParam("@ClassName", SqlDbType.NVarChar, 50, newClass.ClassName)
     };
     try
     {
         sqlHelper.RunProc("Update_NewClass", ParamList);
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #18
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="job"></param>
 /// <returns></returns>
 public int Add_Job(Job job)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@Title",   SqlDbType.NVarChar, 50, job.Title),
         sqlHelper.CreateInParam("@Content", SqlDbType.NText,     0, job.Content),
         sqlHelper.CreateInParam("@Click",   SqlDbType.Int,       4, job.Click)
     };
     try
     {
         return(sqlHelper.RunProc("Add_Job", ParamList));
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #19
0
    public static SqlDataReader GetReaders(string sql)
    {
        ///定义类SQLHelper
        SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

        ///定义保存从数据库获取的结果的DataReader
        SqlDataReader dr = null;

        try
        {
            sqlHelper.RunSQL(sql, out dr);
        }
        catch (Exception ex)
        {
            SystemError.CreateErrorLog(ex.Message);
            throw new Exception(ex.Message, ex);
        }
        return (dr);
    }
Exemple #20
0
        /// <summary>
        /// 按分类查看商品
        /// </summary>
        /// <param name="nstartIndex"></param>
        /// <param name="nendIndex"></param>
        /// <param name="nClassID"></param>
        /// <returns></returns>
        public List <Product> Get_Product(int nstartIndex, int nendIndex, int nClassID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@startIndex", SqlDbType.Int, 4, nstartIndex),
                sqlHelper.CreateInParam("@endIndex",   SqlDbType.Int, 4, nendIndex),
                sqlHelper.CreateInParam("@Classid",    SqlDbType.Int, 4, nClassID),
                sqlHelper.CreateInParam("@docount",    SqlDbType.Bit, 1, 0)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ClassProduct", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <Product> List_product = new List <Product>();

            while (rec.Read())
            {
                Product         product         = new Product();
                ProductClass    productClass    = new ProductClass();
                ProductClassSQL productClassSQL = new ProductClassSQL();
                productClass         = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString()));
                product.productClass = productClass;
                product.ID           = Int32.Parse(rec["ID"].ToString());
                product.Pro_Name     = rec["Pro_Name"].ToString();
                product.Pic          = rec["Pic"].ToString();
                product.Content      = rec["Content"].ToString();
                product.Updatatime   = DateTime.Parse(rec["Updatatime"].ToString());
                product.Click        = Int32.Parse(rec["Click"].ToString());
                List_product.Add(product);
                product      = null;
                productClass = null;
            }
            return(List_product);
        }
Exemple #21
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="admin"></param>
 /// <returns></returns>
 public int Add_Admin(Admin admin)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@UserName",      SqlDbType.NVarChar, 50, admin.UserName),
         sqlHelper.CreateInParam("@Password",      SqlDbType.NVarChar, 50, admin.Password),
         sqlHelper.CreateInParam("@LastLoginIP",   SqlDbType.NVarChar, 50, admin.LastLoginIP),
         sqlHelper.CreateInParam("@LastLoginTime", SqlDbType.DateTime,  8, admin.LastLoginTime)
     };
     try
     {
         return(sqlHelper.RunProc("Add_Admin", ParamList));
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #22
0
 /// <summary>
 /// 添加商品
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public int Add_Product(Product product)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@ClassID",    SqlDbType.Int,        4, product.productClass.ClassID),
         sqlHelper.CreateInParam("@Pro_Name",   SqlDbType.NVarChar,  50, product.Pro_Name),
         sqlHelper.CreateInParam("@Pic",        SqlDbType.NVarChar, 255, product.Pic),
         sqlHelper.CreateInParam("@Content",    SqlDbType.NText,      0, product.Content),
         sqlHelper.CreateInParam("@Updatatime", SqlDbType.DateTime,   8, product.Updatatime),
         sqlHelper.CreateInParam("@Click",      SqlDbType.Int,        4, product.Click)
     };
     try
     {
         return(sqlHelper.RunProc("Add_Product", ParamList));
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #23
0
        /// <summary>
        /// 查看
        /// </summary>
        /// <returns></returns>
        public Config Get_Config()
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlDataReader       rec       = null;

            try
            {
                sqlHelper.RunProc("Get_Config", out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Config config = new Config();

            while (rec.Read())
            {
                config.About   = rec["About"].ToString();
                config.Contact = rec["Contact"].ToString();
            }
            return(config);
        }
Exemple #24
0
        public void DeleteUser(int nUserID)
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///创建访问数据库的参数
            SqlParameter[] paramList =
            {
                sqlHelper.CreateInParam("@UserID", SqlDbType.Int, 4, nUserID)
            };

            try
            {
                ///执行存储过程
                sqlHelper.RunProc("Pr_DeleteUser", paramList);
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
        }
Exemple #25
0
        public SqlDataReader GetUsers()
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///定义保存从数据库获取的结果的DataReader
            SqlDataReader dr = null;

            try
            {
                ///执行存储过程
                sqlHelper.RunProc("Pr_GetUsers", out dr);
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }

            ///返回从数据库获取的结果
            return(dr);
        }
Exemple #26
0
 /// <summary>
 /// 添加新闻
 /// </summary>
 /// <param name="news"></param>
 /// <returns></returns>
 public int Add_News(News news)
 {
     SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
     SqlParameter[]      ParamList =
     {
         sqlHelper.CreateInParam("@ClassID",    SqlDbType.Int,       4, news.NewClass.ClassID),
         sqlHelper.CreateInParam("@Title",      SqlDbType.NVarChar, 50, news.Title),
         sqlHelper.CreateInParam("@Source",     SqlDbType.NVarChar, 50, news.Source),
         sqlHelper.CreateInParam("@Author",     SqlDbType.NVarChar, 50, news.Author),
         sqlHelper.CreateInParam("@Content",    SqlDbType.NText,     0, news.Content),
         sqlHelper.CreateInParam("@Updatatime", SqlDbType.DateTime,  8, news.Updatatime),
         sqlHelper.CreateInParam("@Click",      SqlDbType.Int,       4, news.Click)
     };
     try
     {
         return(sqlHelper.RunProc("Add_News", ParamList));
     }
     catch (Exception ex)
     {
         SystemError.CreateErrorLog(ex.Message);
         throw new Exception(ex.Message, ex);
     }
 }
Exemple #27
0
        public void UpdateUserPwd(int nUserID, string sPassword)
        {
            ///定义类SQLHelper
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();

            ///创建访问数据库的参数
            SqlParameter[] paramList =
            {
                sqlHelper.CreateInParam("@UserID",   SqlDbType.Int,       4, nUserID),
                sqlHelper.CreateInParam("@Password", SqlDbType.VarChar, 255, sPassword)
            };

            try
            {
                ///执行存储过程
                sqlHelper.RunProc("Pr_UpdateUserPwd", paramList);
            }
            catch (Exception ex)
            {
                ///抛出执行数据库异常
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
        }
Exemple #28
0
        /// <summary>
        /// 查看单条新闻
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public News Get_SintNews(int nID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_SintNews", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            News news = new News();

            while (rec.Read())
            {
                NewClass    newClass    = new NewClass();
                NewClassSQL newClassSQl = new NewClassSQL();
                newClass        = newClassSQl.Get_SintNewClass(Int32.Parse(rec["ClassID"].ToString()));
                news.NewClass   = newClass;
                news.ID         = Int32.Parse(rec["ID"].ToString());
                news.Title      = rec["Title"].ToString();
                news.Source     = rec["Source"].ToString();
                news.Author     = rec["Author"].ToString();
                news.Content    = rec["Content"].ToString();
                news.Updatatime = DateTime.Parse(rec["Updatatime"].ToString());
                news.Click      = Int32.Parse(rec["Click"].ToString());
            }
            return(news);
        }