public ActionResult nuevoRegistro(RegistroViewModel input) { try{ if (ModelState.IsValid) { persona p = new persona(); p.email = input.email; p.password = input.contraseña; p.rol_id = 3; p.nombre_usuario = "anonimus"; p.token = Guid.NewGuid().ToString(); ViewBag.linkUrl = "?token=" + p.token; //VIewBag.urlLink = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/ConfirmAccount?token=" + token; MvcMailMessage mail = UserMailer.CorreoConfirmacion(p); mail.Send(); //(en constructor) db = new turismo_uvmEntities(); //luego para guardar db.persona.Add(p); db.SaveChanges(); return RedirectToAction("Terminos", new { Id = p.id }); } } catch (Exception e) { ModelState.AddModelError("email",e.Message); } return View(input); }
//metodo de insercion en la BD tomando parametro tipo entidad persona public void insertar(persona persona) { using (IglesiaBD dbCon = new IglesiaBD()) { dbCon.persona.Add(persona); dbCon.SaveChanges(); } }
//actulizar un registro existente public void actualizar(persona persona) { using (IglesiaBD dbCon = new IglesiaBD()) { dbCon.Entry(persona).State = EntityState.Modified; dbCon.SaveChanges(); } }
public void eliminar(persona persona) { using (IglesiaBD dbCon = new IglesiaBD()) { dbCon.Entry(persona).State = EntityState.Deleted; dbCon.SaveChanges(); } }
public ActionResult regcliente(ReservaHab reser) { DataClasses1DataContext db = new DataClasses1DataContext(); cliente cli = new cliente(); cli.nombre = reser.cli.Nombre; cli.ciudad = reser.cli.Ciudad; cli.estado = reser.cli.Estadoo; cli.pais = reser.cli.pais; cli.nit = reser.cli.nit; cli.telefono = reser.cli.telefono; cli.direccion = reser.cli.direccion; cli.email = reser.cli.email; cli.comentarios = reser.cli.comentarios; db.clientes.InsertOnSubmit(cli); db.SubmitChanges(); if (reser.tipocli == 1) { persona per = new persona(); per.id = cli.id; per.ci = reser.per.ci; per.apellido = reser.per.apellido;/* * string d = (reser.per.cumple).ToString(); * d = d.Substring(3, 3) + d.Substring(0, 3) + d.Substring(6, 4); * per.cumpleaños = Convert.ToDateTime(d);*/ per.cumpleaños = reser.per.cumple; per.pasaporte = reser.per.pasaporte; db.personas.InsertOnSubmit(per); db.SubmitChanges(); } if (reser.tipocli == 2) { empresa empp = new empresa(); empp.id = cli.id; empp.contacto = reser.emp.contacto; empp.metodopago = reser.emp.metodoPago; db.empresas.InsertOnSubmit(empp); db.SubmitChanges(); } if (reser.tipocli == 3) { agencia agenn = new agencia(); agenn.id = cli.id; agenn.contacto = reser.agen.contacto; db.agencias.InsertOnSubmit(agenn); db.SubmitChanges(); } return(View()); }
// GET: /Persona/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.personas.Find(id); if (persona == null) { return(HttpNotFound()); } return(View(persona)); }
static void Main(string[] args) { //ES UN PEQUEÑO CODIGO PARA PRACTICAR //SI HAY ALGUN ERROR POR FAVOR ME AYUDAN //AOENAS ESTOY INICIANDO EN EL MUNDO DE LA PROGRAMACION EN ESTE LENGUAJE String nombre1, nombre2, nombre3, nombre4, nombre5; Console.WriteLine("!BIENVENIDO¡"); Console.WriteLine(""); Console.WriteLine("DIGITE SU NOMBRE..."); nombre1 = Convert.ToString(Console.ReadLine()); Console.WriteLine(""); Console.WriteLine("DIGITE SU NOMBRE..."); nombre2 = Convert.ToString(Console.ReadLine()); Console.WriteLine(""); Console.WriteLine("DIGITE SU NOMBRE..."); nombre3 = Convert.ToString(Console.ReadLine()); Console.WriteLine(""); Console.WriteLine("DIGITE SU NOMBRE..."); nombre4 = Convert.ToString(Console.ReadLine()); Console.WriteLine(""); Console.WriteLine("DIGITE SU NOMBRE..."); nombre5 = Convert.ToString(Console.ReadLine()); Console.WriteLine(); persona[] personas = new persona[5]; personas[0] = new alumno(nombre1); personas[1] = new empleado(nombre2); personas[2] = new contador(nombre3); personas[3] = new profesor(nombre4); personas[4] = new abogado(nombre5); for (int i = 0; i < personas.Length; i++) { Console.WriteLine(personas[i].saludar()); } Console.ReadKey(); }
static void Main(string[] args) { persona per1 = new persona("Rolf", 11); persona per2 = new persona("Wolf", 10); persona per3 = new persona(); Console.Write("Persona #1: "); per1.PrintPers(); Console.Write("Persona #2: "); per2.PrintPers(); Console.Write("Persona #3: "); per3.PrintPers(); Console.ReadKey(); }
// GET: personas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.personas.Find(id); if (persona == null) { return(HttpNotFound()); } return(PartialView("Delete", persona)); }
// GET: personas/Details/5 public ActionResult Details(decimal id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } return(View(persona)); }
public async Task <ActionResult> Create([Bind(Include = "dni,nombre,apellido,celular,tipo,usuarioId")] persona persona) { if (ModelState.IsValid) { db.persona.Add(persona); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.tipo = new SelectList(db.tipo_persona, "id", "tipo_persona1", persona.tipo); ViewBag.usuarioId = new SelectList(db.User, "Id", "user1", persona.usuarioId); return(View(persona)); }
public IHttpActionResult Deletepersona(int id) { persona persona = db.personas.Find(id); if (persona == null) { return(NotFound()); } db.personas.Remove(persona); db.SaveChanges(); return(Ok(persona)); }
// GET: personas/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = await db.persona.FindAsync(id); if (persona == null) { return(HttpNotFound()); } return(View(persona)); }
public async Task <IHttpActionResult> Deletepersona(int id) { persona persona = await db.personas.FindAsync(id); if (persona == null) { return(NotFound()); } db.personas.Remove(persona); await db.SaveChangesAsync(); return(Ok(persona)); }
// GET: personas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.personas.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.idtipidocumento = new SelectList(db.tipodocumentoes, "idtipidocumento", "nombretipodocumento", persona.idtipidocumento); return(PartialView("Edit", persona)); }
public virtual MvcMailMessage CorreoConfirmacion(persona p) { ViewBag.persona = p; //le pasamos el objeto persona a la vista... //devuelve la vista poblada con datos... ViewBag.urlLink = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Registro/correoConfirmacion/?token=" + p.token; return Populate(x => { ViewBag.Name = p.nombre_usuario; x.ViewName = "CorreoConfirmacion" + p.nombreUsuario; //x.To.Add("*****@*****.**"); x.To.Add(p.email); x.Subject = "Confirmación de Correo"; }); }
// GET: persona/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.idEstado = new SelectList(db.estado, "idEstado", "nombre", persona.idEstado); return(View(persona)); }
public ActionResult Edit([Bind(Include = "idpersona,dni,nombre,apellido,fechanacimiento,direccion,idtipidocumento")] persona persona) { if (ModelState.IsValid) { db.Entry(persona).State = EntityState.Modified; db.SaveChanges(); var listPersonas = db.personas.Include(p => p.tipodocumento); return(PartialView("List", listPersonas.ToList())); } ViewBag.idtipidocumento = new SelectList(db.tipodocumentoes, "idtipidocumento", "nombretipodocumento", persona.idtipidocumento); var listPersona = db.personas.Include(p => p.tipodocumento); return(PartialView("List", listPersona.ToList())); }
// GET: personas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.usuario = new SelectList(db.usuario, "usuario1", "password", persona.usuario); return(View(persona)); }
public void borrar(persona persona) { DbContextTransaction dbTransaccion = SS_Contexto.Database.BeginTransaction(); try { SS_Contexto.persona.Remove(persona); SS_Contexto.SaveChanges(); dbTransaccion.Commit(); } catch (Exception ex) { dbTransaccion.Rollback(); throw new Exception(ex.ToString()); }//Fin del try-catch. }
// GET: persona/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.idTipo_Doc = new SelectList(db.tipo_documento, "idTipo_Doc", "Tipo_Documento1", persona.idTipo_Doc); ViewBag.id_Tipo_Vehiculo = new SelectList(db.tipo_vehiculo, "id_Tipo_vehiculo", "Tipo_vehiculo1", persona.id_Tipo_Vehiculo); return(View(persona)); }
public ActionResult eliminar(String ID) { int id = Convert.ToInt32(ID); DataClasses1DataContext db = new DataClasses1DataContext(); cliente c = db.clientes.Single(u => u.id == id); persona p = db.personas.Single(u => u.idCli == id); db.personas.DeleteOnSubmit(p); db.SubmitChanges(); db.clientes.DeleteOnSubmit(c); db.SubmitChanges(); return(Redirect("/Cliente/RegistroPersonas")); }
// GET: personas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.ID_CIUDAD_RESIDENCIA_PERSONA = new SelectList(db.ciudad, "ID_CIUDAD", "NOMBRE_CIUDAD", persona.ID_CIUDAD_RESIDENCIA_PERSONA); ViewBag.ID_SEXO_PERSONA = new SelectList(db.sexo, "ID_SEXO", "SEXO1", persona.ID_SEXO_PERSONA); return(View(persona)); }
// GET: personas/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = await db.persona.FindAsync(id); if (persona == null) { return(HttpNotFound()); } ViewBag.tipo = new SelectList(db.tipo_persona, "id", "tipo_persona1", persona.tipo); ViewBag.usuarioId = new SelectList(db.User, "Id", "user1", persona.usuarioId); return(View(persona)); }
// GET: personas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.idDistrito = new SelectList(db.distrito, "idDistrito", "idprovincia", persona.idDistrito); ViewBag.idtipoCuenta = new SelectList(db.tipoCuenta, "idtipoCuenta", "nombreTipoCuenta", persona.idtipoCuenta); return(View(persona)); }
// GET: personas/Edit/5 public ActionResult Edit(decimal id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(id); if (persona == null) { return(HttpNotFound()); } ViewBag.paisNacimiento = new SelectList(db.pais, "idPais", "nbrPais", persona.paisNacimiento); ViewBag.paisResidencia = new SelectList(db.pais, "idPais", "nbrPais", persona.paisResidencia); return(View(persona)); }
private void dtgPersonaDes_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (dtgPersonaDes.SelectedItem != null) { if (txtdescuento.Text.Equals("") && txtdexcuentobs.Text.Equals("")) { MessageBox.Show("Debe colocar porcentaje ó monto de descuento", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } persona p = dtgPersonaDes.SelectedItem as persona; if (p.IsSelected) { p.IsSelected = false; p.descuento = 0; p.total = p.monto; p.descuentob = 0; dtgPersonaDes.Items.Refresh(); } else { p.IsSelected = true; if (!txtdescuento.Text.Equals("")) { if (Convert.ToDouble(txtdescuento.Text) > 100) { MessageBox.Show("El porcentaje no puede ser mayor a 100%", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } p.descuento = Convert.ToDouble(txtdescuento.Text); p.descuentob = Math.Round(p.monto * (p.descuento / 100), 2); p.total = p.monto - p.descuentob; } else { if (Convert.ToDouble(txtdexcuentobs.Text) > p.monto) { MessageBox.Show("El monto a descontar no puede ser mayor al monto por persona", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } p.descuentob = Convert.ToDouble(txtdexcuentobs.Text); p.total = p.monto - p.descuentob; p.descuento = Math.Round(p.descuentob * 100 / p.monto, 2); } dtgPersonaDes.Items.Refresh(); } } }
public static void Main(string[]args) { persona informacion= new persona(); Console.WriteLine ("dame el nombre"); informacion.nombre = Console.ReadLine (); Console.WriteLine ("dame el telefono"); informacion.telefono= Console.ReadLine (); Console.WriteLine ("dame el email"); informacion.email= Console.ReadLine (); Console.WriteLine ("dame el domicilio"); informacion.domicilio= Console.ReadLine (); Console.WriteLine ("nombre"+ informacion.nombre); Console.WriteLine ("telefono"+informacion.telefono); Console.WriteLine ("email"+informacion.email); Console.WriteLine ("domicilio"+informacion.domicilio); }
public void actualizar(persona persona) { DbContextTransaction dbTransaccion = SS_Contexto.Database.BeginTransaction(); try { var entity = SS_Contexto.persona.Find(persona.identificacion); SS_Contexto.Entry(entity).CurrentValues.SetValues(persona); SS_Contexto.SaveChanges(); dbTransaccion.Commit(); } catch (Exception ex) { dbTransaccion.Rollback(); throw new Exception(ex.ToString()); }//Fin del try-catch. }
public persona[] data() { DataTable dt = obj_persona.get_persona(); DataRow row; persona[] personas = null; if (dt.Rows.Count > 0) { personas = new persona[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { row = dt.Rows[i]; personas[i] = new persona(Convert.ToInt64(row["idpersona"].ToString()), Convert.ToInt64(row["ndocumento"].ToString()), row["nombres"].ToString(), row["apellidos"].ToString(), Convert.ToInt64(row["telefono"].ToString()), row["correo"].ToString(), Convert.ToInt32(row["fk_idprograma"].ToString()), Convert.ToInt32(row["semestre"].ToString())); } } return(personas); }
/*Método llamado por AJAX para cargar un nuevo div con los datos de la persona a modificar (revisar la vista que lleva el mismo nombre en la carpeta Views)*/ public ActionResult modificarPersona(string cedula) { if (cedula == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona persona = db.persona.Find(cedula); if (persona == null) { return(HttpNotFound()); } ModeloIntermedio mod = new ModeloIntermedio(persona); return(View(mod)); }
public RespuestaDTO AddPersona(string nombre, string apellido, string edad) { RespuestaDTO dto = new RespuestaDTO(); int idEdad = 0; int.TryParse(edad, out idEdad); if (idEdad == 0) { dto.Error = "El valor ingresado en id no es un dato numérico"; return(dto); } using (var transaction = db.Database.BeginTransaction()) { try { persona p = new persona(); p.nombre = nombre.Trim().ToUpper(); p.apellido = apellido.Trim().ToUpper(); p.edad = idEdad; p.fecha = DateTime.Now; p.estado = 1; db.Entry(p).State = EntityState.Added; db.SaveChanges(); transaction.Commit(); dto.Respuesta = "Persona almacenada exitosamente"; } catch (Exception ex) { dto.Error = ex.InnerException.Message; } finally { transaction.Dispose(); } } return(dto); }
// GET: personas/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } persona personaTmp = db.persona.Find(id); PersonaConRol persona = new PersonaConRol(); persona.apellido1 = personaTmp.apellido1; persona.apellido2 = personaTmp.apellido2; persona.nombre = personaTmp.nombre; persona.cedula = personaTmp.cedula; persona.carne = personaTmp.carne; persona.email = personaTmp.email; //Ahora obtenemos el ID de ASPNET para obtener el rol var user = UserManager.FindByName(persona.cedula); string ID = user.Id; var aspUser = UserManager.FindById(ID); var rol = aspUser.Roles.SingleOrDefault().RoleId; switch (rol) { case "1": persona.rol = "Estudiante"; break; case "2": persona.rol = "Administrador"; break; case "3": persona.rol = "Asistente"; break; } if (persona == null) { return(HttpNotFound()); } return(View(persona)); }
protected void btnRegistra_Click(object sender, EventArgs e) { string mensaje = string.Empty; ClsPersona clsPersona = new ClsPersona(); persona persona = new persona(); persona.nombre = TextNombre.Text; persona.apellido = TextApellido.Text; persona.correo = TextCorreo.Text; persona.celular = (TextCelular.Text); persona.cedula = int.Parse(TextCedula.Text); persona.password = textPassword.Text; persona.id_rol = 3; mensaje = clsPersona.Registrar(persona); // persona = new persona(); Page.RegisterStartupScript("script", "<script languaje=JavaScript>alert('" + mensaje + "');location.href='agregarPersona.aspx';</script>"); //Response.Redirect(Request.Url.AbsoluteUri); }
public persona login(string id, string pass) { ORMDataContext BD = new ORMDataContext(); var personaLogin = BD.sp_login(id, pass); persona objPersona = new persona(); foreach (var item in personaLogin) { objPersona.cedula = item.cedula; objPersona.id_rol = item.id_rol; objPersona.cedula = item.cedula; objPersona.nombre = item.nombre; objPersona.apellido = item.correo; objPersona.correo = item.correo; objPersona.cedula = item.cedula; } return(objPersona); }
public string registrarPersona(persona perso, usuario usu) { string message; try { db.persona.InsertOnSubmit(perso); db.usuario.InsertOnSubmit(usu); db.SubmitChanges(); message = "¡Usuario registrado exitosamente!"; } catch (Exception ex) { message = "Error en el registro " + ex.Message; } return(message); }
public void nuevo(persona persona) { personaDAL personaDAL = new personaDAL(); personaDAL.insertar(persona); }
public ActionResult regcliente(ReservaHab reser) { DataClasses1DataContext db = new DataClasses1DataContext(); cliente cli = new cliente(); cli.nombre = reser.cli.Nombre; cli.ciudad = reser.cli.Ciudad; cli.estado = reser.cli.Estadoo; cli.pais = reser.cli.pais; cli.nit = reser.cli.nit; cli.telefono = reser.cli.telefono; cli.direccion = reser.cli.direccion; cli.email = reser.cli.email; cli.comentarios = reser.cli.comentarios; db.clientes.InsertOnSubmit(cli); db.SubmitChanges(); if (reser.tipocli == 1) { persona per = new persona(); per.id = cli.id; per.ci = reser.per.ci; per.apellido = reser.per.apellido;/* string d = (reser.per.cumple).ToString(); d = d.Substring(3, 3) + d.Substring(0, 3) + d.Substring(6, 4); per.cumpleaños = Convert.ToDateTime(d);*/ per.cumpleaños = reser.per.cumple; per.pasaporte = reser.per.pasaporte; db.personas.InsertOnSubmit(per); db.SubmitChanges(); } if (reser.tipocli == 2) { empresa empp = new empresa(); empp.id = cli.id; empp.contacto = reser.emp.contacto; empp.metodopago = reser.emp.metodoPago; db.empresas.InsertOnSubmit(empp); db.SubmitChanges(); } if (reser.tipocli == 3) { agencia agenn = new agencia(); agenn.id = cli.id; agenn.contacto = reser.agen.contacto; db.agencias.InsertOnSubmit(agenn); db.SubmitChanges(); } return View(); }