protected void btnXoa_Click(object sender, EventArgs e) { cls_Product cls; List <object> selectedKey = grvList.GetSelectedFieldValues(new string[] { "product_id" }); if (selectedKey.Count > 0) { foreach (var item in selectedKey) { cls = new cls_Product(); tbProduct checkImage = (from i in db.tbProducts where i.product_id == Convert.ToInt32(item) select i).SingleOrDefault(); if (cls.Product_Xoa(Convert.ToInt32(item))) { alert.alert_Success(Page, "Xóa thành công", ""); } else { alert.alert_Error(Page, "Xóa thất bại", ""); } } } else { alert.alert_Warning(Page, "Bạn chưa chọn dữ liệu", ""); } }
protected void btnLuu_Click(object sender, EventArgs e) { if (Session["AdminLogined"] != null) { if (Page.IsValid && FileUpload1.HasFile) { string filename = Path.GetRandomFileName() + Path.GetExtension(FileUpload1.FileName); string fileName_save = Path.Combine(Server.MapPath("~/uploadimages/imageproduct"), filename); FileUpload1.SaveAs(fileName_save); image = "/uploadimages/imageproduct/" + filename; } admin_User logedMember = Session["AdminLogined"] as admin_User; cls_Product cls = new cls_Product(); if (checknull() == false) { alert.alert_Warning(Page, "Hãy nhập đầy đủ thông tin!", ""); } else { string KEYWORD = "", TitleSeo = "", Link = "", Dep = "", ImageSeo = ""; { if (SEO_KEYWORD.Text != "") { KEYWORD = SEO_KEYWORD.Text; } if (SEO_TITLE.Text != "") { TitleSeo = SEO_TITLE.Text; } if (SEO_LINK.Text != "") { Link = SEO_LINK.Text; } if (SEO_DEP.Value != "") { Dep = SEO_DEP.Value; } if (SEO_IMAGE.Text != "") { ImageSeo = SEO_IMAGE.Text; } } if (Session["_id"] == null) { if (cls.Product_Them(txttensanpham.Text, image, txtContent.Value, gia, true, true, Convert.ToInt32(ddlNhomSanPham.Value.ToString()), KEYWORD, TitleSeo, Link, Dep, ImageSeo)) { alert.alert_Success(Page, "Thêm thành công", ""); popupControl.ShowOnPageLoad = false; loadData(); } else { alert.alert_Error(Page, "Thêm thất bại", ""); } } else { if (cls.Product_Sua(Convert.ToInt32(Session["_id"].ToString()), txttensanpham.Text, image, txtContent.Value, gia, Convert.ToInt32(ddlNhomSanPham.Value.ToString()), KEYWORD, TitleSeo, Link, Dep, ImageSeo)) { alert.alert_Success(Page, "Cập nhật thành công", ""); popupControl.ShowOnPageLoad = false; loadData(); } else { alert.alert_Error(Page, "Cập nhật thất bại", ""); } } } loadData(); } //popupControl.ShowOnPageLoad = false; }