예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string noidung = Request.Form["gui"];

        sanphamBLL bl = new sanphamBLL();

        string[]          noidungspli = noidung.Split('&');
        int               id          = Convert.ToInt32(noidungspli[1].Substring(3));
        List <sanphamDAL> ds          = bl.getSanPhambyId(id);

        splienquan.DataSource = ds;
        splienquan.DataBind();

        khuyenmaiBLL km = new khuyenmaiBLL();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbgia = splienquan.Items[i].FindControl("lbGia") as Label;
            if (ds[i].khuyenmai == true)
            {
                decimal khm = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
                lbgia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbgia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</span>";
            }
        }
    }
예제 #2
0
    private void loadsanpham()
    {
        sanphamBLL           sp = new sanphamBLL();
        khuyenmaiBLL         km = new khuyenmaiBLL();
        int                  id = Convert.ToInt32(Request.Form["id"]);
        dathangdetailBLL     bs = new dathangdetailBLL();
        List <dathangdetail> ds = bs.getdathangDetail(id);

        rpDatHang.DataSource = ds;
        rpDatHang.DataBind();
        decimal gia = 0;


        for (int i = 0; i <= ds.Count - 1; i++)
        {
            decimal           giasp = 0;
            List <sanphamDAL> list  = sp.getSPbyId(ds[i].id_sanpham);
            if (list[0].khuyenmai == true)
            {
                giasp = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
            }
            else
            {
                giasp = ds[i].gia;
            }

            Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label;
            gia       += (giasp * ds[i].soluong);
            lbSTT.Text = (i + 1).ToString();
        }
        lbTongTien.Text = String.Format("{0:0,0 VNĐ}", gia);
    }
예제 #3
0
    private void loadSanPham(int hide)
    {
        int row = 10;

        sanphamBLL        bs = new sanphamBLL();
        List <sanphamDAL> ds = bs.getSanPhambyIdP(id, row, hide);

        rpsanpham.DataSource = ds;
        rpsanpham.DataBind();

        khuyenmaiBLL km = new khuyenmaiBLL();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbgia = rpsanpham.Items[i].FindControl("lbGia") as Label;
            if (ds[i].khuyenmai == true)
            {
                decimal khm = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
                lbgia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbgia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</span>";
            }
        }

        // phan trang:
        int       current = Convert.ToInt32(Request.QueryString["p"]);
        phantrang pt      = new phantrang();
        int       cou     = bs.countP(-1, "", Convert.ToInt32(Request.QueryString["id"]));

        lbPhanTrang.Text = pt.pagingpublic(cou, row, "&id=" + Request.QueryString["id"], current);
    }
예제 #4
0
    // san pham mua nhieu

    private void load10muanhieu(int id_khm)
    {
        khuyenmaiBLL         km   = new khuyenmaiBLL();
        sanphamBLL           spbs = new sanphamBLL();
        dathangdetailBLL     bs   = new dathangdetailBLL();
        List <dathangdetail> ds   = bs.getdathangDetailMuaNhieuPubLic();

        rpbanchay.DataSource = ds;
        rpbanchay.DataBind();
        for (int i = 0; i <= ds.Count() - 1; i++)
        {
            Label             lbA    = rpbanchay.Items[i].FindControl("lbA") as Label;
            Label             lbHinh = rpbanchay.Items[i].FindControl("lbHinh") as Label;
            Label             lbTen  = rpbanchay.Items[i].FindControl("lbTen") as Label;
            Label             lbGia  = rpbanchay.Items[i].FindControl("lbGia") as Label;
            List <sanphamDAL> sptt   = spbs.getSPbyId(ds[i].id_sanpham);
            lbA.Text    = "<a href='chitietsanpham.aspx?id=" + sptt[0].id_sanpham + "&gr=" + sptt[0].id_danhmuc + "' title='" + sptt[0].ten_sanpham + "'>";
            lbHinh.Text = "<img class='hinhsp' height='350' width='275' alt='" + sptt[0].ten_sanpham + "' src='/uploads/" + sptt[0].hinhanh + "' style='display: block;' />";
            lbTen.Text  = "<span class='productName'>" + sptt[0].ten_sanpham + "</span>";
            if (sptt[0].khuyenmai == true)
            {
                decimal khm = sptt[0].gia - (sptt[0].gia * km.getKhuyenMaibyId(id_khm) / 100);
                lbGia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbGia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</span>";
            }
        }
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        sanphamBLL bs = new sanphamBLL();

        string            column = Request.Form["co"];
        string            value  = Request.Form["va"];
        List <sanphamDAL> ds     = bs.timkiem(column, value);

        sptimkiem.DataSource = ds;
        sptimkiem.DataBind();

        khuyenmaiBLL km = new khuyenmaiBLL();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbgia = sptimkiem.Items[i].FindControl("lbGia") as Label;
            if (ds[i].khuyenmai == true)
            {
                decimal khm = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
                lbgia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbgia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</span>";
            }
        }

        lbresult.Text = "Kết quả tìm được " + ds.Count + " sản phẩm " + value;
    }
