protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Model.BookInfo bi = new Model.BookInfo();
         int            id = int.Parse(Request["id"]);
         biModel = bll.GetBookInfoById(id);
     }
     else
     {
         Model.BookInfo bi = new Model.BookInfo();
         bi.BookTitle   = Request["title"];
         bi.SubTitle    = Request["subtitle"];
         bi.PriceOld    = Convert.ToDecimal(Request["price"]);
         bi.PriceNew    = Convert.ToDecimal(Request["discountprice"]);
         bi.Author      = Request["author"];
         bi.Publisher   = Request["publisher"];
         bi.PublishDate = Convert.ToDateTime(Request["publishdate"]);
         bi.Isbn        = Request["isbn"];
         bi.TypeId      = Request["type1"] + "," + Request["type2"] + "," + Request["type3"];
         bi.Details     = Request["editorValue"];
         bi.Id          = Convert.ToInt32(Request["bid"]);
         bi.ImgTitle    = Request["imgTitle"];
         if (bll.InsertBookInfo(bi))
         {
             Response.Redirect("BookInfo.aspx");
         }
         else
         {
             Response.Redirect("Error.html");
         }
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Model.BookInfo bi = new Model.BookInfo();
            if (IsPostBack)
            {
                bi.BookTitle   = Request["title"];
                bi.SubTitle    = Request["subtitle"];
                bi.PriceNew    = Convert.ToInt32(Request["price"]);
                bi.PriceOld    = Convert.ToInt32(Request["discountprice"]);
                bi.Author      = Request["author"];
                bi.Publisher   = Request["publisher"];
                bi.PublishDate = Convert.ToDateTime(Request["publishdate"]);
                bi.SaleDate    = System.DateTime.Now;
                bi.Isbn        = Request["isbn"];
                bi.TypeId      = Request["type1"] + "," + Request["type2"] + "," + Request["type3"];
                bi.ImgTitle    = Request["imgTitle"];
                bi.Details     = Request["editorValue"];

                BookShopBLL.BookInfoBLL bll = new BookInfoBLL();
                if (bll.InsertBookInfo(bi))
                {
                    Response.Redirect("BookInfo.aspx");
                }
                else
                {
                    Response.Redirect("Error.html");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 图书信息方法
        /// </summary>
        /// <param name="i">1代表插入数据 2代表修改数据 3代表删除数据</param>
        /// <param name="a">实例化对象</param>
        /// <returns></returns>
        public static string sysBookInfo(int i, Model.BookInfo a)
        {
            string str = "proc_BookInfoSave";

            SqlParameter[] Parameter =
            {
                new SqlParameter("@num",       SqlDbType.Int),
                new SqlParameter("@类别编号",      SqlDbType.NVarChar),
                new SqlParameter("@图书名称",      SqlDbType.NVarChar),
                new SqlParameter("@ISBN",      SqlDbType.NVarChar),
                new SqlParameter("@图书作者",      SqlDbType.NVarChar),
                new SqlParameter("@出版社",       SqlDbType.NVarChar),
                new SqlParameter("@价格",        SqlDbType.Decimal),
                new SqlParameter("@页数",        SqlDbType.Int),
                new SqlParameter("@出版日期",      SqlDbType.DateTime),
                new SqlParameter("@图书等级编号",    SqlDbType.TinyInt),
                new SqlParameter("@图书简介",      SqlDbType.NVarChar),
                new SqlParameter("@入库日期",      SqlDbType.DateTime),
                new SqlParameter("@入库数量",      SqlDbType.Int),
                new SqlParameter("@在馆数量",      SqlDbType.Int),
                new SqlParameter("@BackValue", SqlDbType.NVarChar, 50),
            };
            Parameter[0].Value      = i;
            Parameter[1].Value      = a.CbSortId;
            Parameter[2].Value      = a.TbBookName;
            Parameter[3].Value      = a.TbBookISBN;
            Parameter[4].Value      = a.TbBookAuthor;
            Parameter[5].Value      = a.TbBookPress;
            Parameter[6].Value      = a.TbBookPrice;
            Parameter[7].Value      = a.TbBookPage;
            Parameter[8].Value      = a.DtpPDate;
            Parameter[9].Value      = a.CbBookGrade;
            Parameter[10].Value     = a.TbBookMark;
            Parameter[11].Value     = a.DtpPutDate;
            Parameter[12].Value     = a.TbRQuantity;
            Parameter[13].Value     = a.TbSQuantity;
            Parameter[14].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, str, Parameter);

            return(Convert.ToString(Parameter[14].Value.ToString()));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// update book info by id
        /// </summary>
        /// <param name="bi"></param>
        /// <returns></returns>
        public int UpdateBookInfo(Model.BookInfo bi)
        {
            string sql = "update BookInfo set Title=@Title,SubTitle=@SubTitle,PriceOld=@PriceOld,PriceNew=@PriceNew,Author=@Author,Publisher=@Publisher,@PublishDate=@PublishDate,SaleDate=@SaleDate,ISBN=@ISBN,TypeId=@TypeId,Details=@Details,ImgTitle=@ImgTitle where Id=@Id";

            SqlParameter[] ps =
            {
                new SqlParameter("@Title",       bi.BookTitle),
                new SqlParameter("@SubTitle",    bi.SubTitle),
                new SqlParameter("@PriceOld",    bi.PriceOld),
                new SqlParameter("@PriceNew",    bi.PriceNew),
                new SqlParameter("@Author",      bi.Author),
                new SqlParameter("@Publisher",   bi.Publisher),
                new SqlParameter("@PublishDate", bi.PublishDate),
                new SqlParameter("@SaleDate",    bi.SaleDate),
                new SqlParameter("@ISBN",        bi.Isbn),
                new SqlParameter("@TypeId",      bi.TypeId),
                new SqlParameter("@Details",     bi.Details),
                new SqlParameter("@ImgTitle",    bi.ImgTitle),
                new SqlParameter("@Id",          bi.Id)
            };
            return(SqlHelper.ExcuteNonQuery(sql, ps));
        }
 private Model.BookInfo RowToGetBookInfo(DataRow dr)
 {
     Model.BookInfo bi = new Model.BookInfo();
     bi.Id = Convert.ToInt32(dr["Id"]);
     return(bi);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         int start = Convert.ToInt32(Request["startId"]);
         int end   = Convert.ToInt32(Request["endId"]);
         //absolute path
         string      path = Request.MapPath("/");
         string      temp = File.ReadAllText(Request.MapPath("/BookDetail.html"));
         BookInfoBLL bll  = new BookInfoBLL();
         for (int i = start; i < end; i++)
         {
             Model.BookInfo bi = bll.GetBookInfoById(i);
             //if id is not exist.
             if (bi == null)
             {
                 continue;
             }
             //each folder can contain 500 html page, file name is id
             string path2 = path + (i / 500);
             if (!Directory.Exists(path2))
             {
                 Directory.CreateDirectory(path2);
             }
             string path3 = Path.Combine(path2, bi.Id + ".html");
             //replace all text
             string temp2 = temp.Replace("$imgTitle", bi.ImgTitle)
                            .Replace("$Details", bi.Details)
                            .Replace("$BookTitle", bi.BookTitle)
                            .Replace("$SubTitle", bi.SubTitle)
                            .Replace("$Author", bi.Author)
                            .Replace("$price", bi.PriceOld.ToString())
                            .Replace("$old", bi.PriceNew.ToString())
                            .Replace("$Isbn", bi.Isbn)
                            .Replace("$Publisher", bi.Publisher)
                            .Replace("$PublishDate", bi.PublishDate.ToString("yyyy-MM-dd"))
                            .Replace("$id", bi.Id.ToString());
             File.WriteAllText(path3, temp2);
         }
         Response.Write("<b style='color:red;'>Success to Generate</b>");
     }
     else
     {
         BookInfoBLL    bll   = new BookInfoBLL();
         Model.BookInfo bi    = new Model.BookInfo();
         DataTable      dt    = bll.GetAllBookInfo();
         int            max   = 1;
         int            start = 2;
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 bi = RowToGetBookInfo(dr);
                 if ((bi.Id + 1 - bi.Id) == 1)
                 {
                     max++;
                     continue;
                 }
             }
         }
         //Get Id domain
         Context.Response.Write("Id domain:" + start + "--" + max);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// update book info by id
 /// </summary>
 /// <param name="bi"></param>
 /// <returns></returns>
 public bool UpdateBookInfo(Model.BookInfo bi)
 {
     return(dal.UpdateBookInfo(bi) > 0);
 }