Пример #1
0
        /// <summary>
        /// 更新管理员信息,由BLL层调用,成功返回true,失败返回fales;
        /// </summary>
        /// <param name="admin">要更新的管理员Admin实例</param>
        /// <returns>成功返回true,失败返回false</returns>
        public Boolean UpdateAdminInfo(Admin admin)
        {
            Boolean       result     = false;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                ADMIN destAdmin = (from usr in DataEntity.ADMIN
                                   where usr.admin_id == admin.User_id &&
                                   usr.admin_timestamp == admin.User_timestamp
                                   select usr).Single();
                //全套更新
                destAdmin.admin_id              = admin.User_id;
                destAdmin.admin_account         = admin.User_account;
                destAdmin.admin_password        = admin.User_password;
                destAdmin.admin_last_login_time = admin.User_last_login_date;
                destAdmin.admin_last_login_ip   = admin.User_last_login_ip;
                destAdmin.admin_nickname        = admin.User_nickname;

                DataEntity.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 更新课程信息,course为包含完整的要更新的课程信息的Course类实例
        /// </summary>
        /// <param name="course">包含完整要更新的课程信息的Course类实例</param>
        /// <returns></returns>
        public Boolean UpdateCourseInfo(Course course)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            Boolean       result     = false;

            try
            {
                COURSE toUpdateCourse = (from c in DataEntity.COURSE
                                         where
                                         c.course_id == course.Course_id
                                         &&
                                         c.course_timestamp == course.Course_timestamp
                                         select c
                                         ).Single();
                toUpdateCourse.course_intro      = course.Course_intro;
                toUpdateCourse.course_name       = course.Course_name;
                toUpdateCourse.course_price      = course.Course_price;
                toUpdateCourse.course_robot_link = course.Course_robot_link;
                toUpdateCourse.course_begin_date = course.Course_begin_date;
                toUpdateCourse.course_isDeleted  = course.Course_isDeleted;
                DataEntity.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 更新新闻信息,成功返回true,失败返回false
        /// </summary>
        /// <param name="news">要更新的news类</param>
        /// <returns>成功返回true,失败返回false</returns>
        public Boolean UpdateNewsInfo(News news)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            Boolean       result     = false;

            try
            {
                NEWS ResultNEWS = (from destNews in DataEntity.NEWS
                                   where destNews.news_id == news.Article_id &&
                                   destNews.news_timestamp == news.Article_timestamp
                                   select destNews).Single();

                ResultNEWS.news_title        = news.Article_title;
                ResultNEWS.news_id           = news.Article_id;
                ResultNEWS.news_content      = news.Article_content;
                ResultNEWS.news_isDeleted    = news.Article_isDeleted;
                ResultNEWS.news_isOnIndex    = news.News_isOnIndex;
                ResultNEWS.news_publish_date = news.Article_publish_date;
                ResultNEWS.news_timestamp    = news.Article_timestamp;
                ResultNEWS.news_author       = news.Article_author;
                ResultNEWS.news_click_count  = news.News_click_count;
                ResultNEWS.news_image        = news.News_image;

                DataEntity.SaveChanges();

                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 注册新用户,无数据验证,数据验证应该在BLL层完成
        /// </summary>
        /// <param name="user">需要新创建的UI.User类</param>
        /// <returns>影响的行数,大于0说明成功</returns>
        public int CreateUser(User user)
        {
            int           res;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            USER          NewUSER    = this.ConvertUserToUSER(user);

            DataEntity.USER.AddObject(NewUSER);
            res = DataEntity.SaveChanges();
            return(res);
        }
Пример #5
0
        /// <summary>
        /// 新增课程,数据完整性检查在BLL层做。成功返回true,失败返回false
        /// </summary>
        /// <param name="course">包含新增课程信息的Course类实例</param>
        /// <returns>成功返回true,失败返回false</returns>
        public Boolean CreateCourse(Course course)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            COURSE        newCOURSE  = ConvertCourseToCOURSE(course);
            Boolean       result     = false;

            try
            {
                DataEntity.COURSE.AddObject(newCOURSE);
                DataEntity.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #6
0
        /// <summary>
        /// 插入新闻,成功返回true,失败返回false
        /// </summary>
        /// <param name="news">要插入的新闻类</param>
        /// <returns>成功true,失败false</returns>
        public Boolean CreateNews(News news)
        {
            Boolean       result     = true;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                NEWS newNEWS = ConvertNewsToNEWS(news);
                DataEntity.NEWS.AddObject(newNEWS);
                DataEntity.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #7
0
        /// <summary>
        /// 根据给定的news_id将NEWS表中的对应新闻列isDeleted设为true
        /// </summary>
        /// <param name="news">填写了news_id的news类</param>
        /// <returns>成功返回true,失败返回false</returns>
        public Boolean DeleteNewsByID(News news)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            Boolean       result     = false;

            try
            {
                NEWS destNews = (from d_news in DataEntity.NEWS
                                 where d_news.news_id == news.Article_id
                                 select d_news).Single();
                destNews.news_isDeleted = true;
                DataEntity.SaveChanges();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Пример #8
0
        /// <summary>
        /// DAL层重设密码函数,成功返回true,否则返回false
        /// </summary>
        /// <param name="user">要改变密码的user,account必填,password必填,为重新生成的密码</param>
        /// <returns>成功返回true,否则false</returns>
        public Boolean GetForgetPassword(User user)
        {
            Boolean       result     = false;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                USER DestUser = (from usr in DataEntity.USER
                                 where usr.user_account == user.User_account //找目标user,LINQ里面字符串相等就是 ==!
                                 select usr).Single();
                DestUser.user_password = user.User_password;                 //更改密码为新生成的8位随机字符串
                DataEntity.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }

            return(result);
        }
Пример #9
0
        /// <summary>
        /// 更新用户信息,数据校验在BLL完成
        /// </summary>
        /// <param name="user">要更新的用户</param>
        /// <returns>成功true失败false</returns>
        public Boolean UpdateUserInfo(User user)
        {
            Boolean       result     = true;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try{
                USER newInfoUSER = (from usr in DataEntity.USER
                                    where usr.user_id == user.User_id &&      //账号
                                    usr.user_timestamp == user.User_timestamp //时间戳,注意,这个很重要!确保一致性!
                                    select usr
                                    ).Single();

                //            newInfoUSER = ConvertUserToUSER(user); 这是传指针,算了,老实点,一个个拷贝
                // newInfoUSER.u_id = user.U_id;  自动生成的不能改
                newInfoUSER.user_id              = user.User_id;
                newInfoUSER.user_head            = user.User_head;
                newInfoUSER.user_account         = user.User_account;
                newInfoUSER.user_introduction    = user.User_introduction;
                newInfoUSER.user_isChecked       = user.User_isChecked;
                newInfoUSER.user_isDeleted       = user.User_isDeleted;
                newInfoUSER.user_last_login_ip   = user.User_last_login_ip;
                newInfoUSER.user_last_login_time = user.User_last_login_date;
                newInfoUSER.user_money           = user.User_money;
                newInfoUSER.user_nickname        = user.User_nickname;
                newInfoUSER.user_password        = user.User_password;
                newInfoUSER.user_sex             = user.User_sex;
                //   newInfoUSER.user_timestamp = user.User_timestamp; 妈蛋时间戳不能改啊改了还同步个J8啊!
                newInfoUSER.user_verify_code = user.User_verify_code;

                DataEntity.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }
Пример #10
0
        /// <summary>
        /// 修改用户密码,User为登录的用户,newPassword为新密码,成功返回true否则返回false
        /// </summary>
        /// <param name="user">登录的用户</param>
        /// <param name="newPassword">新密码(MD5大写字符串)</param>
        /// <returns>成功true失败false</returns>
        public Boolean ChangeUserPassword(User user, String newPassword)
        {
            Boolean       result     = true;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                USER OldUSER = (from usr in DataEntity.USER
                                where usr.user_account == user.User_account && //账号
                                usr.user_password == user.User_password &&  //密码
                                usr.user_timestamp == user.User_timestamp      //时间戳,注意,这个很重要!确保一致性!
                                select usr
                                ).Single();
                OldUSER.user_password = newPassword;
                DataEntity.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }