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", ""); } }
public bool Linq_suavideo(int collection_id, string link, string image) { tbCollectionImage update = db.tbCollectionImages.Where(x => x.collection_id == collection_id).FirstOrDefault(); if (link != null) { update.collection_youtube = link; } //else //{ // update.collection_youtube = link; //} if (image != null) { update.collection_image = image; update.collection_avatar = image; } try { db.SubmitChanges(); return(true); } catch { return(false); } }
protected void btnXoaImage_ServerClick(object sender, EventArgs e) { tbCollectionImage del = (from i in db.tbCollectionImages where i.collection_id == Convert.ToInt32(txtImage.Value) select i).SingleOrDefault(); db.tbCollectionImages.DeleteOnSubmit(del); db.SubmitChanges(); rpImageListing.DataSource = from i in db.tbCollectionImages select i; rpImageListing.DataBind(); }
public bool Linq_xoa(int collection_id) { tbCollectionImage delete = db.tbCollectionImages.Where(x => x.collection_id == collection_id).FirstOrDefault(); db.tbCollectionImages.DeleteOnSubmit(delete); try { db.SubmitChanges(); return(true); } catch { return(false); } }
public bool Video_them(string link, string image) { tbCollectionImage insert = new tbCollectionImage(); insert.collection_youtube = link; insert.collection_avatar = image; db.tbCollectionImages.InsertOnSubmit(insert); try { db.SubmitChanges(); return(true); } catch { return(false); } }
// one product public bool InsertImageOneProduct(string image) { tbCollectionImage insert = new tbCollectionImage(); insert.collection_image = image; insert.collection_avatar = image; db.tbCollectionImages.InsertOnSubmit(insert); try { db.SubmitChanges(); return(true); } catch { return(false); } }
//xóa image //public bool Image_xoa(int image_id) //{ // tbCollectionImage delete = db.tbCollectionImages.Where(x => x.collection_id == image_id).FirstOrDefault(); // db.tbCollectionImages.DeleteOnSubmit(delete); // try // { // db.SubmitChanges(); // return true; // } // catch // { // return false; // } //} //thêm video //public bool Video_them(string link, string image) //{ // tbCollectionImage insert = new tbCollectionImage(); // insert.collection_youtube = link; // insert.collection_avatar = image; // db.tbCollectionImages.InsertOnSubmit(insert); // try // { // db.SubmitChanges(); // return true; // } // catch // { // return false; // } //} //sửa image public bool Linq_suaimage(int collection_id, string image) { tbCollectionImage update = db.tbCollectionImages.Where(x => x.collection_id == collection_id).FirstOrDefault(); if (image != null) { update.collection_image = image; update.collection_avatar = image; } try { db.SubmitChanges(); return(true); } catch { return(false); } }