Exemple #1
0
        protected void btnThem1_Click(object sender, EventArgs e)
        {
            L.InsertProduct(DropDownList1.SelectedValue.ToString(), txtTenSP.Text, FileUpload1.FileName, txtQuantity.Text, txtGia.Text);
            Ld.InsertDetailProduct(txtTitle.Text, txtDescription.Text, txtPhoto.FileName, txtTit1.Text, txtDes1.Text, txtPhoto1.FileName, txtTit2.Text, txtDes2.Text, txtPhoto2.FileName, txtTit3.Text, txtDes3.Text, txtPhoto3.FileName, txtTit4.Text, txtDes4.Text, txtPhoto4.FileName, txtTit5.Text, txtDes5.Text, txtPhoto5.FileName);
            string alert = "Thêm thành công";

            Response.Redirect("~/Page/Admin/Product/Product.aspx?alert=" + alert);
        }
Exemple #2
0
 protected void btn_Them_Click(object sender, EventArgs e)
 {
     L.ProductID_    = Int32.Parse(txtMasp.Text);
     L.VenderID_     = Int32.Parse(ddrMansx.SelectedValue);
     L.CategoryID_   = Int32.Parse(ddrMaloai.SelectedValue);
     L.ProductName_  = txtTen.Text;
     L.Description_  = txtMieuta.Text;
     L.Photo_        = FileUploadAnh.FileName;
     L.Quantity_     = Int32.Parse(txtSoluong.Text);
     L.Cost_         = Int32.Parse(txtGia.Text);
     L.Amount_       = Int32.Parse(txtAmout.Text);
     L.ProductState_ = Int32.Parse(ddrState.Text);
     SaveFileUpload();
     bus.InsertProduct(L.ProductID_, L.VenderID_, L.CategoryID_, L.ProductName_, L.Description_,
                       L.Photo_, L.Quantity_, L.Cost_, L.Amount_, L.ProductState_);
     Response.Write("<script>alert('Thêm thành công!');</script>");
     HienThi();
 }
Exemple #3
0
        //public void SavePhoto()
        //{
        //    string path = "";
        //    HttpPostedFile image = Request.Files["FileUploadAnh"];
        //    if (image != null && image.ContentLength > 0)
        //    {
        //        path = Server.MapPath("~/Public/images/products/") + Path.GetFileName(image.FileName);
        //        image.SaveAs(path);
        //    }
        //}
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            int     vendorid    = int.Parse(DropDownList1.SelectedValue);
            int     categoryid  = int.Parse(DropDownList2.SelectedValue);
            string  productname = txtName.Text;
            string  description = txtDescription.Text;
            int     quantity    = int.Parse(txtQuantity.Text);
            decimal cost        = Convert.ToDecimal(txtCost.Text);
            string  photo       = "";

            if (FileUploadAnh.FileName != "")
            {
                string path = Server.MapPath("~/Public/images/products/" + FileUploadAnh.FileName);
                FileUploadAnh.PostedFile.SaveAs(path);
                photo = FileUploadAnh.FileName;
            }
            int state;

            if (chbState.Checked)
            {
                state = 1;
            }
            else
            {
                state = 0;
            }

            if (txtCost.Text == "" || txtDescription.Text == "" || txtName.Text == "" || txtQuantity.Text == "" || photo == "")
            {
                Response.Write("<script>alert('Mời nhập đủ thông tin sản phẩm!')</script>");
            }
            else
            {
                bus.InsertProduct(vendorid, categoryid, productname, description, photo, quantity, cost, state);
                //string alert = "Thêm thành công";
                Response.Redirect("~/Page/Admin/Product/Product.aspx");
            }
        }