protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            SanPhamDTO sp  = SanPhamBUS.LayDSSanPhamCapNhat(txtmasp.Text);
            SanPhamDTO sp2 = SanPhamBUS.LayDSSanPhamCapNhat(txtmasp.Text);

            sp.TenSP    = txtTenSP.Text;
            sp.ThongTin = txtThongTin.Text;
            sp.GiaTien  = Convert.ToInt32(txtGiaTien.Text);
            sp.MaLoaiSp = ddlSanPham.SelectedValue.ToString();
            if (imgHinhSanPham.HasFile)
            {
                string sTenfile;
                sTenfile = imgHinhSanPham.FileName;
                imgHinhSanPham.SaveAs(MapPath("../images/" + sTenfile));
                sp.AnhMinhHoa = sTenfile.ToString();
            }
            else
            {
                sp2.AnhMinhHoa = sp.AnhMinhHoa;
            }
            if (SanPhamBUS.CapNhatSP(sp, txtmasp.Text))
            {
                load();
                Response.Write("<script>alert('Cập nhật sản phẩm thành công!')</script>");
            }
            else
            {
                Response.Write("<script>alert('Cập nhật sản phẩm thất bại!')</script>");
            }
        }
Пример #2
0
        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            SanPhamDTO dto = new SanPhamDTO()
            {
                MaSP          = txtMaSP.Text,
                TenSP         = txtTenSP.Text,
                ThongTin      = txtThongTin.Text,
                GiaTien       = Convert.ToInt32(txtGiaBan.Text),
                SoLuongTonKho = Convert.ToInt32(txtSLTK.Text),
                MaLoaiSP      = drlLoaiSP.SelectedValue,
                AnhMinhHoa    = fileUpload.HasFile ? fileUpload.PostedFile.FileName : null,
                TrangThai     = ckTrangThai.Checked
            };

            if (SanPhamBUS.CapNhatSP(dto) > 0)
            {
                lbTrangThai.Text = "Cập nhật thành công";
                LoadDS();
            }
            else
            {
                lbTrangThai.Text = "Cập nhật thất bại";
            }
        }