コード例 #1
0
ファイル: Myrespson.aspx.cs プロジェクト: zhaowei05/Book
        private void BookSearch_Search()
        {
            BookInfoEntity infoEntity = new BookInfoEntity();

            if (!string.IsNullOrWhiteSpace(Request["TypeId"]))
            {
                BookTypeBLL    typeBLL    = new BookTypeBLL();
                BookTypeEntity typeEntity = typeBLL.lists(int.Parse(Request["TypeId"]));
                if (typeEntity == null)
                {
                    infoEntity.TypeId = 0;
                }
                else if (typeEntity.ParentId != 0)
                {
                    infoEntity.TypeId = int.Parse(Request["TypeId"]);
                }
            }
            if (!string.IsNullOrWhiteSpace(Request["ParentId"]))
            {
                infoEntity.SellCount = int.Parse(Request["ParentId"]);
            }
            if (!string.IsNullOrWhiteSpace(Request["BookName"]))
            {
                infoEntity.BookName = Request["BookName"];
            }
            BookInfoBLL           infoBLL  = new BookInfoBLL();
            int                   count    = 0;
            List <BookInfoEntity> infolist = infoBLL.list(infoEntity, int.Parse(Request["Pageint"]), int.Parse(Request["Pagesize"]), out count);

            Response.Write(count + "_" + MyJson.ToJsJson(infolist));
            Response.End();
        }
コード例 #2
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            BookInfoBLL    infoBLL    = new BookInfoBLL();
            BookInfoEntity infoEntity = new BookInfoEntity();

            infoEntity.TypeId       = int.Parse(hdTwoType.Value);
            infoEntity.BookCode     = txtBookCode.Text;
            infoEntity.BookName     = txtBookName.Text;
            infoEntity.BookPrice    = decimal.Parse(txtBookPrice.Text);
            infoEntity.BookDisCount = decimal.Parse(txtBookDisCount.Text);
            infoEntity.BookAuthor   = txtBookAuthor.Text;
            infoEntity.BookPress    = txtBookPress.Text;
            infoEntity.PressTime    = DateTime.Parse(txtPressTime.Text);
            infoEntity.PicPath      = hdPicPath.Value;
            infoEntity.SellCount    = 0;
            infoEntity.BookRemark   = txtBookRemark.Text;
            if (infoBLL.Add(infoEntity) == 1)
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功!');</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('未知错误!');</script>");
            }
        }
コード例 #3
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public List <BookInfoEntity> list()
        {
            List <BookInfoEntity> list = new List <BookInfoEntity>();
            string sql = "select * from BookInfo";

            db.PrepareSql(sql);
            DataTable dt = db.ExecQuery();

            foreach (DataRow item in dt.Rows)
            {
                BookInfoEntity entity = new BookInfoEntity();
                entity.BookId       = int.Parse(item["BookId"].ToString());
                entity.TypeId       = int.Parse(item["TypeId"].ToString());
                entity.BookCode     = item["BookCode"].ToString();
                entity.BookName     = item["BookName"].ToString();
                entity.BookPrice    = decimal.Parse(item["BookPrice"].ToString());
                entity.BookDisCount = decimal.Parse(item["TypeName"].ToString());
                entity.BookAuthor   = item["BookAuthor"].ToString();
                entity.BookPress    = item["BookPress"].ToString();
                entity.PressTime    = DateTime.Parse(item["ParentId"].ToString());
                entity.PicPath      = item["PicPath"].ToString();
                entity.SellCount    = int.Parse(item["SellCount"].ToString());
                entity.BookRemark   = item["BookRemark"].ToString();

                entity.BookType          = new BookTypeEntity();
                entity.BookType.ParentId = int.Parse(item["ParentId"].ToString());
                entity.BookType.TypeName = item["TypeName"].ToString();
                list.Add(entity);
            }
            return(list);
        }
コード例 #4
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public BookInfoEntity list(int id)
        {
            string sql = "select BookInfo.*,BookType.TypeName,BookType.ParentId from BookInfo left join BookType on BookInfo.TypeId = BookType.TypeId  where BookId=" + id;

            db.PrepareSql(sql);
            DataTable dt = db.ExecQuery();

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            BookInfoEntity entity = new BookInfoEntity();

            entity.BookId       = int.Parse(dt.Rows[0]["BookId"].ToString());
            entity.TypeId       = int.Parse(dt.Rows[0]["TypeId"].ToString());
            entity.BookCode     = dt.Rows[0]["BookCode"].ToString();
            entity.BookName     = dt.Rows[0]["BookName"].ToString();
            entity.BookPrice    = decimal.Parse(dt.Rows[0]["BookPrice"].ToString());
            entity.BookDisCount = decimal.Parse(dt.Rows[0]["BookDisCount"].ToString());
            entity.BookAuthor   = dt.Rows[0]["BookAuthor"].ToString();
            entity.BookPress    = dt.Rows[0]["BookPress"].ToString();
            entity.PressTime    = DateTime.Parse(dt.Rows[0]["PressTime"].ToString());
            entity.PicPath      = dt.Rows[0]["PicPath"].ToString();
            entity.SellCount    = int.Parse(dt.Rows[0]["SellCount"].ToString());
            entity.BookRemark   = dt.Rows[0]["BookRemark"].ToString();

            entity.BookType          = new BookTypeEntity();
            entity.BookType.ParentId = int.Parse(dt.Rows[0]["ParentId"].ToString());
            entity.BookType.TypeName = dt.Rows[0]["TypeName"].ToString();
            return(entity);
        }
コード例 #5
0
ファイル: BookDetail.aspx.cs プロジェクト: zhaowei05/Book
        private void bindata()
        {
            BookInfoBLL    bll    = new BookInfoBLL();
            BookInfoEntity entity = new BookInfoEntity();
            bool           i      = int.TryParse(Request.QueryString["BookId"], out int x);

            if (string.IsNullOrWhiteSpace(Request.QueryString["BookId"]))
            {
                return;
            }
            else if (i == true)
            {
                entity = bll.list(int.Parse(Request.QueryString["BookId"]));
                if (entity != null)
                {
                    ViewState["Bookid"] = entity.BookId;
                    Image1.ImageUrl     = "uploadfile/" + entity.PicPath;
                    lblname.Text        = entity.BookName;
                    lblPrice.Text       = entity.BookPrice.ToString().Split('.')[0];
                    lblDis.Text         = (decimal.Parse(entity.BookPrice.ToString()) * decimal.Parse(entity.BookDisCount.ToString())).ToString("n");
                    lblAuthor.Text      = entity.BookAuthor;
                    lblPress.Text       = entity.BookPress;
                    lblRemark.Text      = entity.BookRemark;
                }
            }
            else
            {
            }
        }
コード例 #6
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public List <BookInfoEntity> list(BookInfoEntity infoEntity, int Pageint, int Pagesize, out int Count)
        {
            string sqlwhere = "";

            if (infoEntity != null)
            {
                if (!infoEntity.TypeId.Equals("") && infoEntity.TypeId != 0)
                {
                    sqlwhere += " and BookType.TypeId=" + infoEntity.TypeId;
                }
                if (!infoEntity.SellCount.Equals("") && infoEntity.SellCount != 0)
                {
                    sqlwhere += " and BookType.ParentId=" + infoEntity.SellCount;
                }
                if (infoEntity.BookName != null && !infoEntity.BookName.Equals(""))
                {
                    sqlwhere += " and BookName like '%" + infoEntity.BookName + "%'";
                    //for (int i = 0; i < infoEntity.BookName.Split(',').Length; i++)
                    //{
                    //    sqlwhere += " and BookName like '%" + infoEntity.BookName.Split(',')[i]+ "%'";
                    //}
                }
            }
            string sql = "select count(*) from BookInfo left join  BookType on BookInfo.TypeId=BookType.TypeId where 1=1 " + sqlwhere;

            db.PrepareSql(sql);
            Count = int.Parse(db.ExecScalar().ToString());
            List <BookInfoEntity> list = new List <BookInfoEntity>();

            sql = @"select *from(
select ROW_NUMBER()over(order by SellCount desc) rowid,BookInfo.*,BookType.TypeName,BookType.ParentId from BookInfo left join BookType on BookInfo.TypeId = BookType.TypeId   where 1 = 1 " + sqlwhere + " ) Tamp where rowid between @star and @end";
            db.PrepareSql(sql);
            db.SetParameter("star", (Pageint - 1) * Pagesize + 1);
            db.SetParameter("end", Pageint * Pagesize);
            DataTable dt = db.ExecQuery();

            foreach (DataRow item in dt.Rows)
            {
                BookInfoEntity entity = new BookInfoEntity();
                entity.BookId       = int.Parse(item["BookId"].ToString());
                entity.TypeId       = int.Parse(item["TypeId"].ToString());
                entity.BookCode     = item["BookCode"].ToString();
                entity.BookName     = item["BookName"].ToString();
                entity.BookPrice    = decimal.Parse(item["BookPrice"].ToString());
                entity.BookDisCount = decimal.Parse(item["BookDisCount"].ToString());
                entity.BookAuthor   = item["BookAuthor"].ToString();
                entity.BookPress    = item["BookPress"].ToString();
                entity.PressTime    = DateTime.Parse(item["PressTime"].ToString());
                entity.PicPath      = item["PicPath"].ToString();
                entity.SellCount    = int.Parse(item["SellCount"].ToString());
                entity.BookRemark   = item["BookRemark"].ToString();

                entity.BookType          = new BookTypeEntity();
                entity.BookType.ParentId = int.Parse(item["ParentId"].ToString());
                entity.BookType.TypeName = item["TypeName"].ToString();
                list.Add(entity);
            }
            return(list);
        }
コード例 #7
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public List <BookInfoEntity> Order(int by, int Pageint, int Pagesize, out int Count)
        {
            string Order = "BookId";

            if (by != 0)
            {
                if (by == 1)
                {
                    Order = " SellCount desc ";
                }
                if (by == 2)
                {
                    Order = " BookDisCount";
                }
                if (by == 3)
                {
                    Order = " BookId desc";
                }
            }
            string sql = "select count(*) from BookInfo left join  BookType on BookInfo.TypeId=BookType.TypeId where 1=1 ";

            db.PrepareSql(sql);
            Count = int.Parse(db.ExecScalar().ToString());
            List <BookInfoEntity> list = new List <BookInfoEntity>();

            sql = @"select *from(
select ROW_NUMBER()over(order by " + Order + " ) rowid,BookInfo.*,BookType.TypeName,BookType.ParentId from BookInfo left join BookType on BookInfo.TypeId = BookType.TypeId   where 1 = 1 ) Tamp where rowid between @star and @end";
            db.PrepareSql(sql);
            db.SetParameter("star", (Pageint - 1) * Pagesize + 1);
            db.SetParameter("end", Pageint * Pagesize);
            DataTable dt = db.ExecQuery();

            foreach (DataRow item in dt.Rows)
            {
                BookInfoEntity entity = new BookInfoEntity();
                entity.BookId       = int.Parse(item["BookId"].ToString());
                entity.TypeId       = int.Parse(item["TypeId"].ToString());
                entity.BookCode     = item["BookCode"].ToString();
                entity.BookName     = item["BookName"].ToString();
                entity.BookPrice    = decimal.Parse(item["BookPrice"].ToString());
                entity.BookDisCount = decimal.Parse(item["BookDisCount"].ToString());
                entity.BookAuthor   = item["BookAuthor"].ToString();
                entity.BookPress    = item["BookPress"].ToString();
                entity.PressTime    = DateTime.Parse(item["PressTime"].ToString());
                entity.PicPath      = item["PicPath"].ToString();
                entity.SellCount    = int.Parse(item["SellCount"].ToString());
                entity.BookRemark   = item["BookRemark"].ToString();

                entity.BookType          = new BookTypeEntity();
                entity.BookType.ParentId = int.Parse(item["ParentId"].ToString());
                entity.BookType.TypeName = item["TypeName"].ToString();
                list.Add(entity);
            }
            return(list);
        }
コード例 #8
0
        //绑定数据
        private void bindata()
        {
            int count = 1;

            if (string.IsNullOrWhiteSpace(Request.QueryString["Count"]))
            {
                count = 1;
            }
            else
            if (int.TryParse(Request.QueryString["Count"], out count) == false || count <= 0)
            {
                count = 1;
            }
            if (string.IsNullOrWhiteSpace(Request.QueryString["BookId"]))
            {
                return;
            }
            if (int.TryParse(Request.QueryString["BookId"], out int i))
            {
                BookInfoBLL    infoBLL    = new BookInfoBLL();
                BookInfoEntity infoEntity = new BookInfoEntity();
                MemberEntity   member     = (MemberEntity)Session["usr"];
                BookCartBLL    cartBLL    = new BookCartBLL();

                infoEntity = infoBLL.list(i);
                if (infoEntity == null)
                {
                    return;
                }
                ContentPlaceHolder1_imgBook.ImageUrl = "~/uploadfile/" + infoEntity.PicPath;
                lblTitle.Text      = "书名:" + infoEntity.BookName;
                lblInfo.Text       = "作者:" + infoEntity.BookAuthor + "&nbsp; &nbsp; 出版社:" + infoEntity.BookPress + "";
                lblPrice.InnerHtml = "<span style='text-decoration:line-through;'>原价:" + (infoEntity.BookPrice * count).ToString().Split('.')[0] + "元</span>&nbsp;&nbsp;现价:" + ((infoEntity.BookPrice * infoEntity.BookDisCount) * count).ToString("n") + "&nbsp;&nbsp;数量:" + count;

                //加入购物车

                BookCartEntity cartEntity = cartBLL.list(member.MemberId, infoEntity.BookId);
                if (cartEntity != null)
                {
                    cartEntity.BookCount += count;
                    cartBLL.Update(cartEntity);
                }
                else
                {
                    BookCartEntity bookCart = new BookCartEntity();
                    bookCart.MemberId  = member.MemberId;
                    bookCart.BookId    = infoEntity.BookId;
                    bookCart.BookCount = count;
                    cartBLL.Add(bookCart);
                }
            }
        }
コード例 #9
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public int Add(BookInfoEntity entity)
        {
            string sql = @"insert into BookInfo(TypeId,BookCode,BookName,BookPrice,BookDisCount,BookAuthor,BookPress,PressTime,PicPath,SellCount,BookRemark) values(@TypeId,@BookCode,@BookName,@BookPrice,@BookDisCount,@BookAuthor,@BookPress,@PressTime,@PicPath,@SellCount,@BookRemark)";

            db.PrepareSql(sql);
            db.SetParameter("TypeId", entity.TypeId);
            db.SetParameter("BookCode", entity.BookCode);
            db.SetParameter("BookName", entity.BookName);
            db.SetParameter("BookPrice", entity.BookPrice);
            db.SetParameter("BookDisCount", entity.BookDisCount);
            db.SetParameter("BookAuthor", entity.BookAuthor);
            db.SetParameter("BookPress", entity.BookPress);
            db.SetParameter("PressTime", entity.PressTime);
            db.SetParameter("PicPath", entity.PicPath);
            db.SetParameter("SellCount", entity.SellCount);
            db.SetParameter("BookRemark", entity.BookRemark);
            return(db.ExecNonQuery());
        }
コード例 #10
0
ファイル: BookInfoDAL.cs プロジェクト: zhaowei05/Book
        public int Update(BookInfoEntity entity)
        {
            string sql = "Update BookInfo set TypeId=@TypeId,BookCode=@BookCode,BookName=@BookName,BookPrice=@BookPrice,BookDisCount=@BookDisCount,BookAuthor=@BookAuthor,BookPress=@BookPress,PressTime=@PressTime,PicPath=@PicPath,SellCount=@SellCount,BookRemark=@BookRemark where BookId=@BookId";

            db.PrepareSql(sql);
            db.SetParameter("TypeId", entity.TypeId);
            db.SetParameter("BookCode", entity.BookCode);
            db.SetParameter("BookName", entity.BookName);
            db.SetParameter("BookPrice", entity.BookPrice);
            db.SetParameter("BookDisCount", entity.BookDisCount);
            db.SetParameter("BookAuthor", entity.BookAuthor);
            db.SetParameter("BookPress", entity.BookPress);
            db.SetParameter("PressTime", entity.PressTime);
            db.SetParameter("PicPath", entity.PicPath);
            db.SetParameter("SellCount", entity.SellCount);
            db.SetParameter("BookRemark", entity.BookRemark);
            db.SetParameter("BookId", entity.BookId);
            return(db.ExecNonQuery());
        }
コード例 #11
0
ファイル: BookInfoBLL.cs プロジェクト: zhaowei05/Book
 public int Update(BookInfoEntity entity)
 {
     return(dal.Update(entity));
 }
コード例 #12
0
ファイル: BookInfoBLL.cs プロジェクト: zhaowei05/Book
 public int Add(BookInfoEntity entity)
 {
     return(dal.Add(entity));
 }
コード例 #13
0
ファイル: BookInfoBLL.cs プロジェクト: zhaowei05/Book
 public List <BookInfoEntity> list(BookInfoEntity infoEntity, int Pageint, int Pagesize, out int Count)
 {
     return(dal.list(infoEntity, Pageint, Pagesize, out Count));
 }