예제 #6
0
    // them :
    private void them()
    {
        string     b       = "";
        sanphamBLL bs      = new sanphamBLL();
        DateTime   datet   = DateTime.Now;
        string     namePic = "";
        string     ext     = Path.GetExtension(fuPicture.FileName);

        if (fuPicture.HasFile)
        {
            if (CheckFileType(fuPicture.FileName) == true)
            {
                namePic = string.Format("{0:yyyy-M-d-HH-mm-ss}", datet) + ext;
                String filePath = "~/uploads/" + namePic;

                fuPicture.SaveAs(MapPath(filePath));
                lbErrorPic.Text = filePath;
            }
            else
            {
                lbErrorPic.Text = "Hình ảnh phải ở dạng đuôi *.png, *.jpg";
            }
        }
        if (rbYes.Checked == true)
        {
            b = "true";
        }
        else
        {
            b = "false";
        }
        if (bs.check(txtTen.Text) == true)
        {
            lbTen.Text = "Sản phẩm này đã tồn tại.";
        }
        else
        {
            bool tf = bs.add(txtTen.Text.Trim(), Convert.ToInt32(txtSoLuong.Text), namePic, Convert.ToInt32(ddlDM.SelectedValue), txtTT.Text, Convert.ToDecimal(txtGia.Text), b);
            if (tf == true)
            {
                Response.Redirect("sanpham.aspx?add=t");
            }
            else
            {
                lbError.Text = "<div class='error'>"
                               + "<div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "<p>Thêm bị lỗi !</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string noidung = Request.Form["gui"];

        sanphamBLL bl = new sanphamBLL();

        string[]          noidungspli = noidung.Split('&');
        int               id          = Convert.ToInt32(noidungspli[0].Substring(4));
        List <sanphamDAL> ds          = bl.getSPbyId(id);

        lbnoidung.Text = ds[0].tt_chitiet;
    }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        sanphamBLL        bs = new sanphamBLL();
        List <sanphamDAL> ds = bs.getSanPhamTonKho();

        rpDatHang.DataSource = ds;
        rpDatHang.DataBind();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label;
            lbSTT.Text += (i + 1).ToString();
        }
    }
