public void CrearNotaOpcionUsuario(NotaOpcionUsuario notaOpcionUsuario) { try { using (BusinessNota negocio = new BusinessNota()) { negocio.CrearNotaOpcionUsuario(notaOpcionUsuario); } } catch (Exception e) { throw new Exception(e.Message); } }
public void CrearNotaOpcionUsuario(NotaOpcionUsuario notaOpcionUsuario) { DataBaseModelContext db = new DataBaseModelContext(); try { db.ContextOptions.ProxyCreationEnabled = _proxy; notaOpcionUsuario.Fecha = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture); notaOpcionUsuario.Habilitado = true; if (notaOpcionUsuario.Id == 0) { db.NotaOpcionUsuario.AddObject(notaOpcionUsuario); } db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { db.Dispose(); } }
protected void btnGuardar_OnClick(object sender, EventArgs e) { try { if (ddlTipoNota.SelectedIndex == BusinessVariables.ComboBoxCatalogo.IndexSeleccione) { throw new Exception("Debe especificar una tipo de nota"); } if (ddlArbol.SelectedIndex == BusinessVariables.ComboBoxCatalogo.IndexSeleccione) { throw new Exception("Debe especificar una opcion para esta nota"); } if (txtNombreNotaGralUsuario.Text.Trim() == string.Empty) { throw new Exception("Debe especificar un nombre"); } if (txtEditor.Text.Trim() == string.Empty) { throw new Exception("Debe especificar un contenido"); } if (EsAlta) { if (chkCompartir.Checked) { NotaOpcionGrupo nota = new NotaOpcionGrupo { IdTipoNota = int.Parse(ddlTipoNota.SelectedValue), IdArbolAcceso = int.Parse(ddlArbol.SelectedValue), IdUsuario = ((Usuario)Session["UserData"]).Id, Nombre = txtNombreNotaGralUsuario.Text.Trim(), Contenido = txtEditor.Text.Trim() }; _servicioNota.CrearNotaOpcionGrupo(nota); } else { NotaOpcionUsuario nota = new NotaOpcionUsuario { IdTipoNota = int.Parse(ddlTipoNota.SelectedValue), IdArbolAcceso = int.Parse(ddlArbol.SelectedValue), IdUsuario = ((Usuario)Session["UserData"]).Id, Nombre = txtNombreNotaGralUsuario.Text.Trim(), Contenido = txtEditor.Text.Trim() }; _servicioNota.CrearNotaOpcionUsuario(nota); } } //else // _servicioArea.Actualizar(int.Parse(hfIdArea.Value), area); LimpiarCampos(); if (OnAceptarModal != null) { OnAceptarModal(); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }