Example #1
0
        /// <summary>
        /// 读取用户信息方法()
        /// </summary>
        /// <returns>读取到的用户信息数据集合</returns>
        public static List <Model.Customer> GetCustomerInfor()
        {
            List <Model.Customer> modelList = new List <Model.Customer>();
            string        sql = "  select * from Customer";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql, System.Data.CommandType.Text);

            while (dr.Read())
            {
                modelList.Add(new Model.Customer()
                {
                    Answer       = dr["Answer"].ToString(),
                    State        = (int)dr["State"],
                    Question     = dr["Question"].ToString(),
                    Birthday     = (DateTime)dr["Birthday"],
                    CustomerName = dr["CustomerName"].ToString(),
                    Email        = dr["Email"].ToString(),
                    Gender       = dr["Gender"].ToString(),
                    ID           = dr["ID"].ToString(),
                    LastLogDate  = (DateTime)dr["LastLogDate"],
                    //LoginInfo = dr["LoginInfo"].ToString(),
                    LoginName = dr["LoginName"].ToString(),
                    Password  = dr["Password"].ToString(),
                    Phone     = dr["Phone"].ToString(),
                    QQMSN     = dr["QQMSN"].ToString(),
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #2
0
        public static List <Model.bookModel> Getbook()
        {
            List <Model.bookModel> modelList = new List <Model.bookModel>();
            string        sql = "";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql);

            while (dr.Read())
            {
                modelList.Add(new Model.bookModel()
                {
                    ID            = (int)dr["ID"],
                    bookName      = dr["bookName"].ToString(),
                    author        = dr["author"].ToString(),
                    publisher     = dr["publisher"].ToString(),
                    publisherDate = (DateTime)dr["publisherDate"],
                    price         = (decimal)dr["price"],
                    ISBN          = dr["ISBN"].ToString(),
                    pages         = (int)dr["pages"],
                    context       = dr["context"].ToString()
                });
            }

            DbHepler.Close();
            return(modelList);
        }
Example #3
0
        /// <summary>
        /// 读取图书信息方法()
        /// </summary>
        /// <returns>查询到图书信息数据集合</returns>
        public static List <Model.Book> GetBooksInfor()
        {
            List <Model.Book> modelList = new List <Model.Book>();
            string            sql       = " select * from book";
            SqlDataReader     dr        = DbHepler.ExecuteReader(sql, System.Data.CommandType.Text);

            while (dr.Read())
            {
                modelList.Add(new Model.Book()
                {
                    Author     = dr["Author"].ToString(),
                    AuthorDesc = dr["AuthorDesc"].ToString(),
                    CategoryID = (int)dr["CategoryID"],
                    //  CategoryName = dr["CategoryName"].ToString(),
                    Clicks        = (int)dr["Clicks"],
                    ContentDesc   = dr["ContentDesc"].ToString(),
                    EditorComment = dr["EditorComment"].ToString(),
                    ID            = dr["ID"].ToString(),
                    ISBN          = dr["ISBN"].ToString(),
                    Price         = (decimal)dr["Price"],
                    PublishDate   = (DateTime)dr["PublishDate"],
                    PublisherID   = (int)dr["PublisherID"],
                    // PublisherName = dr["PublisherName"].ToString(),
                    State      = (int)dr["State"],
                    Title      = dr["Title"].ToString(),
                    TOC        = dr["TOC"].ToString(),
                    WordsCount = (int)dr["WordsCount"],
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #4
0
        /// <summary>
        /// 查询该该用户注册的账号数据库是否存在方法()
        /// </summary>
        /// <param name="model">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明该账号已经存在,否则不存在</returns>
        public static int SelectUserName(Model.Customer model)
        {
            string sql = "  select count(*) from Customer where LoginName=@LoginName";

            SqlParameter[] P =
            {
                new SqlParameter("@LoginName", model.LoginName),
            };
            return((int)DbHepler.ExcuteReadCount(sql, P));
        }
Example #5
0
        /// <summary>
        /// 修改用户密码的方法()
        /// </summary>
        /// <param name="customer">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明修改成功!,否则失败</returns>
        public static int UpdateCustomerPassword(Model.Customer customer)
        {
            string sql = " update Customer set Password=@Password where ID=@ID";

            SqlParameter[] P =
            {
                new SqlParameter("@Password", customer.Password),
                new SqlParameter("@ID",       customer.ID),
            };
            return(DbHepler.ExecuteNonQuery(sql, System.Data.CommandType.Text, P));
        }
Example #6
0
        /// <summary>
        /// 用户登入方法()
        /// </summary>
        /// <param name="model">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明登入成功!,否则失败</returns>
        public static int UserLogin(Model.Customer model)
        {
            string sql = "  select count(*) from Customer where LoginName=@LoginName and [Password]=@pwd";

            SqlParameter[] P =
            {
                new SqlParameter("@LoginName", model.LoginName),
                new SqlParameter("@pwd",       model.Password),
            };
            return((int)DbHepler.ExcuteReadCount(sql, P));
        }
Example #7
0
        /// <summary>
        /// 修改用户密码密保方法()
        /// </summary>
        /// <param name="customer">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明修改成功!,否则失败</returns>
        public static int UpdateCustomerPasswordQuestion(Model.Customer customer)
        {
            string sql = "  update Customer set Question=@Qusetion,Answer=@Answer where ID=@ID";

            SqlParameter[] P =
            {
                new SqlParameter("@Qusetion", customer.Question),
                new SqlParameter("@Answer",   customer.Answer),
                new SqlParameter("@ID",       customer.ID),
            };
            return(DbHepler.ExecuteNonQuery(sql, System.Data.CommandType.Text, P));
        }
Example #8
0
        /// <summary>
        /// 修改用户的联系方式方法()
        /// </summary>
        /// <param name="customer">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明修改成功!,否则失败</returns>
        public static int UpdateCustomerContactWay(Model.Customer customer)
        {
            string sql = "  update Customer set Phone=@Phone,QQMSN=@QQMSN,Email=@Email where ID=@ID";

            SqlParameter[] P =
            {
                new SqlParameter("@Phone", customer.Phone),
                new SqlParameter("@QQMSN", customer.QQMSN),
                new SqlParameter("@Email", customer.Email),
                new SqlParameter("@ID",    customer.ID),
            };
            return(DbHepler.ExecuteNonQuery(sql, System.Data.CommandType.Text, P));
        }
Example #9
0
        /// <summary>
        /// 修改用户个人信息的方法()
        /// </summary>
        /// <param name="customer">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明修改成功!,否则失败</returns>
        public static int UpdateCustomer(Model.Customer customer)
        {
            string sql = "  update Customer set CustomerName=@Name,Gender=@Gender,Birthday=@Birthday where ID=@ID";

            SqlParameter[] P =
            {
                new SqlParameter("@Name",     customer.CustomerName),
                new SqlParameter("@Gender",   customer.Gender),
                new SqlParameter("@Birthday", customer.Birthday),
                new SqlParameter("@ID",       customer.ID),
            };
            return(DbHepler.ExecuteNonQuery(sql, System.Data.CommandType.Text, P));
        }
Example #10
0
        /// <summary>
        /// 添加新用户方法()
        /// </summary>
        /// <param name="model">用户实体类</param>
        /// <returns>数据库受影响的行数,如果大于0则说明用户注册成功!,否则失败</returns>
        public static int AddNewCustomer(Model.Customer model)
        {
            string sql = " insert into Customer([ID],[LoginName],[Password],[CustomerName],[Email]) values(@ID,@LoginName,@Pwd,@CustomerName,@Email)";

            SqlParameter[] P =
            {
                new SqlParameter("@ID",           model.ID),
                new SqlParameter("@LoginName",    model.LoginName),
                new SqlParameter("@Pwd",          model.Password),
                new SqlParameter("@CustomerName", model.CustomerName),
                new SqlParameter("@Email",        model.Email),
            };
            return(DbHepler.ExecuteNonQuery(sql, System.Data.CommandType.Text, P));
        }
Example #11
0
        /// <summary>
        /// 获取图书分类信息的方法
        /// </summary>
        /// <returns>得到图书分类信息的数据集合</returns>
        public static List <Model.Category> GetCategory()
        {
            List <Model.Category> category = new List <Model.Category>();
            string        sql = "  select * from Category";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql, System.Data.CommandType.Text);

            while (dr.Read())
            {
                category.Add(new Model.Category()
                {
                    ID = (int)dr["ID"], CategoryName = dr["CategoryName"] as string, ParentID = 0, ParentName = "", Remark = dr["Remark"] as string, State = (int)dr["State"]
                });
            }
            DbHepler.Close();
            return(category);
        }
Example #12
0
        public static List <Model.Brand> GetBrand()
        {
            List <Model.Brand> modelList = new List <Model.Brand>();
            string             sql       = "";
            SqlDataReader      dr        = DbHepler.ExecuteReader(sql);

            while (dr.Read())
            {
                modelList.Add(new Model.Brand()
                {
                    ID        = (int)dr["ID"],
                    brandName = dr["brandName"].ToString(),
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #13
0
        public static List <Model.typeSecondModel> GetSecond()
        {
            List <Model.typeSecondModel> modelList = new List <Model.typeSecondModel>();
            string        sql = "select * from typeSecond";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql);

            while (dr.Read())
            {
                modelList.Add(new Model.typeSecondModel()
                {
                    ID         = (int)dr["ID"],
                    fsID       = (int)dr["fsID"],
                    secondType = dr["secondType"].ToString()
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #14
0
        public static List <Model.Commodity> GetCommodity()
        {
            List <Model.Commodity> modelList = new List <Model.Commodity>();
            string        sql = "select *from Commodity";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql);

            while (dr.Read())
            {
                modelList.Add(new Model.Commodity()
                {
                    ID              = (int)dr["ID"],
                    Name            = dr["Name"].ToString(),
                    Powersupplymode = dr["Powersupplymode"].ToString(),
                    Price           = (decimal)dr["Price"],
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #15
0
        /// <summary>
        /// 读取图书信息方法()
        /// </summary>
        /// <param name="pagenum">显示的条数</param>
        /// <param name="pageindex">当前页码</param>
        /// <returns>查询到图书信息数据集合</returns>
        public static List <Model.Book> BOOK(int pagenum, int pageindex, out int pagesCount)
        {
            List <Model.Book> modelList = new List <Model.Book>();

            SqlParameter [] P =
            {
                new SqlParameter("@pageIndex",      pageindex),
                new SqlParameter("@pageCount",      pagenum),
                new SqlParameter("@pageTotalCount", SqlDbType.Int),
            };
            P[2].Direction = ParameterDirection.Output;

            SqlDataReader dr = DbHepler.ExecuteReader("WY", System.Data.CommandType.StoredProcedure, P);

            pagesCount = Convert.ToInt32(P[2].Value);
            while (dr.Read())
            {
                modelList.Add(new Model.Book()
                {
                    Author     = dr["Author"].ToString(),
                    AuthorDesc = dr["AuthorDesc"].ToString(),
                    CategoryID = (int)dr["CategoryID"],
                    //  CategoryName = dr["CategoryName"].ToString(),
                    Clicks        = (int)dr["Clicks"],
                    ContentDesc   = dr["ContentDesc"].ToString(),
                    EditorComment = dr["EditorComment"].ToString(),
                    ID            = dr["ID"].ToString(),
                    ISBN          = dr["ISBN"].ToString(),
                    Price         = (decimal)dr["Price"],
                    PublishDate   = (DateTime)dr["PublishDate"],
                    PublisherID   = (int)dr["PublisherID"],
                    // PublisherName = dr["PublisherName"].ToString(),
                    State      = (int)dr["State"],
                    Title      = dr["Title"].ToString(),
                    TOC        = dr["TOC"].ToString(),
                    WordsCount = (int)dr["WordsCount"],
                });
            }

            DbHepler.Close();
            return(modelList);
        }
Example #16
0
        /// <summary>
        /// 查询图书出版社信息方法()
        /// </summary>
        /// <returns>查找到出版社信息数据集合</returns>
        public static List <Model.Publisher> GetPublisher()
        {
            List <Model.Publisher> modelList = new List <Model.Publisher>();
            string        sql = "  select * from Publisher";
            SqlDataReader dr  = DbHepler.ExecuteReader(sql, System.Data.CommandType.Text);

            while (dr.Read())
            {
                modelList.Add(new Model.Publisher()
                {
                    ID            = (int)dr["ID"],
                    ImageUrl      = dr["ImageUrl"].ToString(),
                    PublisherName = dr["PublisherName"].ToString(),
                    Remark        = dr["Remark"].ToString(),
                    State         = (int)dr["State"],
                    WebUrl        = dr["WebUrl"].ToString(),
                });
            }
            DbHepler.Close();
            return(modelList);
        }
Example #17
0
        public static List <Model.Book> GetBImage(int pagenum, int pageindex, out int pageCount)
        {
            List <Model.Book> books = new List <Model.Book>();

            SqlParameter[] P =
            {
                new SqlParameter("@pageIndex",      pageindex),
                new SqlParameter("@pageCount",      pagenum),
                new SqlParameter("@pageTotalCount", SqlDbType.Int),
            };
            P[2].Direction = ParameterDirection.Output;
            DataSet ds = DbHepler.GetDataSet("WY", System.Data.CommandType.StoredProcedure, P);

            pageCount = Convert.ToInt32(P[2].Value);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Model.Book book = new Model.Book();
                book.Author        = dr["Author"].ToString();
                book.AuthorDesc    = dr["AuthorDesc"].ToString();
                book.CategoryID    = (int)dr["CategoryID"];
                book.Clicks        = (int)dr["Clicks"];
                book.ContentDesc   = dr["ContentDesc"].ToString();
                book.EditorComment = dr["EditorComment"].ToString();
                book.ID            = dr["ID"].ToString();
                book.ISBN          = dr["ISBN"].ToString();
                book.Price         = (decimal)dr["Price"];
                book.PublishDate   = (DateTime)dr["PublishDate"];
                book.PublisherID   = (int)dr["PublisherID"];
                book.State         = (int)dr["State"];
                book.Title         = dr["Title"].ToString();
                book.TOC           = dr["TOC"].ToString();
                book.WordsCount    = (int)dr["WordsCount"];
                books.Add(book);
            }
            return(books);
        }