예제 #9
0
    // load thong tin san pham:
    private void loadTTSP(int id)
    {
        sanphamBLL        bs   = new sanphamBLL();
        List <sanphamDAL> list = bs.getSPbyId(id);

        if (list.Count == 1)
        {
            lbGia.Text      = string.Format("{0:0,0 vnđ}", list[0].gia);
            txtGia.Text     = list[0].gia.ToString();;
            txtSoLuong.Text = list[0].soluong.ToString();
            txtTen.Text     = list[0].ten_sanpham;
            txtTT.Text      = list[0].tt_chitiet;

            // ddlist:

            ddlDM.SelectedValue = list[0].id_danhmuc.ToString();

            // radio:
            if (list[0].khuyenmai == true)
            {
                rbYes.Checked = true;
            }
            else
            {
                rbNo.Checked = true;
            }

            // hinh anh:
            if (list[0].hinhanh != "")
            {
                lbHinh.Text         = "<img width='100' height='100' style='display: block;' src='/uploads/" + list[0].hinhanh + "' alt='" + list[0].ten_sanpham + "'>";
                lbHinh.ToolTip      = list[0].hinhanh;
                fuPicture.Visible   = false;
                lbErrorPic.Visible  = false;
                btnHinhKhac.Visible = true;
            }
            else
            {
                lbHinh.Visible      = false;
                fuPicture.Visible   = true;
                lbErrorPic.Visible  = true;
                btnHinhKhac.Visible = false;
            }
        }
        else
        {
            Response.Redirect("error.aspx");
        }
    }
예제 #10
0
    // load thong tin san pham
    private void loadTTSP()
    {
        khuyenmaiBLL      km  = new khuyenmaiBLL();
        sanphamBLL        bs  = new sanphamBLL();
        List <sanphamDAL> ds  = bs.getSPbyId(id);
        decimal           khm = 0;

        if (ds.Count() == 1)
        {
            imgsp.ImageUrl = "/uploads/" + ds[0].hinhanh;
            hinh           = "/uploads/" + ds[0].hinhanh;
            if (ds[0].khuyenmai == true)
            {
                khm        = ds[0].gia - (ds[0].gia * km.getKhuyenMaibyId(1) / 100);
                lbGia.Text = "<del style='color:red'>" + String.Format("{0:0,0 vnđ}", ds[0].gia) + "</del>" + "&nbsp&nbsp&nbsp" + String.Format("{0:0,0 vnđ}", khm);
            }
            else
            {
                khm        = ds[0].gia;
                lbGia.Text = String.Format("{0:0,0 vnđ}", khm);
            }

            gia = khm;

            lbTenSP.Text = ds[0].ten_sanpham;
            ten          = ds[0].ten_sanpham;

            if (ds[0].soluong <= 2)
            {
                lbTinhTrang.Text = "Còn rất ít";
            }
            else if (ds[0].soluong == 0)
            {
                lbTinhTrang.Text = "Hết hàng";
            }
            else
            {
                lbTinhTrang.Text = "Còn hàng";
            }
            lbnoidung.Text = ds[0].tt_chitiet;
            atitle.Text    = ten + " Shop thời trang FMStyle";
        }
        else
        {
            Response.Redirect("error.aspx");
        }
    }
예제 #11
0
    private void loadsp(int danhmuc, string noidung, int view)
    {
        int row  = 10;
        int hide = 0;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }

        sanphamBLL        bs = new sanphamBLL();
        List <sanphamDAL> ds = bs.getSanPhamP(row, hide, danhmuc, noidung, view);

        rpSanpham.DataSource = ds;
        rpSanpham.DataBind();
        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label        lbSTT      = rpSanpham.Items[i].FindControl("lbSTT") as Label;
            DropDownList ddKuyenMai = rpSanpham.Items[i].FindControl("ddKuyenMai") as DropDownList;
            lbSTT.Text += (i + 1 + hide).ToString();
            if (ds[i].khuyenmai == true)
            {
                ddKuyenMai.SelectedValue = "1";
            }
            else
            {
                ddKuyenMai.SelectedValue = "0";
            }
        }
        string pa = "";

        if (view != -1)
        {
            pa = "&v=" + view + "&val=" + Request.QueryString["val"].ToString();
        }
        else if (danhmuc != -1 && noidung != "")
        {
            pa = "&t=" + danhmuc + "&n=" + noidung + "&val=" + Request.QueryString["val"].ToString();
        }
        // phan trang:
        int       current = Convert.ToInt32(Request.QueryString["p"]);
        phantrang pt      = new phantrang();

        lbPage.Text = pt.paging(bs.countP(danhmuc, noidung, view), row, pa, current);
    }
