// edit the selected property public Boolean updateProperty(THE_PROPERTY property) { MySqlCommand command = new MySqlCommand("UPDATE `the_property` SET `type`=@tp,`square_feet`=@size,`price`=@price,`address`=@adrs,`bedrooms`=@bedr,`bathrooms`=@bathr,`age`=@age,`balcony`=@balc,`backyard`=@backy,`pool`=@pool,`garage`=@grg,`fireplace`=@fire,`comment`=@cmnt WHERE `id`=@id"); // (@tp,@size,@owner,@price,@adrs,@bedr,@bathr,@age,@balc,@backy,@pool,@grg,@fire,@cmnt) command.Parameters.Add("@id", MySqlDbType.Int32).Value = property.id; command.Parameters.Add("@tp", MySqlDbType.Int32).Value = property.type; command.Parameters.Add("@size", MySqlDbType.VarChar).Value = property.size; command.Parameters.Add("@price", MySqlDbType.VarChar).Value = property.price; command.Parameters.Add("@adrs", MySqlDbType.VarChar).Value = property.address; command.Parameters.Add("@bedr", MySqlDbType.Int32).Value = property.bedrooms; command.Parameters.Add("@bathr", MySqlDbType.Int32).Value = property.bathrooms; command.Parameters.Add("@age", MySqlDbType.Int32).Value = property.age; command.Parameters.AddWithValue("@balc", property.balcony); command.Parameters.AddWithValue("@backy", property.backyard); command.Parameters.AddWithValue("@pool", property.pool); command.Parameters.AddWithValue("@grg", property.garage); command.Parameters.AddWithValue("@fire", property.fireplace); command.Parameters.Add("@cmnt", MySqlDbType.VarChar).Value = property.comment; return(func.ExecQuery(command)); }
// insert a new property public Boolean insertProperty(THE_PROPERTY property) { MySqlCommand command = new MySqlCommand("INSERT INTO `the_property`(`type`, `square_feet`, `price`, `address`, `bedrooms`, `bathrooms`, `age`, `balcony`, `backyard`, `pool`, `garage`, `fireplace`, `comment`) VALUES (@tp,@size,@price,@adrs,@bedr,@bathr,@age,@balc,@backy,@pool,@grg,@fire,@cmnt)"); // (@tp,@size,@owner,@price,@adrs,@bedr,@bathr,@age,@balc,@backy,@pool,@grg,@fire,@cmnt) // command.Parameters.Add("@tp", MySqlDbType.Int32).Value = property.id; command.Parameters.Add("@tp", MySqlDbType.Int32).Value = property.type; command.Parameters.Add("@size", MySqlDbType.VarChar).Value = property.size; // command.Parameters.Add("@owner", MySqlDbType.Int32).Value = property.ownerId; command.Parameters.Add("@price", MySqlDbType.VarChar).Value = property.price; command.Parameters.Add("@adrs", MySqlDbType.VarChar).Value = property.address; command.Parameters.Add("@bedr", MySqlDbType.Int32).Value = property.bedrooms; command.Parameters.Add("@bathr", MySqlDbType.Int32).Value = property.bathrooms; command.Parameters.Add("@age", MySqlDbType.Int32).Value = property.age; command.Parameters.AddWithValue("@balc", property.balcony); command.Parameters.AddWithValue("@backy", property.backyard); command.Parameters.AddWithValue("@pool", property.pool); command.Parameters.AddWithValue("@grg", property.garage); command.Parameters.AddWithValue("@fire", property.fireplace); command.Parameters.Add("@cmnt", MySqlDbType.VarChar).Value = property.comment; return(func.ExecQuery(command)); }