protected void btnOpcion_Click(object sender, EventArgs e) { if (ddlOpciones.SelectedIndex == 0) { } else if (ddlOpciones.SelectedIndex == 1) { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Session["UserID"].ToString()) { Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); Response.Redirect("ModificarPropiedad.aspx"); } } else if (ddlOpciones.SelectedIndex == 2) { dt = (DataTable)Session["grd_ItemList2"]; //if (dt.Rows[0]["IdUsuario"].ToString() == Session["UserID"].ToString()) //{ Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); Response.Redirect("AltaImagen.aspx"); //} } else if (ddlOpciones.SelectedIndex == 3) { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Session["UserID"].ToString()) { Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); InmueblesBLL bllInmuebles = new InmueblesBLL(); bllInmuebles.Delete(Session["IdInmueble"].ToString()); for (int i = 1; i <= 10; i++) { try { File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + ".jpg")); File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + "_thumb.jpg")); } catch { } } Response.Redirect("MisPropiedades.aspx"); } } }
protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e) { //CalcularSesion(); if (e.CommandName == "Editar") { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Membership.GetUser().ProviderUserKey.ToString()) { Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); Response.Redirect("ModificarPropiedad.aspx"); } } else if (e.CommandName == "Eliminar") { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Membership.GetUser().ProviderUserKey.ToString()) { //Response.Write("<script>window.alert('Hola');</script>"); //Response.Redirect("ModificarPropiedad.aspx?id=" // + dt.Rows[0]["IdInmueble"].ToString()); //CalcularSesion(); Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); InmueblesBLL bllInmuebles = new InmueblesBLL(); bllInmuebles.Delete(Session["IdInmueble"].ToString()); for (int i = 1; i <= 10; i++) { try { File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + ".jpg")); File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + "_thumb.jpg")); } catch { } } Response.Redirect("MisPropiedades.aspx"); } } }
protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e) { if (e.CommandName == "Editar") { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Session["UserID"].ToString()) { Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); Response.Redirect("ModificarPropiedad.aspx"); } } else if (e.CommandName == "Eliminar") { dt = (DataTable)Session["grd_ItemList2"]; if (dt.Rows[0]["IdUsuario"].ToString() == Session["UserID"].ToString()) { Session["IdInmueble"] = dt.Rows[0]["IdInmueble"].ToString(); InmueblesBLL bllInmuebles = new InmueblesBLL(); bllInmuebles.Delete(Session["IdInmueble"].ToString()); for (int i = 1; i <= 10; i++) { try { File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + ".jpg")); File.Delete(Server.MapPath("~\\Image_Upload\\" + Session["IdInmueble"].ToString() + "-" + i + "_thumb.jpg")); } catch { } } Response.Redirect("MisPropiedades.aspx"); } } }
protected void btnEliminar_Click(object sender, EventArgs e) { if (gvInmuebles.SelectedIndex != -1) { InmueblesBLL bllInmuebles = new InmueblesBLL(); bllInmuebles.Delete(gvInmuebles.SelectedValue.ToString()); for (int i = 1; i <= 10; i++) { try { File.Delete(Server.MapPath("~\\Image_Upload\\" + gvInmuebles.SelectedValue.ToString() + "-" + i + ".jpg")); File.Delete(Server.MapPath("~\\Image_Upload\\" + gvInmuebles.SelectedValue.ToString() + "-" + i + "_thumb.jpg")); } catch { } } IniciaGridView(); } }