Compare commits
No commits in common. "add78b3a4a3520f73be6a1beb50033438eb9c2c6" and "fff5fe4523ff914d2eb4739d26fe4b9aa2c623e0" have entirely different histories.
add78b3a4a
...
fff5fe4523
|
@ -5,55 +5,33 @@ import android.os.Bundle
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
|
||||||
|
|
||||||
class compra: AppCompatActivity() {
|
class compra: AppCompatActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.pantallacompra)
|
setContentView(R.layout.pantallacompra)
|
||||||
|
|
||||||
val btnComprar: Button = findViewById(R.id.buttonComprar)
|
val btnCancelar: Button = findViewById(R.id.buttonCancelar)
|
||||||
val editTextNombre: EditText = findViewById(R.id.editTextNombre)
|
val editTextNombre: EditText = findViewById(R.id.editTextNombre)
|
||||||
val editTextTelefono: EditText = findViewById(R.id.editTextTelefono)
|
val editTextTelefono: EditText = findViewById(R.id.editTextTelefono)
|
||||||
|
val btnComprar: Button = findViewById(R.id.buttonComprar)
|
||||||
|
|
||||||
btnComprar.setOnClickListener {
|
btnComprar.setOnClickListener {
|
||||||
val nombre = editTextNombre.text.toString()
|
val nombre = editTextNombre.text.toString()
|
||||||
val telefono = editTextTelefono.text.toString()
|
val telefono = editTextTelefono.text.toString()
|
||||||
|
|
||||||
// Verifica si se ingresó un nombre y un teléfono antes de mostrar el mensaje
|
|
||||||
if (nombre.isNotEmpty() && telefono.isNotEmpty()) {
|
if (nombre.isNotEmpty() && telefono.isNotEmpty()) {
|
||||||
val mensaje = "Nombre: $nombre\nTeléfono: $telefono"
|
val mensaje = "Nombre: $nombre\nTeléfono: $telefono"
|
||||||
mostrarMensaje(mensaje)
|
Toast.makeText(this, mensaje, Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
} else {
|
||||||
mostrarAlerta("Error", "Por favor, ingrese su nombre y número de teléfono")
|
Toast.makeText(this, "Por favor, ingrese su nombre y número de teléfono", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val btnCancelar: Button = findViewById(R.id.buttonCancelar)
|
|
||||||
|
|
||||||
btnCancelar.setOnClickListener {
|
btnCancelar.setOnClickListener {
|
||||||
val intent = Intent(this, EventList::class.java)
|
val intent = Intent(this, ChairList::class.java)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mostrarMensaje(mensaje: String) {
|
|
||||||
val builder = AlertDialog.Builder(this)
|
|
||||||
builder.setTitle("Datos de la compra")
|
|
||||||
builder.setMessage(mensaje)
|
|
||||||
builder.setPositiveButton("Aceptar", null)
|
|
||||||
val dialog = builder.create()
|
|
||||||
dialog.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun mostrarAlerta(titulo: String, mensaje: String) {
|
|
||||||
val builder = AlertDialog.Builder(this)
|
|
||||||
builder.setTitle(titulo)
|
|
||||||
builder.setMessage(mensaje)
|
|
||||||
builder.setPositiveButton("Aceptar", null)
|
|
||||||
val dialog = builder.create()
|
|
||||||
dialog.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue