コード例 #1
0
        public static bool uBookInfo(Entity.BookInfo bookinfo)
        {
            int i = DAL.BookInfo_DAL.uBookInfo(bookinfo);

            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            string TypeId       = this.DropDownList4.SelectedValue;
            string BookName     = this.txtBookName.Text;
            string BookPrice    = this.txtBookPress.Text;
            string BookDisCount = this.txtBookDisCount.Text;
            string BookAuthor   = this.txtBookAuthor.Text;
            string BookPress    = this.txtBookPress.Text;
            string PressTime    = this.txtPressTime.Text;
            string PicPath      = this.FPicPath.FileName;
            string SellCount    = this.txtSellCount.Text;

            if (TypeId == "" || BookName == "" || BookPrice == "" || BookDisCount == "" || BookAuthor == "" || BookPress == "" || PressTime == "" || PicPath == "" || SellCount == "")
            {
                Response.Write("<script>alert('请将信息填写完整!')</script>");
            }
            else
            {
                try
                {
                    Convert.ToDouble(BookPrice);
                }
                catch
                {
                    Response.Write("<script>alert('价格格式不正确!')</script>");
                    return;
                }

                try
                {
                    Convert.ToDouble(BookDisCount);
                }
                catch
                {
                    Response.Write("<script>alert('折扣格式不正确!')</script>");
                    return;
                }

                try
                {
                    Convert.ToDateTime(PressTime);
                }
                catch
                {
                    Response.Write("<script>alert('出版日期格式不正确!')</script>");
                    return;
                }

                if (!(PicPath.EndsWith(".jpg") || PicPath.EndsWith(".png")))
                {
                    Response.Write("<script>alert('上传图片格式不正确!')</script>");
                    return;
                }

                try
                {
                    Convert.ToInt16(SellCount);
                }
                catch
                {
                    Response.Write("<script>alert('销售数量格式不正确!')</script>");
                    return;
                }

                Entity.BookInfo bookinfo = new Entity.BookInfo();
                bookinfo.TypeId       = TypeId;
                bookinfo.BookName     = BookName;
                bookinfo.BookPrice    = BookPrice;
                bookinfo.BookDisCount = BookDisCount;
                bookinfo.BookAuthor   = BookAuthor;
                bookinfo.BookPress    = BookPress;
                bookinfo.PressTime    = PressTime;
                bookinfo.PicPath      = PicPath;
                bookinfo.SellCount    = SellCount;



                if (BLL.BookInfo_BLL.uBookInfo(bookinfo))
                {
                    string strPath = Server.MapPath(@"\img\Books\" + PicPath);
                    this.FPicPath.SaveAs(strPath);
                    Response.Write("<script>alert('添加成功!')</script>");
                }
            }
        }
コード例 #3
0
        public static int uBookInfo(Entity.BookInfo bookinfo)
        {
            string sql = string.Format("insert into BookInfo values({0},'{1}',{2},{3},'{4}','{5}','{6}','{7}',{8})", bookinfo.TypeId, bookinfo.BookName, bookinfo.BookPrice, bookinfo.BookDisCount, bookinfo.BookAuthor, bookinfo.BookPress, bookinfo.PressTime, bookinfo.PicPath, bookinfo.SellCount);

            return(DBHelper.ExecuteNonQuery(sql));
        }