protected void btnBuscarZona_Click(object sender, EventArgs e) { Zonas zona = null; string dep = ddlDepa.SelectedValue; if (String.IsNullOrWhiteSpace(txtLoca.Text)) { mostrarMensajeError("Debe indcar la localidad."); return; } string loc = txtLoca.Text; InterfaceLogicaZona inter = FabricaLogica.GetLogicaZona(); zona = inter.Buscar(dep, loc); if (zona == null) { lblZona.Text = "No se encontro la Zona"; return; } else { lblZona.Text = zona.Nombre; } }
protected void gvservicios_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { string departamento = txtdepartamento.Text; string localidad = txtlocalidad.Text; try { Zonas unaZona = FabricaLogica.GetLogicaZona().Buscar(departamento, localidad); gvservicios.EditIndex = -1; if (unaZona == null) { gvservicios.DataSource = Session["ListaNueva"]; gvservicios.DataBind(); } else { gvservicios.DataSource = Session["Lista"]; gvservicios.DataBind(); } } catch { mostrarMensajeError("Ocurrió un problema al cancelar la modificación del Servicio."); return; } }
protected void btneliminar_Click(object sender, EventArgs e) { string departamento = ""; string localidad = ""; string nombre = ""; int habitantes = 0; List <string> oLista = (List <string>)Session["Lista"]; if (txtdepartamento.Text.Trim().Length != 0) { departamento = txtdepartamento.Text; } else { mostrarMensajeError("Ingrese el departamento.<br>"); return; } if (txtlocalidad.Text.Trim().Length != 0) { localidad = txtlocalidad.Text; } else { mostrarMensajeError("Ingrese la localidad.<br>"); return; } if (txtnombre.Text.Trim().Length != 0) { nombre = txtnombre.Text; } else { mostrarMensajeError("Ingrese el nombre<br>"); return; } try { habitantes = Convert.ToInt32(txthabitantes.Text); } catch { mostrarMensajeError("Ingrese los habitantes<br>"); return; } Zonas unaZona = null; try { unaZona = new Zonas(departamento, localidad, nombre, habitantes, oLista); FabricaLogica.GetLogicaZona().Eliminar(unaZona); lblerror.Text = "La zona fue eliminada con éxito"; LimpiarFormulario(); } catch (ExcepcionPersonalizada ex) { mostrarMensajeError(ex.Message); return; } catch { mostrarMensajeError("Ocurrió un problema al eliminar la Zona."); return; } }
protected void btnbuscar_Click(object sender, EventArgs e) { string departamento = ""; string localidad = ""; if (txtdepartamento.Text.Trim().Length != 0) { departamento = txtdepartamento.Text; } else { mostrarMensajeError("Ingrese el departamento.<br>"); return; } if (txtlocalidad.Text.Trim().Length != 0) { localidad = txtlocalidad.Text; } else { mostrarMensajeError("Ingrese la localidad.<br>"); return; } Zonas unaZona = null; try { unaZona = FabricaLogica.GetLogicaZona().BuscarHabilitada(departamento, localidad); } catch (ExcepcionPersonalizada ex) { if (ex.Message == "Esta zona fue dada de baja.") { btnsumar.Enabled = true; btnagregar.Enabled = true; btnbuscar.Enabled = false; txtnombre.Enabled = true; txtnuevoserv.Enabled = true; txthabitantes.Enabled = true; lblerror.Text = "Esta zona fue dada de baja, pude darla de alta."; return; } else { mostrarMensajeError(ex.Message); return; } } catch { mostrarMensajeError("Ocurrió un problema al buscar la Zona."); return; } if (unaZona == null) { lblerror.Text = "No se encontró la zona, puede agregarla ahora."; txtdepartamento.Enabled = false; txtlocalidad.Enabled = false; btnsumar.Enabled = true; btnagregar.Enabled = true; txthabitantes.Enabled = true; txtnombre.Enabled = true; txtnuevoserv.Enabled = true; } else { txtnombre.Enabled = true; txtnombre.Text = unaZona.Nombre; txthabitantes.Enabled = true; txthabitantes.Text = Convert.ToString(unaZona.Habitantes); txtnuevoserv.Enabled = true; btneliminar.Enabled = true; btnmodificar.Enabled = true; btnsumar.Enabled = true; if (unaZona.Servicios.Count > 0) { gvservicios.DataSource = unaZona.Servicios; gvservicios.DataBind(); Session["Lista"] = unaZona.Servicios; } else { gvservicios.DataSourceID = null; gvservicios.DataSource = null; gvservicios.DataBind(); gvservicios.Visible = false; lblerror.Text = "Esta zona no tiene servicios agregados."; } } }
protected Apartamento CargarApartamento() { int padron; string direccion = txtDireccion.Text; string accion = ddlAccion.SelectedValue; int precio; double tamaño; int habitacion; int baños; int piso; bool ascensor = false; Empleado empleado = null; Zonas zona = null; if (String.IsNullOrWhiteSpace(txtLoca.Text)) { throw new ExcepcionPersonalizada("Debe indcar la localidad."); } string dep = ddlDepa.SelectedValue; string loc = txtLoca.Text; try { empleado = (Empleado)Session["USER"]; } catch (ExcepcionPersonalizada ex) { throw ex; } catch { throw new ExcepcionPersonalizada("Ocurrio un problema al buscar al empleado"); } try { InterfaceLogicaZona inter = FabricaLogica.GetLogicaZona(); zona = inter.Buscar(dep, loc); if (zona == null) { throw new ExcepcionPersonalizada("Debe ingresar una zona valida."); } } catch (ExcepcionPersonalizada ex) { throw ex; } catch { throw new ExcepcionPersonalizada("Ocurrio un problema al buscar la zona"); } try { padron = Convert.ToInt32(txtPadron.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El Padron debe ser un numero entero."); } try { precio = Convert.ToInt32(txtPrecio.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El Precio debe ser un numero entero."); } try { tamaño = Convert.ToDouble(txtTamaño.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El Tamaño debe ser un numero decimal."); } try { habitacion = Convert.ToInt32(txtHabitacion.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El numero de habitaciones debe ser un numero entero."); } try { baños = Convert.ToInt32(txtBaño.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El numero de baños debe ser un numero entero."); } try { piso = Convert.ToInt32(txtPiso.Text); } catch (FormatException) { throw new ExcepcionPersonalizada("El Piso debe ser un numero entero."); } if (rbtnSi.Checked) { ascensor = true; } Apartamento apartamento = new Apartamento(padron, direccion, precio, accion, baños, habitacion, tamaño, piso, ascensor, empleado, zona); return(apartamento); }