private void btnProcesar2_Click(object sender, EventArgs e) { dueñoMascota = new Dueño(txtNombreDueño.Text,txtApellidoDueño.Text,int.Parse(txtEdadDueño.Text),txtTipoMascota.Text,txtRazaMascota.Text,txtNombreMascota.Text,int.Parse(txtEdadMascota.Text)); MessageBox.Show("OK", "Dueño/Mascota", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(); btnProcesar2.Enabled = false; }
public void Baja(Dueño UnDueño) { MySqlConnection cnn = new MySqlConnection(Conexion.Cnn); string oComando = "EliminarDueño"; MySqlCommand cmd = new MySqlCommand(oComando, cnn); cmd.CommandType = CommandType.StoredProcedure; MySqlParameter oDocumento = new MySqlParameter("pCiDueño", UnDueño.CI); cmd.Parameters.Add(oDocumento); try { cnn.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { cnn.Close(); } }
public void Alta(Dueño UnDueño) { MySqlConnection cnn = new MySqlConnection(Conexion.Cnn); string oComando = "AltaDueño"; MySqlCommand cmd = new MySqlCommand(oComando, cnn); cmd.CommandType = CommandType.StoredProcedure; MySqlParameter oDocumento = new MySqlParameter("pCiDueño", UnDueño.CI); MySqlParameter oUserLogueo = new MySqlParameter("pNombreUsuario", UnDueño.NombreUsuario); MySqlParameter oPassLogueo = new MySqlParameter("pContraseña", UnDueño.Contraseña); MySqlParameter oNombre = new MySqlParameter("pNombre", UnDueño.Nombre); MySqlParameter oEmail = new MySqlParameter("pEmail", UnDueño.Email); cmd.Parameters.Add(oDocumento); cmd.Parameters.Add(oUserLogueo); cmd.Parameters.Add(oPassLogueo); cmd.Parameters.Add(oNombre); cmd.Parameters.Add(oEmail); try { cnn.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { cnn.Close(); } }
private Dueño mapearDueño(DueñoInputModel dueñoInput) { Dueño dueño = new Dueño(); dueño.Nombre = dueñoInput.Nombre; dueño.Apellido = dueñoInput.Apellido; dueño.ID = dueñoInput.ID; return(dueño); }
public ActionResult <DueñoViewModel> Post(DueñoInputModel dueñoInput) { Dueño dueño = mapearDueño(dueñoInput); var respuesta = _dueñoService.Guardar(dueño); if (respuesta.Error) { return(BadRequest(respuesta.Mensaje)); } return(Ok(respuesta.Dueño)); }
public GuardarDueñoResponse Guardar(Dueño dueño) { try { _conexion.Open(); _repositorio.Guardar(dueño); _conexion.Close(); return(new GuardarDueñoResponse(dueño)); } catch (Exception e) { return(new GuardarDueñoResponse($"Error de la Aplicacion: {e.Message}")); } finally { _conexion.Close(); } }
public void Guardar(Dueño dueño) { using (var command = _connection.CreateCommand()) { command.CommandText = @"Insert Into Dueños (Nombre,Apellido,ID) values (@Nombre,@Apellido,@ID)"; command.Parameters.AddWithValue("@Nombre", dueño.Nombre); command.Parameters.AddWithValue("@Apellido", dueño.Apellido); command.Parameters.AddWithValue("@ID", dueño.ID); var filas = command.ExecuteNonQuery(); } }
private Dueño DataReaderMapToDueño(SqlDataReader dataReader) { if (!dataReader.HasRows) { return(null); } Dueño dueño = new Dueño(); dueño.Nombre = (string)dataReader["Nombre"]; dueño.Apellido = (string)dataReader["Apellido"]; dueño.ID = (string)dataReader["ID"]; return(dueño); }
public List <Dueño> ListarDueños() { string Documento; string UserLogueo; string PassLogueo; string Nombre; string Email; Dueño UnDueño; List <Dueño> lista = null; MySqlConnection cnn = new MySqlConnection(Conexion.Cnn); string oComando = "ListarDueño"; MySqlCommand cmd = new MySqlCommand(oComando, cnn); cmd.CommandType = CommandType.StoredProcedure; MySqlDataReader lector; try { cnn.Open(); lector = cmd.ExecuteReader(); if (lector.HasRows) { lista = new List <Dueño>(); while (lector.Read()) { Documento = (string)lector["CiDueño"]; UserLogueo = (string)lector["NombreUsuario"]; PassLogueo = (string)lector["Contraseña"]; Nombre = (string)lector["Nombre"]; Email = (string)lector["Email"]; UnDueño = new Dueño(Documento, Nombre, UserLogueo, PassLogueo, Email); lista.Add(UnDueño); } } } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { cnn.Close(); } return(lista); }
private void Guardarbutton_Click(object sender, EventArgs e) { int edad = Convert.ToInt32(EdadtextBox.Text); du = new Dueño(NombretextBox.Text, ApellidotextBox.Text, edad, DirecciontextBox.Text, TelefonotextBox.Text, NombreMascotatextBox.Text, ClasetextBox.Text, RazatextBox.Text); arreglo.Add(du.ToString()); MessageBox.Show("Informacion guardada","Mensaje",MessageBoxButtons.OK,MessageBoxIcon.Information); NombretextBox.Clear(); ApellidotextBox.Clear(); EdadtextBox.Clear(); DirecciontextBox.Clear(); TelefonotextBox.Clear(); NombreMascotatextBox.Clear(); ClasetextBox.Clear(); RazatextBox.Clear(); }
public Usuario Logueo(string cUserLogueo, string cPassLogueo) { string UserLogueo; string PassLogueo; string Nombre; string Documento; string Email; Usuario c = null; MySqlConnection cnn = new MySqlConnection(Conexion.Cnn); string oComando = "DueñoLogueo"; MySqlCommand cmd = new MySqlCommand(oComando, cnn); cmd.CommandType = CommandType.StoredProcedure; MySqlDataReader lector; MySqlParameter oUserLogueo = new MySqlParameter("pNombreUsuario", cUserLogueo); MySqlParameter oPassLogueo = new MySqlParameter("pContraseña", cPassLogueo); cmd.Parameters.Add(oUserLogueo); cmd.Parameters.Add(oPassLogueo); try { cnn.Open(); lector = cmd.ExecuteReader(); if (lector.Read()) { Documento = (string)lector["CiDueño"]; Nombre = (string)lector["Nombre"]; UserLogueo = (string)lector["NombreUsuario"]; PassLogueo = (string)lector["Contraseña"]; Email = (string)lector["Email"]; c = new Dueño(Documento, Nombre, UserLogueo, PassLogueo, Email); } } catch (Exception ex) { throw new ApplicationException(ex.Message); } finally { cnn.Close(); } return(c); }
public ActionResult Guardar(HttpPostedFileBase image, FormCollection collection) { try { EntidadesCompartidas.Dueño dueño = new Dueño(); dueño = (EntidadesCompartidas.Dueño)Session["Dueño"]; LugarModel Lugar = new LugarModel(); EntidadesCompartidas.Lugar l = new EntidadesCompartidas.Lugar(); Lugar.Nombre = Convert.ToString(collection["Nombre"]); Lugar.Direccion = Convert.ToString(collection["Direccion"]); Lugar.NombreCiudad = Convert.ToString(collection["NombreCiudad"]); EntidadesCompartidas.Ciudad Ciudad = Logica.FabricaLogica.getLogicaUbicacion().BuscarCiudad(Lugar.NombreCiudad); Lugar.Descripcion = Convert.ToString(collection["Descripcion"]); Lugar.CoordenadaX = float.Parse(collection["CoordenadaX"], System.Globalization.CultureInfo.InvariantCulture); Lugar.CoordenadaY = float.Parse(collection["CoordenadaY"], System.Globalization.CultureInfo.InvariantCulture); l.Nombre = Lugar.Nombre; l.Direccion = Lugar.Direccion; l.UbicacionLugar = Ciudad; l.Descripcion = Lugar.Descripcion; l.CoordenadaX = Lugar.CoordenadaX; l.CoordenadaY = Lugar.CoordenadaY; l.DueñoLugar = dueño; l.Fotos = (List <EntidadesCompartidas.FotosLugar>)Session["Fotos"]; l.MapaAsociado = (EntidadesCompartidas.Mapa)Session["Plano"]; Logica.FabricaLogica.getLogicaLugar().AltaLugar(l); string JsonLugar = JsonConvert.SerializeObject(l); Session["LugarJson"] = JsonLugar; Session["LugarActual"] = l; Session["LugarModel"] = Lugar; return(View("AdministrarLugares")); } catch { return(View("AdministrarLugares")); } }
private void Guardarbutton_Click(object sender, EventArgs e) { Dueño [] dueño = new Dueño[5]; dueño[1].NombreDueño = NombreDuenotextBox.Text; dueño[1].EdadDueño = Convert.ToInt32(EdadDuenotextBox.Text); dueño[1].Perro.NombreMascota = NombremascotatextBox.Text; dueño[1].Perro.EdadMascota = Convert.ToInt32(EdadMacotatextBox.Text); dueño[1].Perro.RazaMascota = RazatextBox.Text; if (dueño != null) { MessageBox.Show("Guardado"); } else { MessageBox.Show("No Guardado"); } }
public List <Dueño> ConsultarTodos() { SqlDataReader dataReader; List <Dueño> dueños = new List <Dueño>(); using (var command = _connection.CreateCommand()) { command.CommandText = "Select * from Dueños"; dataReader = command.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { Dueño dueño = DataReaderMapToDueño(dataReader); dueños.Add(dueño); } } } return(dueños); }
public GuardarDueñoResponse Guardar(Dueño dueño) { try { var due = _context.Dueños.Find(dueño.ID); if (due != null) { return(new GuardarDueñoResponse("Error el Dueño ya se encuentra registrado")); } _context.Dueños.Add(dueño); _context.SaveChanges(); return(new GuardarDueñoResponse(dueño)); } catch (Exception e) { return(new GuardarDueñoResponse($"Error de la Aplicacion: {e.Message}")); } }
private void button2_Click(object sender, EventArgs e) { string nombre; string telefono; string direccion; string nombreMascota; string tipo; string raza; Dueño dueño; Mascota mascota; Console.WriteLine("Digite el nombre del dueño: "); nombre = Console.ReadLine(); Console.WriteLine("Digite el numero de telefono: "); telefono = Console.ReadLine(); Console.WriteLine("Digite la direccion: "); direccion = Console.ReadLine(); Console.WriteLine("Digite el nombre de la mascota: "); nombreMascota = Console.ReadLine(); Console.WriteLine("Digite el tipo de mascota: "); tipo = Console.ReadLine(); Console.WriteLine("Digite la raza: "); raza = Console.ReadLine(); mascota = new Mascota(nombre, raza, tipo); dueño = new Dueño(nombre, telefono, direccion, mascota); Console.WriteLine(dueño.ToString()); }
public string Modificar(Dueño dueñoN) { try { var dueñoV = _context.Dueños.Find(dueñoN.ID); if (dueñoV != null) { dueñoV.ID = dueñoN.ID; dueñoV.Nombre = dueñoN.Nombre; dueñoV.Apellido = dueñoN.Apellido; _context.Dueños.Update(dueñoV); _context.SaveChanges(); return($"El registro {dueñoN.ID} se ha modificado satisfactoriamente"); } else { return($"Lo sentimos, {dueñoN.ID} no se encuentra registrado."); } } catch (Exception e) { return($"Error de la aplicacion: {e.Message}."); } }
public DueñoViewModel(Dueño dueño) { Nombre = dueño.Nombre; Apellido = dueño.Apellido; ID = dueño.ID; }
public Mascota(string Nombre, string Raza, string NombreD, string Direccion, string Telefono) { this.Nombre = Nombre; this.Raza = Raza; Propietario = new Dueño(NombreD, Direccion, Telefono); }
private void button4_Click(object sender, EventArgs e) { if (Empresa.Text == "") { Empresa.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (Dueño.Text == "") { Dueño.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (Telefono.Text == "") { Telefono.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (Direccion.Text == "") { Direccion.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (usuario.Text == "") { usuario.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (key1.Text == "") { key1.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (key2.Text == "") { key2.Focus(); MessageBox.Show("¡Faltan Datos!"); return; } if (key1.Text != key2.Text) { MessageBox.Show("¡Las Contraseñas no coinciden!"); key1.Text = ""; key2.Text = ""; key1.Focus(); return; } else { Empresa a = new Empresa(); a.Nombre = Empresa.Text; a.Dueño = Dueño.Text; a.Telefono = Telefono.Text; a.Direccion = Direccion.Text; a.Usuario = usuario.Text; a.Clave = key1.Text; a.ListaDivisas = new List <Divisa>(); Divisa Bs = new Divisa(); Bs.Nombre = "Bolívares"; Bs.Logo = "Bs"; Bs.equivalente = 250000; a.ListaDivisas.Add(Bs); Random ran = new Random(); byte[] buffer = new byte[14]; string g = File.ReadAllText("Data/Registro.OKs"); ListaEmpresas asd = JsonConvert.DeserializeObject <ListaEmpresas>(g); bool s = true; do { s = false; a.id = ""; ran.NextBytes(buffer); foreach (char c in buffer) { a.id += c; } foreach (Empresa c in asd.UsuariosTotales) { if (c.id == a.id) { s = true; break; } } } while (s); foreach (Empresa c in asd.UsuariosTotales) { if (c.Usuario == a.Usuario) { MessageBox.Show("¡Este nombre de usuario ya esta en uso!"); return; } } asd.UsuariosTotales.Add(a); g = JsonConvert.SerializeObject(asd); File.WriteAllText("Data/Registro.OKs", g); //transacciones------------------------------------------- Transacciones tr = new Transacciones(); tr.TodasLasCompras = new List <Compra>(); tr.TodasLasVentas = new List <Venta>(); tr.id = a.id; g = JsonConvert.SerializeObject(tr); File.WriteAllText(string.Format("trans/{0}{1}", a.Usuario, ".tr"), g); //Stock-------------------------------------------------- Stock st = new Stock(); st.ListaDeArticulos = new List <Articulo>(); st.id = a.id; g = JsonConvert.SerializeObject(st); File.WriteAllText(string.Format("stock/{0}{1}", a.Usuario, ".st"), g); //estatus---------------------------------------------------- Estatus es = new Estatus(); es.id = a.id; g = JsonConvert.SerializeObject(es); File.WriteAllText(string.Format("estatus/{0}{1}", a.Usuario, ".es"), g); Application.Restart(); } }
public GuardarDueñoResponse(Dueño dueño) { Error = false; Dueño = dueño; }
public Dueño BuscarPorID(string ID) { Dueño dueño = _context.Dueños.Find(ID); return(dueño); }