protected void btnGuardar_OnClick(object sender, EventArgs e) { try { if (txtDescripcionAreas.Text.Trim() == string.Empty) { throw new Exception("Debe especificar una descripción"); } Area area = new Area(); area.Descripcion = txtDescripcionAreas.Text.Trim(); if (Session["ImagenArea"] != null) { if (Session["ImagenArea"].ToString() != string.Empty) { area.Imagen = BusinessFile.Imagenes.ImageToByteArray(Session["ImagenArea"].ToString()); } } area.Habilitado = true; if (EsAlta) { area.IdUsuarioAlta = ((Usuario)Session["UserData"]).Id; _servicioArea.Guardar(area); _mp.AlertaSucces(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.Exito)); } else { area.IdUsuarioModifico = ((Usuario)Session["UserData"]).Id; _servicioArea.Actualizar(int.Parse(hfIdArea.Value), area); _mp.AlertaSucces(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.Actualizacion)); } LimpiarCampos(); if (!EsAlta) { if (OnAceptarModal != null) { OnAceptarModal(); } } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void btnGuardar_OnClick(object sender, EventArgs e) { try { if (ddlTipoUsuario.SelectedIndex == BusinessVariables.ComboBoxCatalogo.IndexSeleccione) { throw new Exception(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.FaltaTipoUsuario)); } if (txtDescripcionPuesto.Text.Trim() == string.Empty) { throw new Exception(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.FaltaDescripcion)); } Puesto puesto = new Puesto { IdTipoUsuario = int.Parse(ddlTipoUsuario.SelectedValue), Descripcion = txtDescripcionPuesto.Text.Trim(), Habilitado = true }; if (EsAlta) { _servicioPuesto.Guardar(puesto); mp.AlertaSucces(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.Exito)); } else { _servicioPuesto.Actualizar(int.Parse(hfIdPuesto.Value), puesto); mp.AlertaSucces(BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.Actualizacion)); } LimpiarCampos(); if (!EsAlta || !ddlTipoUsuario.Enabled) { btnTerminar_OnClick(btnTerminar, null); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
public void AlertaError(string value = "") { value = value.Trim() == string.Empty ? BusinessErrores.ObtenerMensajeByKey(BusinessVariables.EnumMensajes.Exito) : value; ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ScriptErrorAlert", "ErrorAlert('','" + value + "');", true); }