Exemplo n.º 1
0
        public bool AgregarHabitacion(int numero, string tipoCama, string accesorios, int precio)
        {
            ServiceHabitacion sh = new ServiceHabitacion();

            try
            {
                // Habitacion
                HABITACION h = new HABITACION();
                h.IDHABITACION     = sh.id();
                h.NUMERO           = numero;
                h.TIPO_CAMA        = tipoCama;
                h.ACCESORIOS       = accesorios;
                h.PRECIO           = precio;
                h.IDADMINISTRADOR  = 1;
                h.ESTADOHABITACION = 1;

                if (this.BuscarHabitacion((int)h.NUMERO) == false)
                {
                    if ((int)h.NUMERO >= 0)
                    {
                        if (h.PRECIO >= 0)
                        {
                            sh.addEntity(h);
                            MessageBox.Show("Habitacion Agregada.", "Agregar Habitacion", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return(true);
                        }
                        else
                        {
                            MessageBox.Show("El precio debe ser mayor o igual a 0.", "Agregar Habitacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return(false);
                        }
                    }
                    else
                    {
                        MessageBox.Show("La habitacion: " + h.NUMERO + " debe ser mayor o igual a 0.", "Agregar Habitacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("La habitacion: " + h.NUMERO + " ya existe.", "Agregar Habitacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se pudo crear la habitacion.", "Crear Habitacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }