예제 #1
0
    private void themSP()
    {
        SanPham sanpham = laySanPham();
        bool    kiemtra = connect.KiemTraMaSP(sanpham.masp);

        if (!fUpload.HasFile)
        {
            lblThongBao.Text = thongbao("Chưa chọn hình ảnh").ToString();
        }
        else
        {
            if (kiemtra)
            {
                lblThongBao.Text = thongbao("Mã sản phẩm này đã tồn tại!").ToString();
            }
            else
            {
                string imgname = fUpload.FileName;
                string imgLink = Server.MapPath("/MyShop/picture/" + imgname);
                fUpload.SaveAs(imgLink);

                bool result = connect.ThemSP(sanpham);
                if (result)
                {
                    lblThongBao.Text = thongbao("Thêm thành công!").ToString();
                    XoaForm();
                }
            }
        }
    }