public int D_registrar_tipomas(TipoMascota tipo) { String cadena = DConexion.cadena; String sql = "INSERT INTO tipomascota (DESCRIPCION) VALUES (@descripcion)"; cone = new MySqlConnection(cadena); MySqlCommand com = new MySqlCommand(sql, cone); cone.Open(); if (tipo.Descripcion.Equals("")) { com.Parameters.AddWithValue("@descripcion", null); } else { com.Parameters.AddWithValue("@descripcion", tipo.Descripcion); } int band; try { band = com.ExecuteNonQuery(); } catch (Exception) { band = 0; } cone.Close(); return(band); }
// GET: TipoMascotas/Delete/5 public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } TipoMascota TipoMascota = await _context.TipoMascotas.Include(tm => tm.Mascotas).FirstOrDefaultAsync(tm => tm.Id == id); if (TipoMascota == null) { return(NotFound()); } if (TipoMascota.Mascotas.Count > 0) { ModelState.AddModelError(string.Empty, "No se puede eliminar el tipo de mascota si tiene registros relacionados."); return(RedirectToAction(nameof(Index))); } _context.TipoMascotas.Remove(TipoMascota); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public List <TipoMascota> D_listar_tipomas() { String cadena = DConexion.cadena; List <TipoMascota> lista = new List <TipoMascota>(); string sql = "select * from tipomascota"; cone = new MySqlConnection(cadena); MySqlCommand com = new MySqlCommand(sql, cone); cone.Open(); MySqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { TipoMascota tipo = new TipoMascota(); tipo.Id = Convert.ToInt32(dr[0]); if (!dr.IsDBNull(1)) { tipo.Descripcion = dr[1].ToString(); } else { tipo.Descripcion = ""; } lista.Add(tipo); } cone.Close(); return(lista); }
public TipoMascota D_buscar_TipoMascota(int id) { String cadena = DConexion.cadena; string sql = "select * from tipomascota where ID = @ID"; cone = new MySqlConnection(cadena); MySqlCommand com = new MySqlCommand(sql, cone); cone.Open(); com.Parameters.AddWithValue("@ID", id); MySqlDataReader dr = com.ExecuteReader(); TipoMascota m = new TipoMascota(); while (dr.Read()) { m.Id = int.Parse(dr[0].ToString()); m.Descripcion = dr[1].ToString(); cone.Close(); return(m); } cone.Close(); return(m);; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] TipoMascota tipoMascota) { if (id != tipoMascota.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tipoMascota); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoMascotaExists(tipoMascota.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tipoMascota)); }
public int N_Modificar_Ficha_Temp(TipoMascota tipo, String tamaño, String nombre, String apellido, String dni, String direccion, String sexo, String edad, String email, String facebook, String rpm, int movistar, int claro, String nextel, int casa, String horario, string observa, String esta, int id_ficha, int id_perso, Usuario voluntario) { Persona p = new Persona(); p.Id = id_perso; p.Nombre = nombre; p.Apellidos = apellido; p.Dni = dni; p.Direccion = direccion; p.Sexo = sexo; p.Edad = edad; p.Email = email; p.Facebook = facebook; p.Rpm = rpm; p.Tel_mov = movistar; p.Tel_claro = claro; p.Tel_nex = nextel; p.Tel_casa = casa; p.Hor_disp = horario; FichaTemporal ficha = new FichaTemporal(); ficha.Id = id_ficha; ficha.Tipomascota = (TipoMascota)tipo; ficha.Persona = (Persona)p; ficha.Tamano = tamaño; ficha.Observaciones = observa; ficha.Estado = esta; ficha.Voluntario = (Usuario)voluntario; int band = new DFichaTemporal().D_Modificar_fichaTemporal(ficha); return(band); }
// se agrega una mascota public void agregarmascota(string nombre, DateTime fechanacimiento, TipoMascota tipo) { mySql.Open(); String query = "INSERT INTO `mascota` ( `nombre_mascota`, `tipo_mascota`, `fecha_nacimiento`) VALUES ('" + nombre + "','" + tipo.ToString() + "','" + fechanacimiento.ToString("yyyy/MM/dd") + "');"; MySqlCommand command = new MySqlCommand(query, mySql); command.ExecuteNonQuery(); Cerrar(); }
public int N_eliminar_persona(int id) { TipoMascota tipoM = new TipoMascota(); tipoM.Id = id; int band = new DTipoMascota().D_eliminar_tipomas(tipoM); return(band); }
public int N_registrar_tipo(String descripcion) { TipoMascota tipoM = new TipoMascota(); tipoM.Descripcion = descripcion; int band = new DTipoMascota().D_registrar_tipomas(tipoM); return(band); }
public async Task <IActionResult> Create([Bind("Id,Nombre")] TipoMascota tipoMascota) { if (ModelState.IsValid) { _context.Add(tipoMascota); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tipoMascota)); }
[HttpPost] //la parte del posteo public IActionResult AgregarEspecie(TipoMascota e) { if (ModelState.IsValid) { _context.Add(e); _context.SaveChanges(); return(RedirectToAction("ListadoEspecie")); } ViewBag.especie = _context.TipoMascotas.ToList(); return(View(e)); }
public int N_modificar_persona(int id, String descripcion) { TipoMascota tipoM = new TipoMascota(); tipoM.Id = id; tipoM.Descripcion = descripcion; int band = new DTipoMascota().D_modificar_tipomas(tipoM); return(band); }
public IActionResult RegistrarTipoMascota(TipoMascota tp) { if (ModelState.IsValid) { _context.Add(tp); _context.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View()); }
public int D_modificar_tipomas(TipoMascota tipo) { String cadena = DConexion.cadena; String sql = "UPDATE tipomascota set DESCRIPCION=@descripcion WHERE ID = @id"; cone = new MySqlConnection(cadena); MySqlCommand com = new MySqlCommand(sql, cone); cone.Open(); if (tipo.Descripcion.Equals("")) { com.Parameters.AddWithValue("@descripcion", null); } else { com.Parameters.AddWithValue("@descripcion", tipo.Descripcion); } com.Parameters.AddWithValue("@id", tipo.Id); int band; try { band = com.ExecuteNonQuery(); } catch (Exception) { band = 0; } cone.Close(); return(band); }
public int D_eliminar_tipomas(TipoMascota tipo) { String cadena = DConexion.cadena; String sql = "DELETE FROM tipomascota WHERE ID = @id"; cone = new MySqlConnection(cadena); MySqlCommand com = new MySqlCommand(sql, cone); cone.Open(); com.Parameters.AddWithValue("@id", tipo.Id); int band; try { band = com.ExecuteNonQuery(); } catch (Exception) { band = 0; } cone.Close(); return(band); }
private void grilla_listado_CellClick(object sender, DataGridViewCellEventArgs e) { limpiar_cajas(); lb_id.Text = this.grilla_listado.CurrentRow.Cells[0].Value.ToString(); String tipo = this.grilla_listado.CurrentRow.Cells[1].Value.ToString(); for (int i = 0; i < combo_tipoMascota.Items.Count; i++) { TipoMascota ti = (TipoMascota)combo_tipoMascota.Items[i]; if (tipo.Equals(ti.Descripcion)) { combo_tipoMascota.SelectedIndex = i; break; } } String volu = this.grilla_listado.CurrentRow.Cells[2].Value.ToString(); for (int i = 0; i < combo_voluntario.Items.Count; i++) { Usuario usu = (Usuario)combo_voluntario.Items[i]; String conta = "DNI: " + usu.Dni + " - " + usu.Nombres + " " + usu.Apellidos; if (conta.Equals(volu)) { combo_voluntario.SelectedIndex = i; break; } } String tam = this.grilla_listado.CurrentRow.Cells[3].Value.ToString(); for (int i = 0; i < combo_Tamaño.Items.Count; i++) { String combo = combo_Tamaño.Items[i].ToString(); if (tam.Equals(combo)) { combo_Tamaño.SelectedIndex = i; break; } } lb_idPersona.Text = this.grilla_listado.CurrentRow.Cells[4].Value.ToString(); text_nombre.Text = this.grilla_listado.CurrentRow.Cells[5].Value.ToString(); text_apellido.Text = this.grilla_listado.CurrentRow.Cells[6].Value.ToString(); text_dni.Text = this.grilla_listado.CurrentRow.Cells[7].Value.ToString(); text_direccion.Text = this.grilla_listado.CurrentRow.Cells[8].Value.ToString(); String sexo = this.grilla_listado.CurrentRow.Cells[9].Value.ToString(); if (sexo.Equals("Masculino")) { radio_masculino.Checked = true; } else { radio_femenino.Checked = true; } text_edad.Text = this.grilla_listado.CurrentRow.Cells[10].Value.ToString(); text_email.Text = this.grilla_listado.CurrentRow.Cells[11].Value.ToString(); text_facebook.Text = this.grilla_listado.CurrentRow.Cells[12].Value.ToString(); text_rpm.Text = this.grilla_listado.CurrentRow.Cells[13].Value.ToString(); text_movistar.Text = this.grilla_listado.CurrentRow.Cells[14].Value.ToString(); text_claro.Text = this.grilla_listado.CurrentRow.Cells[15].Value.ToString(); text_nextel.Text = this.grilla_listado.CurrentRow.Cells[16].Value.ToString(); text_telefono.Text = this.grilla_listado.CurrentRow.Cells[17].Value.ToString(); text_horario.Text = this.grilla_listado.CurrentRow.Cells[18].Value.ToString(); String estado = this.grilla_listado.CurrentRow.Cells[19].Value.ToString(); if (estado.Equals("Activo")) { radio_activo.Checked = true; } else { radio_inactivo.Checked = true; } text_observa.Text = this.grilla_listado.CurrentRow.Cells[20].Value.ToString(); }
private void btn_modificar_Click(object sender, EventArgs e) { Boolean band1 = false, band2 = false, band3 = false; String mensaje = "Por Favor Complete los campos obligatorios : \n"; int id_ficha = int.Parse(lb_id.Text); int id_per = int.Parse(lb_idPersona.Text); String nombre = ""; String apellidos = ""; String dni = ""; String direccion = ""; String sexo = ""; String edad = ""; int movistar = 0; int claro = 0; int telefono = 0; String nextel = ""; String rpm = ""; String email = ""; String facebook = ""; String horario = ""; String observa = ""; String estado = ""; TipoMascota tipo = (TipoMascota)combo_tipoMascota.SelectedItem; String tamaño = combo_Tamaño.SelectedItem.ToString(); Usuario voluntario = (Usuario)combo_voluntario.SelectedItem; if (!String.IsNullOrEmpty(text_nombre.Text)) { nombre = text_nombre.Text; } else { mensaje = mensaje + "\n - Casilla de Nombre "; band1 = true; } if (!String.IsNullOrEmpty(text_apellido.Text)) { apellidos = text_apellido.Text; } else { mensaje = mensaje + "\n - Casilla de Apellidos "; band2 = true; } if (!String.IsNullOrEmpty(text_dni.Text)) { dni = text_dni.Text; } else { mensaje = mensaje + "\n - Casilla de Dni "; band3 = true; } if (!String.IsNullOrEmpty(text_direccion.Text)) { direccion = text_direccion.Text; } if (radio_masculino.Checked == true) { sexo = "Masculino"; } else { sexo = "Femenino"; } if (radio_activo.Checked == true) { estado = "Activo"; } else { estado = "Inactivo"; } if (!String.IsNullOrEmpty(text_edad.Text)) { edad = text_edad.Text; } if (!String.IsNullOrEmpty(text_email.Text)) { email = text_email.Text; } if (!String.IsNullOrEmpty(text_facebook.Text)) { facebook = text_facebook.Text; } if (!String.IsNullOrEmpty(text_rpm.Text)) { rpm = text_rpm.Text; } if (!String.IsNullOrEmpty(text_movistar.Text)) { movistar = int.Parse(text_movistar.Text); } if (!String.IsNullOrEmpty(text_claro.Text)) { claro = int.Parse(text_claro.Text); } if (!String.IsNullOrEmpty(text_nextel.Text)) { nextel = text_nextel.Text; } if (!String.IsNullOrEmpty(text_telefono.Text)) { telefono = int.Parse(text_telefono.Text); } if (!String.IsNullOrEmpty(text_horario.Text)) { horario = text_horario.Text; } if (!String.IsNullOrEmpty(text_observa.Text)) { observa = text_observa.Text; } if (band1 == true || band2 == true || band3 == true) { MessageBox.Show(mensaje); } else { int confir1 = new NFichaTemporal().N_Modificar_Ficha_Temp(tipo, tamaño, nombre, apellidos, dni, direccion, sexo, edad, email, facebook, rpm, movistar, claro, nextel, telefono, horario, observa, estado, id_ficha, id_per, voluntario); if (confir1 == 0) { MessageBox.Show("Error Al Modificar Por favor intente nuevamente"); } else { MessageBox.Show("Modificado Correctamente"); limpiar_cajas(); listar_fichas(); } } }
public int N_modificar_mascota_confecha_esterilizado(int serie, Usuario rescatista, FichaTemporal fitemp, DateTime fIngreso, TipoMascota tipo, string tamano, string estado, string nombre, string raza, string sexo, string color, string edad, String esterilizado, DateTime FechaEsterilizado) { Mascota masc = new Mascota(); masc.Serie = serie; masc.Ser_usu = (Usuario)rescatista; masc.Fic_tem = (FichaTemporal)fitemp; masc.Fecha_ingreso = fIngreso; masc.Tipomascota = (TipoMascota)tipo; masc.Tamano = tamano; masc.Estado = estado; masc.Nombre = nombre; masc.Raza = raza; masc.Sexo = sexo; masc.Color = color; masc.Edad = edad; masc.Esterilizado = esterilizado; masc.Fecha_esterilizacion = FechaEsterilizado; int band = new DMascota().D_modificar_mascotaConFecha_Esterilizado(masc); return(band); }