예제 #12
0
    protected void btnMua_Click(object sender, EventArgs e)
    {
        sanphamBLL        bs   = new sanphamBLL();
        List <sanphamDAL> ds   = bs.getSPbyId(id);
        string            size = ddlMau.Text;
        int soluong            = Convert.ToInt32(txtSoLuong.Text);
        int qd = ds[0].soluong - soluong;

        if (qd >= 0)
        {
            addCart(id, ten, soluong, hinh, gia, size);
            Response.Redirect("muahang.aspx");
        }
        else
        {
            lbError.Text = "Sản phẩm này đã hết hàng !<br>";
        }
    }
예제 #13
0
    // xoa hinh anh
    private void del_Hinh()
    {
        bool xoa = false;

        // xoa hinh trong thu muc uploads
        int               id            = Convert.ToInt32(Request.QueryString["id"]);
        sanphamBLL        bs            = new sanphamBLL();
        List <sanphamDAL> list          = bs.getSPbyId(id);
        string            imageFilePath = Server.MapPath("~/uploads/" + list[0].hinhanh + "");

        try
        {
            System.IO.File.Delete(imageFilePath);
            xoa = true;
        }
        catch
        {
            xoa = false;
        }

        // xoa hinh trong csdl:
        bool tf = bs.delHinh("", id);

        if (xoa == true && tf == true)
        {
            lbError.Text = "<div class='success'> " +
                           " <div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "	<p>Xóa hình thành công !</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
        else
        {
            lbError.Text = "<div class='error'> " +
                           " <div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "	<p>Xóa hình không thành công!</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
    }
예제 #14
0
    // load san pham ban chay:

    private void spbanchay(int id_khm)
    {
        lbtitle.Text   = "Sản phẩm bán chạy";
        lbDanhMuc.Text = "Sản phẩm bán chạy";
        int row  = 10;
        int hide = 0;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }
        phantrang            pt   = new phantrang();
        khuyenmaiBLL         km   = new khuyenmaiBLL();
        sanphamBLL           spbs = new sanphamBLL();
        dathangdetailBLL     bs   = new dathangdetailBLL();
        List <dathangdetail> ds   = bs.getdathangDetailMuaNhieuP(row, hide);

        rpbanchay.DataSource = ds;
        rpbanchay.DataBind();
        for (int i = 0; i <= ds.Count() - 1; i++)
        {
            Label             lbA    = rpbanchay.Items[i].FindControl("lbA") as Label;
            Label             lbHinh = rpbanchay.Items[i].FindControl("lbHinh") as Label;
            Label             lbTen  = rpbanchay.Items[i].FindControl("lbTen") as Label;
            Label             lbGia  = rpbanchay.Items[i].FindControl("lbGia") as Label;
            List <sanphamDAL> sptt   = spbs.getSPbyId(ds[i].id_sanpham);
            lbA.Text    = "<a href='chitietsanpham.aspx?id=" + sptt[0].id_sanpham + "&gr=" + sptt[0].id_danhmuc + "' title='" + sptt[0].ten_sanpham + "'>";
            lbHinh.Text = "<img class='hinhsp' height='350' width='275' alt='" + sptt[0].ten_sanpham + "' src='/uploads/" + sptt[0].hinhanh + "' style='display: block;' />";
            lbTen.Text  = "<span class='productName'>" + sptt[0].ten_sanpham + "</span>";
            if (sptt[0].khuyenmai == true)
            {
                decimal khm = sptt[0].gia - (sptt[0].gia * km.getKhuyenMaibyId(id_khm) / 100);
                lbGia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbGia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", sptt[0].gia) + "</span>";
            }
        }
        int r = bs.countMuaNhieuP();

        lbPhanTrang.Text = pt.pagingpublic(r, row, "&v=bc", hide);
    }
예제 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        sanphamBLL sp = new sanphamBLL();

        dathangdetailBLL     bs = new dathangdetailBLL();
        List <dathangdetail> ds = bs.getdathangDetailMuaNhieu();

        rpDatHang.DataSource = ds;
        rpDatHang.DataBind();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label;
            Label lbTen = rpDatHang.Items[i].FindControl("lbTen") as Label;
            lbSTT.Text += (i + 1).ToString();

            List <sanphamDAL> lsp = sp.getSPbyId(ds[i].id_sanpham);
            lbTen.Text = lsp[0].ten_sanpham;
        }
    }
