public int SelectClienteId(Cliente C)//selecciona el id del cliente para utilizarlo en insertercliente { int id_cliente = 0; CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand commID = CM.con.CreateCommand(); commID.CommandText = "SELECT id_cliente FROM cliente WHERE email = ?email"; commID.Parameters.AddWithValue("?email", C.EmailC); MySqlDataReader myreader = commID.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { id_cliente = Convert.ToInt32(myreader["id_cliente"].ToString()); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(id_cliente); }
public void InsertInmobiliaria(Inmobiliaria I) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO inmobiliaria(nombre,email,telefono, direccion, sitioweb) VALUES(?nombre,?email,?telefono,?direccion,?sitioweb)"; comm.Parameters.AddWithValue("?nombre", I.Nombre); comm.Parameters.AddWithValue("?email", I.Email); comm.Parameters.AddWithValue("?telefono", I.Telefono); comm.Parameters.AddWithValue("?direccion", I.Direccion); comm.Parameters.AddWithValue("?sitioweb", I.SitioWeb); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); int id = SelectInmobiliariaId(I); ingresarcontrasenia(I, id); }
public int SelectInmobiliariaId(Contacto I) { int id = 0; CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM inmobiliaria WHERE email=?email"; comm.Parameters.AddWithValue("?email", I.Email); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { id = int.Parse(myreader["id_inmobiliaria"].ToString()); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(id); }
public void insertarCliente(Cliente cliente)//inserta en la tabla clientes los datos y tambien en la tabla logueo { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO Cliente(nombre,apellido,email,telefono)VALUES(?nombre,?apellido ,?email,?telefono)"; comm.Parameters.AddWithValue("?nombre", cliente.NombreC); comm.Parameters.AddWithValue("?apellido", cliente.ApellidoC); comm.Parameters.AddWithValue("?email", cliente.EmailC); comm.Parameters.AddWithValue("?telefono", cliente.TelefonoC); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); int id = SelectClienteId(cliente); ingresarcontrasenia(cliente, id); }
public void SelectCliente(ref Cliente cliente)//seleccion un cliente y lo guarda en el parametro q esta mandado como referencia { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM cliente INNER JOIN logueo USING(id_cliente) WHERE logueo.email=?email"; comm.Parameters.AddWithValue("?email", cliente.EmailC); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { cliente.NombreC = myreader["nombre"].ToString(); cliente.ApellidoC = myreader["apellido"].ToString(); cliente.EmailC = myreader["email"].ToString(); cliente.TelefonoC = int.Parse(myreader["telefono"].ToString()); cliente.ContraseniaC = myreader["pass"].ToString(); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void SelectDuenio(ref Duenio D)//trae los datos de duenio de la base de datos y los guarda en el parametro enviado { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM duenio INNER JOIN logueo USING(id_duenio) WHERE logueo.email=?email"; comm.Parameters.AddWithValue("?email", D.Email); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { D.Nombre = myreader["nombre"].ToString(); D.Email = myreader["email"].ToString(); D.Direccion = myreader["direccion"].ToString(); D.HorarioDeDisponibilidad = myreader["horariodisp"].ToString(); D.Telefono = int.Parse(myreader["telefono"].ToString()); D.Contrasenia = myreader["pass"].ToString(); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public bool tipoContacto(string usuario) // true = Duenio { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM logueo WHERE email=?email"; comm.Parameters.AddWithValue("?email", usuario); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { string id = myreader["id_duenio"].ToString(); if (id != "") { return(true); } } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(false); }
public void insertarDuenio(Duenio D)//inserta los datos en la tabla duenio y en logueo { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO duenio(nombre,email,telefono, direccion, horariodisp) VALUES(?nombre,?email,?telefono,?direccion,?horariodisp)"; comm.Parameters.AddWithValue("?nombre", D.Nombre); comm.Parameters.AddWithValue("?email", D.Email); comm.Parameters.AddWithValue("?telefono", D.Telefono); comm.Parameters.AddWithValue("?direccion", D.Direccion); comm.Parameters.AddWithValue("?horariodisp", D.HorarioDeDisponibilidad); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); int id = SelectDuenioId(D); ingresarcontrasenia(D, id); }
public bool validar(string email, string contrasenia) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM logueo WHERE email=?email"; comm.Parameters.AddWithValue("?email", email); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { if (email == myreader["email"].ToString() && contrasenia == myreader["pass"].ToString()) { return(true); } } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(false); }
public void UpdatePropiedad(Propiedad P1) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE propiedad SET nombre=?nombre, superficie=?superficie, estado=?estado," + " cantbanios=?cantbanios, canthabitaciones=?canthabitaciones, cantcocheras=?cantcocheras," + " cantsuites=?cantsuites, condicion=?condicion, fechahabitable=?fechahabitable, precio=?precio " + "WHERE direccion=?direccion"; comm.Parameters.AddWithValue("?nombre", P1.NombreI); comm.Parameters.AddWithValue("?direccion", P1.DireccionI); comm.Parameters.AddWithValue("?superficie", P1.SuperficieI); comm.Parameters.AddWithValue("?estado", P1.EstadoI); comm.Parameters.AddWithValue("?precio", P1.PrecioI); comm.Parameters.AddWithValue("?cantbanios", P1.CantidadBanios); comm.Parameters.AddWithValue("?canthabitaciones", P1.CantidadHabitaciones); comm.Parameters.AddWithValue("?cantcocheras", P1.CantidadCocheras); comm.Parameters.AddWithValue("?cantsuites", P1.CantidadSuites); comm.Parameters.AddWithValue("?condicion", P1.Condicion); comm.Parameters.AddWithValue("?fechahabitable", P1.FechaHabitable); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void SelectInmobiliaria(ref Inmobiliaria I) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM inmobiliaria INNER JOIN logueo USING(id_inmobiliaria) WHERE logueo.email=?email"; comm.Parameters.AddWithValue("?email", I.Email); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { I.Nombre = myreader["nombre"].ToString(); I.Email = myreader["email"].ToString(); I.Direccion = myreader["direccion"].ToString(); I.SitioWeb = myreader["sitioweb"].ToString(); I.Telefono = int.Parse(myreader["telefono"].ToString()); I.Contrasenia = myreader["pass"].ToString(); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void Updateinmobiliaria(Inmobiliaria I) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE inmobiliaria SET nombre=?nombre,email=?email,telefono=?telefono, " + "direccion=?direccion,sitioweb=?sitioweb WHERE email=?email"; comm.Parameters.AddWithValue("?nombre", I.Nombre); comm.Parameters.AddWithValue("?email", I.Email); comm.Parameters.AddWithValue("?telefono", I.Telefono); comm.Parameters.AddWithValue("?direccion", I.Direccion); comm.Parameters.AddWithValue("?sitioweb", I.SitioWeb); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); modificarcontrasenia(I); }
public List <Terreno> SelectTerreno(Contacto C)//mostrar todos los inmuebles { List <Terreno> lista = new List <Terreno>(); CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); if (C.getTipo() == "Duenio") { comm.CommandText = "SELECT * FROM terreno INNER JOIN duenio USING(id_duenio) WHERE email=?email"; comm.Parameters.AddWithValue("?email", C.Email); } else { comm.CommandText = comm.CommandText = "SELECT * FROM terreno INNER JOIN inmobiliaria" + " USING(id_inmobiliaria) WHERE email=?email"; comm.Parameters.AddWithValue("?email", C.Email); } //comm.CommandText = "SELECT * FROM terreno WHERE direccion=?direccion"; //comm.Parameters.AddWithValue("?email", T1.DireccionI); MySqlDataReader myreader = comm.ExecuteReader(); while (myreader.Read()) { Terreno T1 = new Terreno(); T1.NombreI = myreader["nombre"].ToString(); switch (myreader["estado"].ToString()) { case "2": T1.EstadoI = estado.NoDisponible; break; case "1": T1.EstadoI = estado.Venta; break; default: Console.WriteLine("errror"); break; } T1.DireccionI = myreader["direccion"].ToString(); T1.SuperficieI = int.Parse(myreader["superficie"].ToString()); T1.PrecioI = float.Parse(myreader["precio"].ToString()); lista.Add(T1); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(lista); }
public List <Propiedad> SelectPropiedades() { List <Propiedad> lista = new List <Propiedad>(); CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM propiedad"; DuenioABM D = new DuenioABM(); //comm.CommandText = "SELECT * FROM propiedad WHERE direccion=?direccion AND nombre=?nombre"; //comm.Parameters.AddWithValue("?direccion", P1.DireccionI); //comm.Parameters.AddWithValue("?nombre", P1.NombreI); MySqlDataReader myreader = comm.ExecuteReader(); while (myreader.Read()) { Propiedad P1 = new Propiedad(); P1.NombreI = myreader["nombre"].ToString(); P1.SuperficieI = int.Parse(myreader["superficie"].ToString()); P1.DireccionI = myreader["direccion"].ToString(); switch (myreader["estado"].ToString()) { case "0": P1.EstadoI = estado.Alquiler; break; case "2": P1.EstadoI = estado.NoDisponible; break; case "1": P1.EstadoI = estado.Venta; break; default: Console.WriteLine("errror"); break; } P1.PrecioI = float.Parse(myreader["precio"].ToString()); P1.CantidadBanios = int.Parse(myreader["cantbanios"].ToString()); P1.CantidadHabitaciones = int.Parse(myreader["canthabitaciones"].ToString()); P1.CantidadCocheras = int.Parse(myreader["cantcocheras"].ToString()); P1.CantidadSuites = int.Parse(myreader["cantsuites"].ToString()); P1.FechaHabitable = myreader["fechahabitable"].ToString(); lista.Add(P1); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(lista); }
public List <Terreno> selecTerrenoporSuperficie(int superficie) { List <Terreno> lista = new List <Terreno>(); CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM Terreno WHERE superficie>=?superficie"; DuenioABM D = new DuenioABM(); comm.Parameters.AddWithValue("?superficie", superficie); //comm.CommandText = "SELECT * FROM propiedad WHERE direccion=?direccion AND nombre=?nombre"; //comm.Parameters.AddWithValue("?direccion", P1.DireccionI); //comm.Parameters.AddWithValue("?nombre", P1.NombreI); MySqlDataReader myreader = comm.ExecuteReader(); while (myreader.Read()) { Terreno T1 = new Terreno(); T1.NombreI = myreader["nombre"].ToString(); T1.SuperficieI = int.Parse(myreader["superficie"].ToString()); T1.DireccionI = myreader["direccion"].ToString(); switch (myreader["estado"].ToString()) { case "2": T1.EstadoI = estado.NoDisponible; break; case "1": T1.EstadoI = estado.Venta; break; default: Console.WriteLine("errror"); break; } T1.PrecioI = float.Parse(myreader["precio"].ToString()); lista.Add(T1); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); return(lista); }
public void SelectPropiedad(ref Propiedad P1) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM propiedad WHERE direccion=?direccion"; comm.Parameters.AddWithValue("?direccion", P1.DireccionI); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { P1.NombreI = myreader["nombre"].ToString(); P1.SuperficieI = int.Parse(myreader["superficie"].ToString()); P1.DireccionI = myreader["direccion"].ToString(); switch (myreader["estado"].ToString()) { case "Alquiler": P1.EstadoI = estado.Alquiler; break; case "NoDisponible": P1.EstadoI = estado.NoDisponible; break; case "Venta": P1.EstadoI = estado.Venta; break; default: Console.WriteLine("errror"); break; } P1.PrecioI = float.Parse(myreader["precio"].ToString()); P1.CantidadBanios = int.Parse(myreader["cantbanios"].ToString()); P1.CantidadHabitaciones = int.Parse(myreader["canthabitaciones"].ToString()); P1.CantidadCocheras = int.Parse(myreader["cantcocheras"].ToString()); P1.CantidadSuites = int.Parse(myreader["cantsuites"].ToString()); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void InsertPropiedad(Propiedad P1, Contacto C) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); if (C.getTipo() == "Duenio") { comm.CommandText = "INSERT INTO propiedad(id_duenio, nombre, superficie, direccion, estado, cantbanios," + " canthabitaciones, cantcocheras, cantsuites,condicion, fechahabitable, precio) VALUES(?id_duenio,?nombre,?superficie," + "?direccion,?estado,?cantbanios,?canthabitaciones,?cantcocheras,?cantsuites,?condicion,?fechahabitable, ?precio)"; DuenioABM D = new DuenioABM(); int idDuenio = D.SelectDuenioId(C); comm.Parameters.AddWithValue("?id_duenio", idDuenio); } else { comm.CommandText = "INSERT INTO propiedad(id_inmobiliaria,nombre, superficie, direccion, estado, cantbanios," + " canthabitaciones, cantcocheras, cantsuites,condicion, fechahabitable, precio) VALUES(?id_inmobiliaria,?nombre,?superficie," + "?direccion,?estado,?cantbanios,?canthabitaciones,?cantcocheras,?cantsuites,?condicion,?fechahabitable, ?precio)"; InmobiliariaABM I = new InmobiliariaABM(); int idInmo = I.SelectInmobiliariaId(C); comm.Parameters.AddWithValue("?id_inmobiliaria", idInmo); } //comm.CommandText = "INSERT INTO propiedad(nombre, superficie, direccion, estado, cantbanios, canthabitaciones, cantacocheras, cantsuites,condicion, fechahabitable) VALUES(?nombre,?superficie,?direccion,?estado,?cantbanios,?canthabitaciones,?cantacocheras,?cantsuites,?condicion,?fechahabitable)"; comm.Parameters.AddWithValue("?nombre", P1.NombreI); comm.Parameters.AddWithValue("?superficie", P1.SuperficieI); comm.Parameters.AddWithValue("?direccion", P1.DireccionI); comm.Parameters.AddWithValue("?estado", P1.EstadoI); comm.Parameters.AddWithValue("?precio", P1.PrecioI); comm.Parameters.AddWithValue("?cantbanios", P1.CantidadBanios); comm.Parameters.AddWithValue("?canthabitaciones", P1.CantidadHabitaciones); comm.Parameters.AddWithValue("?cantcocheras", P1.CantidadCocheras); comm.Parameters.AddWithValue("?cantsuites", P1.CantidadSuites); comm.Parameters.AddWithValue("?condicion", P1.Condicion); comm.Parameters.AddWithValue("?fechahabitable", P1.FechaHabitable); comm.ExecuteNonQuery(); comm.Dispose(); }catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void DeleteTerreno(Terreno T1) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "DELETE FROM terreno WHERE direccion=?direccion"; comm.Parameters.AddWithValue("?direccion", T1.DireccionI); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void modificarcontrasenia(Duenio D)//modifica duenio en la tabla logueo(se la utilisa en updateduenio) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE logueo SET pass=?contrasenia WHERE email=?email"; comm.Parameters.AddWithValue("?email", D.Email); comm.Parameters.AddWithValue("?contrasenia", D.Contrasenia); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void deleteDuenio(Duenio D)//elimina el duenio de la tabla { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "DELETE FROM duenio WHERE email=?email"; comm.Parameters.AddWithValue("?email", D.Email); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void deleteCliente(Cliente cliente)//elimina el cliente especificado de las tablas { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "DELETE FROM Cliente WHERE email=?email"; comm.Parameters.AddWithValue("?email", cliente.EmailC); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void modificarcontrasenia(Inmobiliaria I) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE logueo SET pass=?contrasenia WHERE email=?email"; comm.Parameters.AddWithValue("?email", I.Email); comm.Parameters.AddWithValue("?contrasenia", I.Contrasenia); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void modificarcontrasenia(Cliente cliente)//se utilisa para modificar la contraseña en la tabla logueo cunado se hace updatecliente { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE logueo SET pass=?contrasenia WHERE email=?email"; comm.Parameters.AddWithValue("?email", cliente.EmailC); comm.Parameters.AddWithValue("?contrasenia", cliente.ContraseniaC); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void DeleteInmobiliaria(Inmobiliaria I) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "DELETE FROM Inmobiliaria WHERE email=?email"; comm.Parameters.AddWithValue("?email", I.Email); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void ingresarcontrasenia(Duenio D, int id)//ingresa los datos de logueo dell duenio en la tabla logueo { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO logueo(id_duenio, pass, email) VALUES(?id_duenio,?contrasenia,?email)"; comm.Parameters.AddWithValue("?email", D.Email); comm.Parameters.AddWithValue("?contrasenia", D.Contrasenia); comm.Parameters.AddWithValue("?id_duenio", id); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void ingresarcontrasenia(Cliente C, int id)//se utiliza en insertarcliente para insertar datos en tabla logueo { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO logueo(id_cliente, pass, email) VALUES(?id_cliente,?contrasenia,?email)"; comm.Parameters.AddWithValue("?email", C.EmailC); comm.Parameters.AddWithValue("?contrasenia", C.ContraseniaC); comm.Parameters.AddWithValue("?id_cliente", id); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void ingresarcontrasenia(Inmobiliaria I, int id) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "INSERT INTO logueo(id_inmobiliaria, pass, email) VALUES(?id_inmobiliaria,?contrasenia,?email)"; comm.Parameters.AddWithValue("?email", I.Email); comm.Parameters.AddWithValue("?contrasenia", I.Contrasenia); comm.Parameters.AddWithValue("?id_inmobiliaria", id); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void InsertTerreno(Terreno T1, Contacto C) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); if (C.getTipo() == "Duenio") { comm.CommandText = "INSERT INTO terreno(id_duenio,nombre, superficie, direccion," + " estado, precio) VALUES(?id_duenio,?nombre,?superficie,?direccion,?estado,?precio)"; DuenioABM D = new DuenioABM(); int idDuenio = D.SelectDuenioId(C); comm.Parameters.AddWithValue("?id_duenio", idDuenio); } else { comm.CommandText = "INSERT INTO terreno(id_inmobiliaria,nombre, superficie," + " direccion, estado, precio) VALUES(?id_inmobiliaria,?nombre,?superficie,?direccion,?estado,?precio)"; InmobiliariaABM I = new InmobiliariaABM(); int idInmo = I.SelectInmobiliariaId(C); comm.Parameters.AddWithValue("?id_inmobiliaria", idInmo); } //comm.CommandText = "INSERT INTO terreno(nombre, superficie, direccion, estado, precio) VALUES(?nombre,?superficie,?direccion,?estado,?precio)"; comm.Parameters.AddWithValue("?nombre", T1.NombreI); comm.Parameters.AddWithValue("?superficie", T1.SuperficieI); comm.Parameters.AddWithValue("?direccion", T1.DireccionI); comm.Parameters.AddWithValue("?estado", T1.EstadoI); comm.Parameters.AddWithValue("?precio", T1.PrecioI); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void SelectTerreno(ref Terreno T1) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "SELECT * FROM terreno WHERE direccion=?direccion"; comm.Parameters.AddWithValue("?email", T1.DireccionI); MySqlDataReader myreader = comm.ExecuteReader(); myreader.Read(); if (myreader.HasRows) { T1.NombreI = myreader["nombre"].ToString(); switch (myreader["estado"].ToString()) { case "2": T1.EstadoI = estado.NoDisponible; break; case "1": T1.EstadoI = estado.Venta; break; default: Console.WriteLine("errror"); break; } T1.DireccionI = myreader["direccion"].ToString(); T1.SuperficieI = int.Parse(myreader["superficie"].ToString()); } } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }
public void UpdateTerreno(Terreno T1) { CM = new ConectarYDesconectar(); CM.conectar(); try { MySqlCommand comm = CM.con.CreateCommand(); comm.CommandText = "UPDATE terreno SET nombre=?nombre, superficie=?superficie, estado=?estado, precio=?precio WHERE direccion=?direccion"; comm.Parameters.AddWithValue("?nombre", T1.NombreI); comm.Parameters.AddWithValue("?superficie", T1.SuperficieI); comm.Parameters.AddWithValue("?estado", T1.EstadoI); comm.Parameters.AddWithValue("?precio", T1.PrecioI); comm.Parameters.AddWithValue("?direccion", T1.DireccionI); comm.ExecuteNonQuery(); comm.Dispose(); } catch (Exception ex) { MessageBox.Show("Hubo un error: " + ex.ToString()); } CM.desconectar(); }