Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #5
0
        /// <summary>
        /// DAL层,根据用户账号密码返回相应信息
        /// </summary>
        /// <param name="user">要查询的UI.User类,账号密码必填</param>
        /// <returns>若存在返回对应的User类,保存了全部信息,否则返回null</returns>
        public User GetUserByAccountAndPassword(User user)
        {
            User          ResultUser = null;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            USER          LoginUser  = (from usr in DataEntity.USER
                                        where usr.user_account == user.User_account &&
                                        usr.user_password == user.User_password
                                        select usr)
                                       .Single();

            ResultUser = ConvertUSERToUser(LoginUser);
            return(ResultUser);
        }
Exemple #6
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);
        }
Exemple #7
0
        /// <summary>
        /// 在数据库中创建订单,调用的是数据库中的CreateNewOrder存储过程。这个函数有事务保护
        /// </summary>
        /// <param name="order">包含订单信息的完整order类</param>
        /// <returns>成功返回true,否则返回false</returns>
        public Boolean CreateOrder(Order order)
        {
            Boolean       result     = false;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                DataEntity.CreateNewOrder
                    (order.Order_price, order.Order_user, order.Order_course, BitConverter.GetBytes(order.Order_isPaid));

                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Exemple #8
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);
        }
Exemple #9
0
        /// <summary>
        /// 根据ID获取包含完整信息的Course类实例
        /// </summary>
        /// <param name="course">包含id字段的Course类实例</param>
        /// <returns>包含完整信息的Course类实例</returns>
        public Course GetCourseByID(Course course)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            Course        result     = null;

            try
            {
                COURSE toFindCourse = (from c in DataEntity.COURSE
                                       where
                                       c.course_id == course.Course_id
                                       select c).Single();
                result = ConvertCOURSEToCourse(toFindCourse);
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Exemple #10
0
        /// <summary>
        /// 根据账号密码获得数据库中的admin实例
        /// </summary>
        /// <param name="admin">要查找的Admin对象</param>
        /// <returns>成功返回Admin对象,未找到或失败返回null</returns>
        public Admin GetAdminByAccountAndPassword(Admin admin)
        {
            Admin         result     = null;
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();

            try
            {
                ADMIN result_admin = (from usr in DataEntity.ADMIN
                                      where usr.admin_account == admin.User_account &&
                                      usr.admin_password == admin.User_password
                                      select usr).Single();
                result = ConvertADMINToAdmin(result_admin);
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Exemple #11
0
        /// <summary>
        /// 根据参数的article_id返回包含完整信息的News类,失败返回null
        /// </summary>
        /// <param name="news">包含了news的ID的News对象</param>
        /// <returns>成功返回包含完整信息的News对象,否则返回Null</returns>
        public News GetNewsByID(News news)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            News          result     = null;

            try
            {
                NEWS ResultNEWS = (from destNews in DataEntity.NEWS
                                   where
                                   destNews.news_id == news.Article_id
                                   select destNews).Single();
                result = ConvertNEWSToNews(ResultNEWS);
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Exemple #12
0
        /// <summary>
        /// 根据参数中User类实例的user_id获取包含完整信息的User对象
        /// </summary>
        /// <param name="user">包含user_id的User类实例</param>
        /// <returns>成功返回包含完整信息的User类实例,失败返回null</returns>
        public User GetUserByID(User user)
        {
            avfunEntities DataEntity = DataEntityManager.GetDataEntity();
            User          result     = null;

            try
            {
                USER ResultUSER = (from usr in DataEntity.USER
                                   where usr.user_id == user.User_id
                                   select usr
                                   ).Single();
                result = ConvertUSERToUser(ResultUSER);
            }
            catch
            {
                result = null;
            }
            return(result);
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
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);
        }