protected void Page_Load(object sender, EventArgs e) { if (this.User.Identity.IsAuthenticated) { if (!this.IsPostBack) { RealStateDSTableAdapters.FlatsTableAdapter adapter = new RealStateDSTableAdapters.FlatsTableAdapter(); RealStateDS.FlatsDataTable table = adapter.GetDataByUserName(this.User.Identity.Name.ToString()); GridView1.DataSource = table; GridView1.DataBind(); } } }
public void DeleteFilePicture(int FlatID) { string FolderPath = HttpContext.Current.Request.PhysicalApplicationPath + "Images\\Flats\\"; RealStateDSTableAdapters.FlatsTableAdapter adapter = new RealStateDSTableAdapters.FlatsTableAdapter(); string PictureURL = adapter.GetPictureByFlatID(FlatID); ProcessDelete(FolderPath ); ProcessDelete(FolderPath + "thumb_" + PictureURL); RealStateDS.FlatsDataTable T = adapter.GetPicturesByFlatID(FlatID); for (int i = 0; i < T.Rows.Count; i++) { ProcessDelete(FolderPath + T.Rows[i].ItemArray[7].ToString()); ProcessDelete(FolderPath + "thumb_" + T.Rows[i].ItemArray[7].ToString()); } }
public void DeleteFilePicture(int FlatID) { string FolderPath = HttpContext.Current.Request.PhysicalApplicationPath + "Images\\Flats\\"; RealStateDSTableAdapters.FlatsTableAdapter adapter = new RealStateDSTableAdapters.FlatsTableAdapter(); string PictureURL = adapter.GetPictureByFlatID(FlatID); ProcessDelete(FolderPath); ProcessDelete(FolderPath + "thumb_" + PictureURL); RealStateDS.FlatsDataTable T = adapter.GetPicturesByFlatID(FlatID); for (int i = 0; i < T.Rows.Count; i++) { ProcessDelete(FolderPath + T.Rows[i].ItemArray[7].ToString()); ProcessDelete(FolderPath + "thumb_" + T.Rows[i].ItemArray[7].ToString()); } }
protected void Button2_Click(object sender, EventArgs e) { try { RealStateDSTableAdapters.FlatsTableAdapter adapter = new RealStateDSTableAdapters.FlatsTableAdapter(); adapter.DeleteFav(Convert.ToInt32(this.GridView1.SelectedValue.ToString()), this.User.Identity.Name); GridView1.DataSource = adapter.GetDataByUserName(this.User.Identity.Name); GridView1.DataBind(); } catch { this.Label1Error.Visible = true; this.Label1Error.Text = "Select A Flat First!"; } finally { } }
protected void ButtonDeleteRecord_Click(object sender, EventArgs e) { Image MyImage = (Image)this.DetailsView1.FindControl("Image1"); Tools T = new Tools(); string ImageName = MyImage.ImageUrl; if (MyImage.ImageUrl != null) { int index = MyImage.ImageUrl.LastIndexOf('/'); ImageName = MyImage.ImageUrl.Substring(index + 1); T.DeleteFile(ImageName); } string query = this.Request.QueryString.ToString(); int CharIndex = query.IndexOf('='); query = query.Substring(++CharIndex); int FlatID = Convert.ToInt32(query); RealStateDSTableAdapters.FlatsTableAdapter A = new RealStateDSTableAdapters.FlatsTableAdapter(); A.DeletePicture(FlatID, ImageName); this.DetailsView1.DataBind(); }