protected void grResultado_RowCommand(object sender, GridViewCommandEventArgs e) { sitio = new localhost.SitioBO(); if (e.CommandName == "SELECT") { indice = Convert.ToInt32(e.CommandArgument); Session["Id"] = Convert.ToInt32(grResultado.Rows[indice].Cells[0].Text); txtNombre.Text = HttpUtility.HtmlDecode(grResultado.Rows[indice].Cells[1].Text); txtDescripcion.Text = HttpUtility.HtmlDecode(grResultado.Rows[indice].Cells[2].Text); txtDireccion.Text = HttpUtility.HtmlDecode(grResultado.Rows[indice].Cells[3].Text); ddlEstatus.SelectedValue = HttpUtility.HtmlDecode(grResultado.Rows[indice].Cells[4].Text); Session["Id"] = Convert.ToInt32(grResultado.Rows[indice].Cells[0].Text); sitio.IdSitio = Convert.ToInt32(grResultado.Rows[indice].Cells[0].Text); latitude.Text = servicio.BuscarSitioDAO(sitio).Rows[0].ItemArray[6].ToString(); longitude.Text = servicio.BuscarSitioDAO(sitio).Rows[0].ItemArray[7].ToString(); //Session["IdU"] =Convert.ToInt32(servicio.BuscarUbicacionesDAO(Ubicacion).Rows[0].ItemArray[0].ToString()); try { //Foto.IdSitio = (int)Session["Id"]; //FileUpload1. = servicio.BuscarFotoDAO(Foto).Rows[0].ItemArray[1]; } catch { } } if (e.CommandName == "Delete") { indice = Convert.ToInt32(e.CommandArgument); sitio.IdSitio = Convert.ToInt32(grResultado.Rows[indice].Cells[0].Text); Foto.IdSitio = Convert.ToInt32(grResultado.Rows[indice].Cells[0].Text); try { Foto.IdFoto = Convert.ToInt32(servicio.BuscarFotoDAO(Foto).Rows[0].ItemArray[0].ToString()); servicio.EliminarFotoDAO(Foto); } catch { } try { servicio.EliminarSitioDAO(sitio); Mensaje("Se elimino exitosamente"); } catch { Mensaje("Ocurrio un error al eliminar intentelo más tarde"); } validarNumeroSitios(); sitio = new localhost.SitioBO(); llenarDataGrid(sitio); } }
public void limpiar() { txtNombre.Text = ""; //address.Text = ""; txtDescripcion.Text = ""; ddlEstatus.SelectedValue = "Activo"; FileUpload2 = null; latitude.Text = 20.96645955666419.ToString(); longitude.Text = (-89.62270814819334).ToString(); txtDireccion.Text = ""; sitio = new localhost.SitioBO(); llenarDataGrid(sitio); }
public void Agregar() { string Res = ValidarCampos(); llenarDatos(); if (Res.Trim().Length == 0) { int i = 0; try { i = servicio.agregarSitioDAO(sitio); } catch { i = 0; } if (i == 1) { if (FileUpload2.HasFile) { Foto.IdSitio = Convert.ToInt32(servicio.BuscarSitioDAO(sitio).Rows[0].ItemArray[0].ToString()); AgregarImagen(sitio.Nombre); Foto.Foto = FileUpload2.FileName.ToString() + sitio.Nombre; int j = servicio.agregarFotoDAO(Foto); if (j == 1) { Mensaje("Los datos se agregaron correctamente"); llenarDataGrid(sitio); limpiar(); } else { Mensaje("Error al agregar imagen intentalo más tarde"); } } else { Mensaje("La información del sitio se agrego correctamente"); } } else { Mensaje("Los datos no se agregaron, intenta de nuevo"); } sitio = new localhost.SitioBO(); llenarDataGrid(sitio); } }
public object llenarDatos() { sitio = new localhost.SitioBO(); US = (DataTable)Session["Usuarios"]; sitio.Nombre = txtNombre.Text; sitio.Descripcion = txtDescripcion.Text; sitio.Estatus = ddlEstatus.Text; sitio.IdEstablecimiento = Convert.ToInt32(DdlEstablecimiento.SelectedValue); sitio.Longitud = longitude.Text; sitio.Latitud = latitude.Text; sitio.Direccion = txtDireccion.Text; sitio.Idusuario = Convert.ToInt32(US.Rows[0].ItemArray[0]); return(sitio); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { sitio = new localhost.SitioBO(); llenarDataGrid(sitio); llenarddlTipos(); llenarddlEstablecimiento(); validarNumeroSitios(); US = (DataTable)Session["Usuarios"]; if (Convert.ToInt32(US.Rows[0].ItemArray[9]) != 1) { ddl.Visible = false; } } }