Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookManager bm = new BookManager();

        book = bm.GetByID(Convert.ToInt32(Request["id"]));
        bm.Save();
        return;
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookManager BM   = new BookManager();
        BookTBx     book = BM.GetByID(Convert.ToInt32(Request["id"]));

        book.Status = -1;
        BM.Save();
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookManager bm = new BookManager();

        if (RouteData.Values["id"] != null)
        {
            int id = Convert.ToInt32(RouteData.Values["id"].ToString());
            book = bm.GetByID(id);
        }
        //book = bm.GetByID(Convert.ToInt32(Request["id"]));
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookTBx     book = new BookTBx();
        BookManager bm   = new BookManager();
        int         id   = Convert.ToInt32(Request["id"]);

        book           = bm.GetByID(id);
        book.Name      = Request["name"];
        book.ShortDesc = Request["shortdesc"];
        book.Desc      = Request["desc"];
        book.Price     = Convert.ToInt32(Request["price"]);

        ImageManager IM     = new ImageManager();
        string       base64 = Request["base64"];

        var imagebase64 = ImageUtilities.ConvertBase64ToImage(base64);
        var extention   = ImageUtilities.getExtention(imagebase64.RawFormat);

        imagebase64 = ImageUtilities.CreateThumbnail2(1024, 800, imagebase64);

        ImageTBx ima     = new ImageTBx();
        int      idimage = Convert.ToInt32(Request["imageid"]);

        if (idimage != 0)
        {
            ima      = IM.GetByID(idimage);
            ima.Name = "sach_" + ima.ID + extention;
            IM.Save();
        }
        if (idimage == 0)
        {
            ima.Name   = "demo.jpg";
            ima.BookID = book.ID;
            IM.AddNew(ima);
            ima.Name = "sach_" + ima.ID + extention;
            IM.Save();
        }

        imagebase64.Save(Server.MapPath("~/Admin/upload/" + ima.Name), imagebase64.RawFormat);

        var imagethumb = ImageUtilities.CreateThumbnail(300, 500, Server.MapPath("~/Admin/upload/" + ima.Name));

        imagethumb.Save(Server.MapPath("~/Admin/upload/thumbnails/" + ima.Name), imagethumb.RawFormat);
        imagethumb.Dispose();


        bm.Save();
        return;
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookTBx     book = new BookTBx();
        BookManager bm   = new BookManager();

        book.Name      = Request["name"];
        book.ShortDesc = Request["shortdesc"];
        book.Desc      = Request["desc"];
        book.Price     = Convert.ToInt32(Request["price"]);
        book.Status    = 1;
        bm.AddNew(book);
        ImageManager IM     = new ImageManager();
        string       base64 = Request["base64"];

        //Nut tải ảnh lên
        if (base64 != "" && base64 != null)
        {
            var imagebase64 = ImageUtilities.ConvertBase64ToImage(base64);
            var extention   = ImageUtilities.getExtention(imagebase64.RawFormat);
            imagebase64 = ImageUtilities.CreateThumbnail2(1024, 800, imagebase64);

            ImageTBx ima = new ImageTBx();
            ima.Name   = "demo.jpg";
            ima.BookID = book.ID;
            IM.AddNew(ima);
            ima.Name = "sach_" + ima.ID + extention;
            IM.Save();

            imagebase64.Save(Server.MapPath("~/upload/" + ima.Name), imagebase64.RawFormat);

            var imagethumb = ImageUtilities.CreateThumbnail(300, 500, Server.MapPath("~/upload/" + ima.Name));
            imagethumb.Save(Server.MapPath("~/upload/thumbnails/" + ima.Name), imagethumb.RawFormat);
            imagethumb.Dispose();
        }
        bm.Save();


        return;
    }
Пример #6
0
 public void AddNew(BookTBx book)
 {
     db.BookTBxes.InsertOnSubmit(book);
     Save();
 }
Пример #7
0
 private void detach_BookTBxes(BookTBx entity)
 {
     this.SendPropertyChanging();
     entity.AuthorTBx = null;
 }
Пример #8
0
 private void attach_BookTBxes(BookTBx entity)
 {
     this.SendPropertyChanging();
     entity.AuthorTBx = this;
 }
Пример #9
0
 partial void DeleteBookTBx(BookTBx instance);
Пример #10
0
 partial void UpdateBookTBx(BookTBx instance);
Пример #11
0
 partial void InsertBookTBx(BookTBx instance);
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BookTBx book = BM.GetByID(Convert.ToInt32(Request["id"]));

        if (!IsPostBack)
        {
            DataTable cart = new DataTable();
            if (Session["cart"] == null)
            {
                //Nếu chưa có giỏ hàng, tạo giỏ hàng thông qua DataTable với 4 cột chính
                //ID (Mã sản phẩm), Name (Tên sản phẩm)
                //Price (Giá tiền), Quantity (Số lượng)

                cart.Columns.Add("ID");
                cart.Columns.Add("Name");
                cart.Columns.Add("Price");
                cart.Columns.Add("Quantity");
                //Sau khi tạo xong thì lưu lại vào session
                Session["cart"] = cart;
            }
            else
            {
                //Lấy thông tin giỏ hàng từ Session["cart"]
                cart = Session["cart"] as DataTable;
            }
            //if (!String.IsNullOrEmpty(Request.QueryString["action"]))
            {
                //if (Request.QueryString["action"] == "add")
                {
                    String         id  = Request["id"];
                    int            id1 = Convert.ToInt32(Request["id"]);
                    SqlConnection  con = new SqlConnection("Data Source=DESKTOP-QETFID9;Initial Catalog=Test3ASP.NET;Integrated Security=True");
                    SqlDataAdapter sda = new SqlDataAdapter("Select * from BookTBx Where ID='" + id1 + "'", con);
                    DataTable      dt  = new DataTable();
                    sda.Fill(dt);
                    //string id ="2";
                    string name  = dt.Rows[0][1].ToString();
                    string price = dt.Rows[0][4].ToString();

                    //Kiểm tra xem đã có sản phẩm trong giỏ hàng chưa ?
                    //Nếu chưa thì thêm bản ghi mới vào giỏ hàng với số lượng Quantity là 1
                    //Nếu có thì tăng quantity lên 1
                    bool isExisted = false;
                    foreach (DataRow dr in cart.Rows)
                    {
                        if (dr["ID"].ToString() == id)
                        {
                            dr["Quantity"] = int.Parse(dr["Quantity"].ToString()) + 1;
                            isExisted      = true;
                            break;
                        }
                    }
                    if (!isExisted && id != null)//Chưa có sản phẩm trong giỏ hàng
                    {
                        DataRow dr = cart.NewRow();
                        dr["ID"]       = id;
                        dr["Name"]     = name;
                        dr["Price"]    = price;
                        dr["Quantity"] = 1;
                        cart.Rows.Add(dr);
                    }
                    //Lưu lại thông tin giỏ hàng mới nhất vào session["Cart"]
                    Session["cart"] = cart;
                    //Quay lai trang chu
                    // Response.Redirect("Category.aspx");
                }
            }

            //Hiện thị thông tin giỏ hàng
            GridView1.DataSource = cart;
            GridView1.DataBind();
        }
    }