public async Task <IHttpActionResult> PutPERSONAS(int id, PERSONAS pERSONAS) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != pERSONAS.IDPERSONA) { return(BadRequest()); } db.Entry(pERSONAS).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PERSONASExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected void BtnGuardar_Click(object sender, EventArgs e) { List <DCPERSONAS> lstPERSONAS = new List <DCPERSONAS>(); DataTable DTPERSONAS = new DataTable(); PERSONASELECCIONADA = PERSONAS.PERSONASObtenerbyCriterio(txt_NumeroId.Text, 0); Session["PERSONACERSELECCIONADA"] = PERSONASELECCIONADA; if (PERSONASELECCIONADA.Count == 0) { PERSONAS.PERSONASRegistrar(0, txt_NumeroId.Text, cbo_tipoId.SelectedItem.Text, Convert.ToDateTime(dtpFechaExpedicion.Text), Convert.ToDateTime(dtpFechaNacimiento.Text), txt_nombres.Text.ToUpper(), txt_apellidos.Text.ToUpper(), txtDireccion.Text, cboPais.SelectedItem.Text, cboDepto.SelectedItem.Text, cboCiudad.SelectedItem.Text, TextCorreoElectronico.Text, cboGenero.SelectedItem.Text, txtTelefono.Text, txtCelular.Text, "PERSONA", "SI", 0, DateTime.Now, 0, DateTime.Now); //string script = " $.growl.notice({ title: 'Registro Exitoso',message: '' });"; //ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); Alerta.notiffy("Registro Exitoso", "Se ha registrado correctamenta en la BD, los datos de la persona", "sucessful", this, GetType()); } else { //string script = "alert(\"No se ha podido agregar la persona pues el numero de identificación ya existe!\");"; //ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); Alerta.notiffy("Operacion incompleta", "No se ha podido agregar la persona, el numero de identificación ya existe!", "warning", this, GetType()); } }
public ActionResult Enter(int user, string pwd) { try { using (carcenterEntities db = new carcenterEntities()) { var lst = from p in db.PERSONAS where p.IDENTIFICACION == user && p.CONTRASENA == pwd select p; if (lst.Count() > 0) { PERSONAS oPersona = lst.First(); Session["User"] = oPersona; return(Content("1")); } else { return(Content("Usuario o Contraseña Incorrectos")); } } } catch (Exception ex) { return(Content("Ocurrió un error :( " + ex.Message)); } }
public ActionResult Edit([Bind(Include = "ID_PERSONA,ID_NACIONALIDAD,RUT,DV,NOMBRE,APELLIDOMATERNO,APELLIDOPATERNO,INACTIVO,PASAPORTE,FECHAINDUCCION")] PERSONAS pERSONAS) { if (ModelState.IsValid) { String rutaux; rutaux = pERSONAS.RUT.ToString() + "-" + pERSONAS.DV; if (!BOL.Helpers.Util.RutValido(rutaux) && rutaux != "") { ViewBag.Error = "Rut con Formato Incorrecto"; } else if (pERSONAS.PASAPORTE == "" && rutaux == "") { ViewBag.Error = "Es obligacion Registrar Pasaporte o Rut"; } else { db.Entry(pERSONAS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.ID_NACIONALIDAD = new SelectList(db.NACIONALIDADES, "ID_NACIONALIDAD", "NACIONALIDAD", pERSONAS.ID_NACIONALIDAD); return(View(pERSONAS)); }
public ActionResult Create(PERSONAS persona) { string mensaje = ""; try { mensaje = "Registro agregado satisfactoriamente"; using (UnidadDeTrabajo <PERSONAS> unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { unidad.genericDAL.Add(persona); if (!unidad.Complete()) { TempData["mensaje"] = "El registro ya existe"; return(RedirectToAction("Create")); } } } catch (Exception ex) { mensaje = ex.ToString(); } TempData["mensaje"] = mensaje; return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID_PERSONA,ID_NACIONALIDAD,RUT,DV,NOMBRE,APELLIDOMATERNO,APELLIDOPATERNO,INACTIVO,PASAPORTE,FECHAINDUCCION")] PERSONAS pERSONAS) { if (ModelState.IsValid) { String rutaux; rutaux = pERSONAS.RUT.ToString() + "-" + pERSONAS.DV; if (DAL.PersonasDAL.GetPersona(pERSONAS.RUT) != null) { ViewBag.Error = "Ya existe una persona con el rut"; } else { if (!BOL.Helpers.Util.RutValido(rutaux)) { ViewBag.Error = "Rut con Formato Incorrecto"; } else { try { pERSONAS.NOMBRE = pERSONAS.NOMBRE.ToUpper(); pERSONAS.APELLIDOPATERNO = pERSONAS.APELLIDOPATERNO.ToUpper(); pERSONAS.APELLIDOMATERNO = pERSONAS.APELLIDOMATERNO.ToUpper(); db.PERSONAS.Add(pERSONAS); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message.ToString(); } //catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException ex) //{ // ViewBag.Error = ex.InnerException; //} //catch (System.Data.Entity.Core.EntityCommandCompilationException ex) //{ // ViewBag.Error = ex.InnerException; //} //catch (System.Data.Entity.Core.UpdateException ex) //{ // ViewBag.Error = ex.InnerException; //} //catch (System.Data.Entity.Infrastructure.DbUpdateException ex) //DbContext //{ // ViewBag.Error = ex.InnerException; //} } } } ViewBag.ID_NACIONALIDAD = new SelectList(db.NACIONALIDADES, "ID_NACIONALIDAD", "NACIONALIDAD", pERSONAS.ID_NACIONALIDAD); return(View(pERSONAS)); }
public ActionResult DeleteConfirmed(int id) { PERSONAS pERSONAS = db.PERSONAS.Find(id); db.PERSONAS.Remove(pERSONAS); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Register(UsuarioViewModel usuarioViewModel) { usuarioViewModel.usuario = Request["usuario"]; usuarioViewModel.contrasenia = Request["contrasenia"]; PERSONAS p; List <PERSONAS> listP; string id; using (UnidadDeTrabajo <PERSONAS> Unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { listP = Unidad.genericDAL.GetAll().ToList(); id = this.RandomString(12); foreach (var item in listP) { while (id == item.numeroIdentificacion) { id = this.RandomString(12); //genero una cedula unica } } p = new PERSONAS { correoElectronico = "generico", estado = 1, genero = 1, nacionalidad = 1, numeroIdentificacion = id, nombrePersona = "generico", segundoApellido = "generico", telefono = "generico", primerApellido = "generico", }; Unidad.genericDAL.Add(p);//creo una persona Unidad.Complete(); } int ide = 0; using (UnidadDeTrabajo <PERSONAS> Unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { listP = Unidad.genericDAL.GetAll().ToList(); foreach (var item in listP) { if (item.numeroIdentificacion == id) { ide = item.idPersona; //obtengo id de la persona } } Unidad.Complete(); } using (UnidadDeTrabajo <USUARIOS> Unidad = new UnidadDeTrabajo <USUARIOS>(new BDContext())) { usuarioViewModel.idPersona = ide; Unidad.genericDAL.Add(this.Convertir(usuarioViewModel)); Unidad.Complete(); } return(RedirectToAction("Index", "Login")); }
public async Task <ActionResult> DeleteConfirmed(long id) { PERSONAS pERSONAS = await db.PERSONAS.FindAsync(id); db.PERSONAS.Remove(pERSONAS); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> GetPERSONAS(int id) { PERSONAS pERSONAS = await db.PERSONAS.FindAsync(id); if (pERSONAS == null) { return(NotFound()); } return(Ok(pERSONAS)); }
public ActionResult Edit([Bind(Include = "IDPERSONA,SEUDONIMO,NOMBRES,APELLIDOS,EMAIL,IDPERFIL")] PERSONAS pERSONAS) { if (ModelState.IsValid) { db.Entry(pERSONAS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDPERFIL = new SelectList(db.PERFILES, "IDPERFIL", "NOMBRE", pERSONAS.IDPERFIL); return(View(pERSONAS)); }
public async Task <ActionResult> Edit([Bind(Include = "ID_PERSONA,PRIMER_NOMBRE,SEGUNDO_NOMBRE,PRIMER_APELLIDO,SEGUNDO_APELLIDO,TIPO_IDENTIFICACION,IDENTIFICACION,NO_CELULAR,DIRECCION,CORREO_ELECTRONICO")] PERSONAS pERSONAS) { if (ModelState.IsValid) { db.Entry(pERSONAS).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(pERSONAS)); }
public ActionResult Edit([Bind(Include = "IDPersona,Nombre,Apellido1,Apellido2,Telefono,Email,Rol,IDTerritorio")] PERSONAS pERSONAS) { if (ModelState.IsValid) { db.Entry(pERSONAS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IDTerritorio = new SelectList(db.TERRITORIOS, "IDTerritorio", "Comite", pERSONAS.IDTerritorio); return(View(pERSONAS)); }
public void TestDeleteGeneric() { PERSONAS x = new PERSONAS(); using (UnidadDeTrabajo <PERSONAS> Unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { x = Unidad.genericDAL.Get(2); Unidad.genericDAL.Remove(x); Assert.AreEqual(true, Unidad.Complete()); } }
public async Task <IHttpActionResult> PostPERSONAS(PERSONAS pERSONAS) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PERSONAS.Add(pERSONAS); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = pERSONAS.IDPERSONA }, pERSONAS)); }
public async Task <IHttpActionResult> DeletePERSONAS(int id) { PERSONAS pERSONAS = await db.PERSONAS.FindAsync(id); if (pERSONAS == null) { return(NotFound()); } db.PERSONAS.Remove(pERSONAS); await db.SaveChangesAsync(); return(Ok(pERSONAS)); }
private void PickerVisitaA_SelectedIndexChanged(object sender, EventArgs e)// Metodo del evento Change del picker, es decir si selecciono un item del picker este lo tomara { try { var selected = pickerVisitaA.SelectedItem as PERSONAS; //Preferences.Set("PERSONA_SELECTED", selected.NOMBRES_APELLIDOS.ToString()); //Preferences.Set("ID_PERSONA_SELECTED", selected.PERSONA_ID.ToString()); this.persona = selected; } catch (Exception ex) { Debug.WriteLine("Exception catched while trying to set preference \"COMPANIA_SELECTED\": " + ex); } }
// GET: Personas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PERSONAS pERSONAS = db.PERSONAS.Find(id); if (pERSONAS == null) { return(HttpNotFound()); } return(View(pERSONAS)); }
// GET: PERSONAS/Delete/5 public async Task <ActionResult> Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PERSONAS pERSONAS = await db.PERSONAS.FindAsync(id); if (pERSONAS == null) { return(HttpNotFound()); } return(View(pERSONAS)); }
public JsonResult GuardaPersona(int nacionalidad, int rut, string dv, string nombre, string paterno, string materno, string pasaporte, string fechainduccion) { var respuesta = new { mensaje = "" }; try { CaboFroward2018Entities db = new CaboFroward2018Entities(); PERSONAS p = new PERSONAS(); p.ID_NACIONALIDAD = nacionalidad; p.RUT = rut; p.DV = dv; p.NOMBRE = nombre; p.APELLIDOMATERNO = materno; p.APELLIDOPATERNO = paterno; p.PASAPORTE = pasaporte; DateTime fecha; if (DateTime.TryParse(fechainduccion, out fecha)) { p.FECHAINDUCCION = DateTime.Parse(fechainduccion); } if (DAL.PersonasDAL.GetPersonaInactiva(rut) != null && rut != 0) { respuesta = new { mensaje = "Rut ya existe,valide vigencia de persona" }; return(Json(respuesta)); } db.PERSONAS.Add(p); db.SaveChanges(); db.Dispose(); respuesta = new { mensaje = "" }; return(Json(respuesta)); } catch (Exception ex) { respuesta = new { mensaje = "Error al crear Persona" + ex.InnerException.ToString() }; return(Json(respuesta)); } }
// GET: PERSONAS/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PERSONAS pERSONAS = db.PERSONAS.Find(id); if (pERSONAS == null) { return(HttpNotFound()); } ViewBag.IDTerritorio = new SelectList(db.TERRITORIOS, "IDTerritorio", "Comite", pERSONAS.IDTerritorio); return(View(pERSONAS)); }
// GET: PERSONAS/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PERSONAS pERSONAS = db.PERSONAS.Find(id); if (pERSONAS == null) { return(HttpNotFound()); } ViewBag.IDPERFIL = new SelectList(db.PERFILES, "IDPERFIL", "NOMBRE", pERSONAS.IDPERFIL); return(View(pERSONAS)); }
// GET: Personas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PERSONAS pERSONAS = db.PERSONAS.Find(id); if (pERSONAS == null) { return(HttpNotFound()); } ViewBag.ID_NACIONALIDAD = new SelectList(db.NACIONALIDADES, "ID_NACIONALIDAD", "NACIONALIDAD", pERSONAS.ID_NACIONALIDAD); return(View(pERSONAS)); }
private PERSONAS Convertir(PersonaViewModel personaViewModel) { PERSONAS persona = new PERSONAS { idPersona = personaViewModel.idPersona, numeroIdentificacion = personaViewModel.numeroIdentificacion, nombrePersona = personaViewModel.nombrePersona, primerApellido = personaViewModel.primerApellido, segundoApellido = personaViewModel.segundoApellido, genero = personaViewModel.genero, estado = personaViewModel.estado, nacionalidad = personaViewModel.nacionalidad, correoElectronico = personaViewModel.correoElectronico, telefono = personaViewModel.telefono, direccionResidencia = personaViewModel.direccionResidencia }; return(persona); }
public ActionResult Edit(PERSONAS persona) { string mensaje = ""; try { using (UnidadDeTrabajo <PERSONAS> unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { unidad.genericDAL.Update(persona); unidad.Complete(); mensaje = "Registro modificado satisfactoriamente"; } } catch (Exception ex) { mensaje = ex.ToString(); } TempData["mensaje"] = mensaje; return(RedirectToAction("Index")); }
public void CARGARGRILLA3() { List <DCPERSONAS> dt = new List <DCPERSONAS>(); dt = PERSONAS.PERSONASObtener(0); GrdVw_Personas.Visible = false; if (dt.Count > 0) { GrdVw_Personas.Visible = true; GrdVw_Personas.DataSource = null; GrdVw_Personas.DataBind(); GrdVw_Personas.DataSource = dt; GrdVw_Personas.DataBind(); } else { GrdVw_Personas.Visible = false; GrdVw_Personas.DataSource = null; GrdVw_Personas.DataBind(); } }
public void TestAddGeneric() { PERSONAS x = new PERSONAS { numeroIdentificacion = "222222", nombrePersona = "jordan", primerApellido = "jordan", segundoApellido = "jordan", genero = 1, estado = 3, nacionalidad = 2, correoElectronico = "*****@*****.**", telefono = "898998" }; using (UnidadDeTrabajo <PERSONAS> Unidad = new UnidadDeTrabajo <PERSONAS>(new BDContext())) { Unidad.genericDAL.Add(x); Assert.AreEqual(true, Unidad.Complete()); } }
protected void GrdVw_Personas_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Editar")) { int index = Convert.ToInt32(e.CommandArgument); string code = GrdVw_Personas.DataKeys[index].Value.ToString(); PERSONASELECCIONADA = PERSONAS.PERSONASObtenerbyIDPERSONA(Convert.ToDecimal(code), 0); Session["PERSONASELECCIONADA"] = PERSONASELECCIONADA; txtCelular.Text = PERSONASELECCIONADA[0].MOVIL; txtDireccion.Text = PERSONASELECCIONADA[0].DIRECCION; txtTelefono.Text = PERSONASELECCIONADA[0].TELEFONO; txt_apellidos.Text = PERSONASELECCIONADA[0].APELLIDOS; txt_nombres.Text = PERSONASELECCIONADA[0].NOMBRE; txt_NumeroId.Text = PERSONASELECCIONADA[0].IDENTIFICACION; TextCorreoElectronico.Text = PERSONASELECCIONADA[0].CORREO; cboCiudad.SelectedValue = PERSONASELECCIONADA[0].CIUDAD; cboDepto.SelectedValue = PERSONASELECCIONADA[0].DEPTO; cboGenero.SelectedValue = PERSONASELECCIONADA[0].GENERO; cboPais.SelectedValue = PERSONASELECCIONADA[0].PAIS; cbo_tipoId.SelectedValue = PERSONASELECCIONADA[0].TIPOIDENTIFICACION; dtpFechaExpedicion.Text = PERSONASELECCIONADA[0].FECHAEXPEDICION.ToShortDateString(); dtpFechaNacimiento.Text = PERSONASELECCIONADA[0].FECHAEXPEDICION.ToShortDateString(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#myModal').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModalScript", sb.ToString(), false); } else if (e.CommandName.Equals("Eliminar")) { int index = Convert.ToInt32(e.CommandArgument); Decimal code = Convert.ToDecimal(GrdVw_Personas.DataKeys[index].Value); bool _actualizado; _actualizado = PERSONAS.PERSONASEliminarbyIDPERSONA(code, 0, DateTime.Now); if (_actualizado == true) { CARGARGRILLA3(); Alerta.notiffy("Eliminación Exitosa", "Se ha Eliminado correctamente la persona", "sucessful", this, GetType()); } else { Alerta.notiffy("Operacion incompleta", "No se ha podido Eliminar la persona!", "warning", this, GetType()); } } else if (e.CommandName.Equals("Detalle")) { int index = Convert.ToInt32(e.CommandArgument); string code = GrdVw_Personas.DataKeys[index].Value.ToString(); PERSONASELECCIONADA = PERSONAS.PERSONASObtenerbyIDPERSONA(Convert.ToDecimal(code), 0); Session["PERSONASELECCIONADA"] = PERSONASELECCIONADA; LblIDPERSONA.InnerText = PERSONASELECCIONADA[0].IDPERSONA.ToString(); LblIDENTIFICACION.InnerText = PERSONASELECCIONADA[0].IDENTIFICACION; LblTIPOIDENTIFICACION.InnerText = PERSONASELECCIONADA[0].TIPOIDENTIFICACION; LblFECHAEXPEDICION.InnerText = PERSONASELECCIONADA[0].FECHAEXPEDICION.ToString(); LblFECHANACIMIENTO.InnerText = PERSONASELECCIONADA[0].FECHANACIMIENTO.ToString(); LblNOMBRE.InnerText = PERSONASELECCIONADA[0].NOMBRE; LblApellidos.InnerText = PERSONASELECCIONADA[0].APELLIDOS; LblDIRECCION.InnerText = PERSONASELECCIONADA[0].DIRECCION; LblPAIS.InnerText = PERSONASELECCIONADA[0].PAIS; LblDEPTO.InnerText = PERSONASELECCIONADA[0].DEPTO; LblCIUDAD.InnerText = PERSONASELECCIONADA[0].CIUDAD; LblCORREO.InnerText = PERSONASELECCIONADA[0].CORREO; LblGENERO.InnerText = PERSONASELECCIONADA[0].GENERO; LblTELEFONO.InnerText = PERSONASELECCIONADA[0].TELEFONO; LblMOVIL.InnerText = PERSONASELECCIONADA[0].MOVIL; LblIDUSUARIOCREO.InnerText = PERSONASELECCIONADA[0].IDUSUARIOCREO.ToString(); LblFECHACREO.InnerText = PERSONASELECCIONADA[0].FECHACREO.ToString(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#myModalDetail').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModalScript", sb.ToString(), false); } }