private void Guardar() { lblResultado.Text = string.Empty; Reserva reserva = new Reserva(); string mensaje = Estaticas.Validaciones(Controls); if (mensaje != "") { MessageBox.Show(mensaje, "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { if (_tipo != AbmTipo.Alta) { reserva.Id = int.Parse(txtIdReserva.Text); } reserva.IdHabitacion = int.Parse(txtIdHabitacion.Text); reserva.IdCliente = int.Parse(txtIdCliente.Text); reserva.CantidadHuespedes = int.Parse(txtNroHuespedes.Text); reserva.FechaIngreso = dtFechaIngreso.Value; reserva.FechaEgreso = dtFechaEgreso.Value; if (_hh == null) { _hh = _hotelServicios.TraerTodoPorId(int.Parse(txtIdHotel.Text)).SingleOrDefault(x => x.Id == reserva.IdHabitacion); if (_hh == null) { throw new ReservasException("Debe seleccionar una habitacion valida."); } } int resultado = -1; switch (_tipo) { case AbmTipo.Alta: resultado = _hotelServicios.IngresarReserva(reserva, _hh); LogHelper.LogResultado(lblResultado, resultado, "Ingresar Reserva"); break; case AbmTipo.Modificacion: resultado = _hotelServicios.ModificarReserva(reserva, _hh); LogHelper.LogResultado(lblResultado, resultado, "Modificar Reserva"); break; } this.DialogResult = DialogResult.OK; } catch (Exception e) { LogHelper.LogResultado(lblResultado, false, e.Message); } } }
private void Guardar() { //lblResultado.Text = ""; string mensaje = Estaticas.Validaciones(Controls); if (mensaje != "") { MessageBox.Show(mensaje, "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!ValidationHelper.IsValidEmail(txtMail.Text)) { MessageBox.Show("Email invalido", "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { Cliente cliente = new Cliente(); if (_tipo != AbmTipo.Alta) { cliente.Id = int.Parse(txtIdCliente.Text); } cliente.Dni = int.Parse(txtDni.Text); cliente.Nombre = txtNombre.Text; cliente.Apellido = txtApellido.Text; cliente.Direccion = txtDireccion.Text; cliente.Email = txtMail.Text; cliente.Telefono = int.Parse(txtTelefono.Text); int resultado = -1; switch (_tipo) { case AbmTipo.Alta: resultado = _clienteServicios.IngresarCliente(cliente); LogHelper.LogResultado(lblResultado, resultado, "Ingresar Cliente"); break; case AbmTipo.Modificacion: resultado = _clienteServicios.ModificarCliente(cliente); LogHelper.LogResultado(lblResultado, resultado, "Modificar Cliente"); break; } this.DialogResult = DialogResult.OK; } catch (Exception e) { LogHelper.LogResultado(lblResultado, false, e.Message); } } }
private void Guardar() { lblResultado.Text = ""; Habitacion habitacion = new Habitacion(); string mensaje = Estaticas.Validaciones(Controls); if (mensaje != "") { MessageBox.Show(mensaje, "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { if (_tipo != AbmTipo.Alta) { habitacion.Id = int.Parse(txtIdHabitacion.Text); } habitacion.IdHotel = _idHotel; habitacion.Categoria = txtCategoria.Text; habitacion.CantidadPlazas = int.Parse(txtCantidadPlazas.Text); habitacion.Cancelable = cbCancelable.Checked; habitacion.Precio = double.Parse(txtPrecio.Text); int resultado = -1; switch (_tipo) { case AbmTipo.Alta: resultado = _hotelServicios.IngresarHabitacion(habitacion); LogHelper.LogResultado(lblResultado, resultado, "Ingresar Habitacion"); break; case AbmTipo.Modificacion: resultado = _hotelServicios.ModificarHabitacion(habitacion); LogHelper.LogResultado(lblResultado, resultado, "Modificar Habitacion"); break; } this.DialogResult = DialogResult.OK; } catch (Exception e) { LogHelper.LogResultado(lblResultado, false, e.Message); } } }
private void Guardar() { lblResultado.Text = ""; Hotel hotel = new Hotel(); string mensaje = Estaticas.Validaciones(Controls); if (mensaje != "") { MessageBox.Show(mensaje, "Datos invalidos", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { if (_tipo != AbmTipo.Alta) { hotel.Id = int.Parse(txtIdHotel.Text); } hotel.Nombre = txtNombre.Text; hotel.Direccion = txtDireccion.Text; hotel.Amenities = cbAmenities.Checked; hotel.Estrellas = int.Parse(nuEstrellas.Value.ToString()); int resultado = -1; switch (_tipo) { case AbmTipo.Alta: resultado = _hotelServicios.IngresarHotel(hotel); LogHelper.LogResultado(lblResultado, resultado, "Ingresar Hotel"); break; case AbmTipo.Modificacion: resultado = _hotelServicios.ModificarHotel(hotel); LogHelper.LogResultado(lblResultado, resultado, "Modificar Hotel"); break; } this.DialogResult = DialogResult.OK; } catch (Exception e) { LogHelper.LogResultado(lblResultado, false, e.Message); } } }