예제 #16
0
    protected void btnThanhToan_Click(object sender, EventArgs e)
    {
        sanphamBLL           bss  = new sanphamBLL();
        List <giohangDAL>    cart = (List <giohangDAL>)Session["cart"];
        List <userpublicDAL> usp  = (List <userpublicDAL>)Session["userPublic"];
        dathangBLL           bs   = new dathangBLL();

        bs.add_dathang(usp[0].id_user, Convert.ToInt32(ddThanhToan.SelectedValue));
        int id = bs.id_dathang(usp[0].id_user);

        for (int i = 0; i <= cart.Count - 1; i++)
        {
            int y = Convert.ToInt32(cart[i].id_sanpham);
            List <sanphamDAL> liSoLuong = bss.getSPbyId(y);
            bs.add_dathang_detail(cart[i].id_sanpham, id, cart[i].soluong, cart[i].size);
            int pi = liSoLuong[0].soluong - cart[i].soluong;
            bs.soluong_sp(cart[i].id_sanpham, pi);
        }

        Session.Remove("cart");
        Response.Redirect("success.aspx");
    }
예제 #17
0
    // load san pham khuyen mai:
    private void loadspKM()
    {
        lbtitle.Text   = "Sản phẩm khuyến mãi";
        lbDanhMuc.Text = "Sản phẩm khuyến mãi";
        int hide = 0;

        int row = 10;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }
        phantrang         pt = new phantrang();
        khuyenmaiBLL      km = new khuyenmaiBLL();
        sanphamBLL        bs = new sanphamBLL();
        List <sanphamDAL> ds = bs.getSanPhamKMP(hide, row);

        rpsanpham.DataSource = ds;
        rpsanpham.DataBind();
        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbGia = rpsanpham.Items[i].FindControl("lbGia") as Label;
            if (ds[i].khuyenmai == true)
            {
                decimal khm = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
                lbGia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbGia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</span>";
            }
        }
        int r = bs.countKMP();

        lbPhanTrang.Text = pt.pagingpublic(r, row, "&v=km", hide);
    }
예제 #18
0
    // load 10 sanpham khuyenmai
    private void load10kmai()
    {
        sanphamBLL        bs = new sanphamBLL();
        List <sanphamDAL> ds = bs.getSanPhamKhuyenMai();

        rpkhuyenmai.DataSource = ds;
        rpkhuyenmai.DataBind();

        khuyenmaiBLL km = new khuyenmaiBLL();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbgia = rpkhuyenmai.Items[i].FindControl("lbGia") as Label;
            if (ds[i].khuyenmai == true)
            {
                decimal khm = ds[i].gia - (ds[i].gia * km.getKhuyenMaibyId(1) / 100);
                lbgia.Text = "<span class='price'><span style='color:Red;'><del>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</del>&nbsp;&nbsp;&nbsp;</span>" + String.Format("{0:0,0 vnđ}", khm) + "</span>";
            }
            else
            {
                lbgia.Text = "<span class='price'>" + String.Format("{0:0,0 vnđ}", ds[i].gia) + "</span>";
            }
        }
    }
