Beispiel #1
0
        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 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();
        }