protected void btnXoa_Click(object sender, EventArgs e) { ctl_newbuilding cls; List <object> selectedKey = grvList.GetSelectedFieldValues(new string[] { "collection_id" }); if (selectedKey.Count > 0) { foreach (var item in selectedKey) { cls = new ctl_newbuilding(); tbCollectionImage checkImage = (from i in db.tbCollectionImages where i.collection_id == Convert.ToInt32(item) select i).SingleOrDefault(); if (cls.Linq_xoa(Convert.ToInt32(item))) { alert.alert_Success(Page, "Xóa thành công", ""); loadData(); } 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/thuvienanh"), filename); FileUpload1.SaveAs(fileName_save); image = "/uploadimages/thuvienanh/" + filename; } admin_User logedMember = Session["AdminLogined"] as admin_User; ctl_newbuilding cls = new ctl_newbuilding(); cls_ThemVideo clss = new cls_ThemVideo(); { if (Session["_id"].ToString() == "0") { if (checknull() == false) { alert.alert_Warning(Page, "Hãy nhập đầy đủ thông tin!", ""); } else if (clss.Video_them(txtlink.Text, image)) { alert.alert_Success(Page, "Thêm thành công", ""); setNULL(); } else { alert.alert_Error(Page, "Thêm thất bại", ""); } } else { if (cls.Linq_suavideo(Convert.ToInt32(Session["_id"].ToString()), txtlink.Text, image)) { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "swal('Cập nhật thành công','','success').then(function(){grvList.Refresh();})", true); popupControl.ShowOnPageLoad = false; loadData(); } else { alert.alert_Error(Page, "Cập nhật thất bại", ""); } } } // loadData(); } // popupControl.ShowOnPageLoad = false; }
protected void btnUpload_Click(object sender, EventArgs e) { ctl_newbuilding insert = new ctl_newbuilding(); String folderUser = Server.MapPath("~/uploadimages/thuvienanh/"); if (!Directory.Exists(folderUser)) { Directory.CreateDirectory(folderUser); } string filename; string ulr = "/uploadimages/thuvienanh/"; HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { //string filename = Path.GetRandomFileName() + Path.GetExtension(FileUpload1.FileName); //filename = ulr + System.IO.Path.GetFileName(cls_ToAscii.ToAscii(hpf.FileName).ToLower()); filename = ulr + Path.GetRandomFileName() + Path.GetExtension(hpf.FileName); string path = HttpContext.Current.Server.MapPath("~/" + filename); hpf.SaveAs(path); VaryQualityLevel(System.Drawing.Image.FromStream(hpf.InputStream), path); insert.InsertImageOneProduct(filename); } } rpImageListing.DataSource = from i in db.tbCollectionImages select i; rpImageListing.DataBind(); foreach (RepeaterItem item in rpImageListing.Items) { HtmlGenericControl control = item.FindControl("divSub") as HtmlGenericControl; if (control != null) { //set the control value here. } } //divMes.InnerHtml = mes; //Session["re_id"] = null; cls_Alert.alert_Success(Page, "Đã lưu thành công", ""); loadData(); }