예제 #19
0
    // sua :
    private void sua()
    {
        string     b       = "";
        sanphamBLL bs      = new sanphamBLL();
        DateTime   datet   = DateTime.Now;
        string     namePic = lbHinh.ToolTip;
        string     ext     = Path.GetExtension(fuPicture.FileName);

        if (rbYes.Checked == true)
        {
            b = "true";
        }
        else
        {
            b = "false";
        }
        string  ten     = txtTen.Text.Trim();
        int     soluong = Convert.ToInt32(txtSoLuong.Text);
        int     idd     = Convert.ToInt32(ddlDM.SelectedValue);
        string  tt      = txtTT.Text;
        decimal gia     = Convert.ToDecimal(txtGia.Text);
        int     id_sp   = Convert.ToInt32(Request.QueryString["id"]);

        if (bs.check(txtTen.Text, id_sp) == true)
        {
            lbTen.Text = "Sản phẩm này đã tồn tại.";
        }
        else
        {
            if (fuPicture.HasFile)
            {
                if (CheckFileType(fuPicture.FileName) == true)
                {
                    namePic = string.Format("{0:yyyy-M-d-HH-mm-ss}", datet) + ext;
                    String filePath = "~/uploads/" + namePic;

                    fuPicture.SaveAs(MapPath(filePath));
                    lbErrorPic.Text = filePath;
                }
                else
                {
                    lbErrorPic.Text = "Hình ảnh phải ở dạng đuôi *.png, *.jpg";
                }
            }
            bool tf = bs.edit(ten, soluong, namePic, idd, tt, gia, b, id_sp);
            if (tf == true)
            {
                Response.Redirect("sanpham.aspx?edit=t");
            }
            else
            {
                lbError.Text = "<div class='error'>"
                               + "<div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "<p>Thêm bị lỗi !</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
    }
예제 #20
0
    protected void btnCapNhat_Click(object sender, EventArgs e)
    {
        bool       tf    = false;
        bool       check = false;
        sanphamBLL bs    = new sanphamBLL();

        //cap nhat san pham khuyen mai:
        for (int i = 0; i <= rpSanpham.Items.Count - 1; i++)
        {
            CheckBox     cbDell     = rpSanpham.Items[i].FindControl("cbDell") as CheckBox;
            DropDownList ddKuyenMai = rpSanpham.Items[i].FindControl("ddKuyenMai") as DropDownList;
            if (ddKuyenMai.SelectedValue == "0")
            {
                tf = bs.suaKhuyenMai("false", Convert.ToInt32(cbDell.ToolTip));
            }
            else
            {
                tf = bs.suaKhuyenMai("true", Convert.ToInt32(cbDell.ToolTip));
            }
        }
        string id    = "";
        int    lengh = 0;

        // xoa  san pham:
        for (int i = 0; i <= rpSanpham.Items.Count - 1; i++)
        {
            CheckBox     cbDell     = rpSanpham.Items[i].FindControl("cbDell") as CheckBox;
            DropDownList ddKuyenMai = rpSanpham.Items[i].FindControl("ddKuyenMai") as DropDownList;
            if (cbDell.Checked)
            {
                //tf = bs.del(Convert.ToInt32(cbDell.ToolTip));

                string imageFilePath = Server.MapPath("~/uploads/" + ddKuyenMai.ValidationGroup + "");
                try
                {
                    System.IO.File.Delete(imageFilePath);
                    tf = true;
                }
                catch
                {
                    tf = false;
                }
                id   += cbDell.ToolTip + ",";
                lengh = id.Length;
                check = true;
            }
        }



        if (check == true)
        {
            string hid = id.Remove(lengh - 1);
            tf = bs.del(hid);
        }

        if (tf == false)
        {
            lbError.Text = "<div class='error'> " +
                           " <div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "	<p>Cập nhật thất bại!</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
        else
        {
            Response.Redirect("sanpham.aspx?up=t");
        }
    }