예제 #1
0
        private void CargarDatos()
        {
            IBLLHabitacion _IBLLHabitacion = new BLLHabitacion();

            //IBLLBodega _BLLBodega = new BLLBodega();
            //List<Bodega> lista = null;

            // Cambiar el estado
            this.CambiarEstado(EstadoMantenimiento.Ninguno);

            // Configuracion del DataGridView para que se vea bien la imagen.
            dgvDatos.AutoGenerateColumns = false;
            dgvDatos.RowTemplate.Height  = 100;
            dgvDatos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells;


            this.pbImagen.Enabled = false;

            // Cargar el DataGridView
            this.dgvDatos.DataSource = _IBLLHabitacion.GetAllHabitacion();


            // Colocar el primero como default



            this.pbImagen.SizeMode = PictureBoxSizeMode.CenterImage;
        }
예제 #2
0
        private void EstadoHabitaciones()
        {
            IBLLHabitacion _BLLHabitacion = new BLLHabitacion();

            Habitacion oHabitacion = null;

            oHabitacion = new Habitacion();


            oHabitacion.NUM = double.Parse(this.txtNumHabitacion.Text);

            oHabitacion.Descripcion = _BLLHabitacion.GetHabitacionById(double.Parse(this.txtNumHabitacion.Text)).Descripcion;

            oHabitacion.Foto = _BLLHabitacion.GetHabitacionById(double.Parse(this.txtNumHabitacion.Text)).Foto;

            oHabitacion.Precio = _BLLHabitacion.GetHabitacionById(double.Parse(this.txtNumHabitacion.Text)).Precio;


            if (_BLLHabitacion.GetHabitacionById(double.Parse(this.txtNumHabitacion.Text)).Estado == 2)
            {
                oHabitacion.Estado = 1;
            }



            oHabitacion = _BLLHabitacion.SaveHabitacion(oHabitacion);

            //_BLLHabitacion.SaveHabitacion(oHabitacion);
        }
예제 #3
0
        private void toolStripBtnBuscar_Click(object sender, EventArgs e)
        {
            IBLLHabitacion _BLLHabitacion = new BLLHabitacion();
            double         filtro         = 0;

            try
            {
                //filtro = Double.Parse(this.txtFiltro.Text);

                this.dgvDatos.AutoGenerateColumns = false;
                this.dgvDatos.DataSource          = _BLLHabitacion.GetAllHabitacion();
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                MessageBox.Show(msg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
        private void toolStripBtnBorrar_Click(object sender, EventArgs e)
        {
            IBLLHabitacion _BLLHabitacion = new BLLHabitacion();

            try
            {
                if (this.dgvDatos.SelectedRows.Count > 0)
                {
                    this.CambiarEstado(EstadoMantenimiento.Borrar);

                    HabitacionDTO oHabitacionDTO = this.dgvDatos.SelectedRows[0].DataBoundItem as HabitacionDTO;
                    if (MessageBox.Show($"¿Seguro que desea borrar el registro {oHabitacionDTO.NUM} {oHabitacionDTO.Descripcion}?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        _BLLHabitacion.DeleteHabitacion(oHabitacionDTO.NUM);
                        this.CargarDatos();
                    }
                }
                else
                {
                    MessageBox.Show("Seleccione el registro !", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                // Log error
                //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                // Mensaje de Error
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            Habitacion oHabitacion = null;

            try
            {
                IBLLHabitacion _IBLLHabitacion = new BLLHabitacion();


                if (this.pbImagen.Tag == null)
                {
                    MessageBox.Show("La Imagen  es un dato requerido !", "Atención");
                    return;
                }



                oHabitacion = new Habitacion();


                oHabitacion.NUM = double.Parse(this.mskCodigo.Text);

                oHabitacion.Descripcion = this.mskDescripcion.Text;

                oHabitacion.Foto = (byte[])this.pbImagen.Tag;

                oHabitacion.Precio = double.Parse(this.txtPrecio.Text);



                if (chkDisponible.Checked == true)
                {
                    oHabitacion.Estado = 1;
                }

                else
                {
                    oHabitacion.Estado = 2;
                }



                oHabitacion = _IBLLHabitacion.SaveHabitacion(oHabitacion);

                if (oHabitacion != null)
                {
                    this.CargarDatos();
                }

                this.txtPrecio.Text = "";
                this.pbImagen.Image = null;
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                // Log error
                //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                // Mensaje de Error
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #6
0
        private void toolStripBtnFacturar_Click(object sender, EventArgs e)
        {
            IBLLEncFactura _BLLFactura    = new BLLEncFactura();
            IBLLTarjeta    _BLLTarjeta    = new BLLTarjeta();
            IBLLHuesped    _BLLHuesped    = new BLLHuesped();
            IBLLHabitacion _BLLHabitacion = new BLLHabitacion();

            IBLLImpuesto _BLLImpuesto = new BLLImpuesto();

            DetFactura oFacturaDetalle = new DetFactura();

            this.cmbEstado.SelectedIndex = 1;

            IBLLReservacion _BLLReservacion = new BLLReservacion();


            Tarjeta oTarjeta      = new Tarjeta();
            string  rutaImagen    = @"c:\temp\qr.png";
            double  numeroFactura = 0d;

            try
            {
                _FacturaEncabezado = new EncFactura()
                {
                    IDFactura  = Double.Parse(this.txtNumeroFactura.Text),
                    _Tarjeta   = cmbTarjeta.SelectedItem as Tarjeta,//_BLLTarjeta.GetTarjetaById(Double.Parse(this.txtNumeroTarjeta.Text)),
                    Fecha      = DateTime.Now.Date,
                    EstadoFact = this.cmbEstado.SelectedIndex.ToString(),
                };

                oFacturaDetalle._EncFactura  = _BLLFactura.GetFactura(Double.Parse(this.txtNumeroFactura.Text));
                oFacturaDetalle._Reservacion = _BLLReservacion.GetReserva(Double.Parse(this.mskIDReserva.Text.ToString()));



                oFacturaDetalle.Precio = Double.Parse(this.txtPrecio.Text.ToString());

                // Calcular el Impuesto
                IBLLImpuesto _BLLImpuestotest = new BLLImpuesto();
                oFacturaDetalle._Impuesto = _BLLImpuestotest.GetImpuesto();
                // Enumerar la secuencia
                oFacturaDetalle.Numero = _FacturaEncabezado._ListaFacturaDetalle.Count == 0 ?
                                         1 : _FacturaEncabezado._ListaFacturaDetalle.Max(p => p.Numero) + 1;

                ;
                // Agregar
                _FacturaEncabezado.AddDetalle(oFacturaDetalle);


                if (_FacturaEncabezado == null)
                {
                    MessageBox.Show("No hay datos por facturar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (_FacturaEncabezado._ListaFacturaDetalle.Count == 0)
                {
                    MessageBox.Show("No hay items en la factura ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                this.txtSubtotal.Text = _FacturaEncabezado.GetSubTotal().ToString();
                this.txtImpuesto.Text = _FacturaEncabezado.GetImpuesto().ToString();
                this.txtTotal.Text    = (_FacturaEncabezado.GetSubTotal() + (_FacturaEncabezado.GetImpuesto())).ToString();

                _FacturaEncabezado = _BLLFactura.SaveFactura(_FacturaEncabezado);

                numeroFactura = _BLLFactura.GetCurrentNumeroFactura();

                EstadoHabitaciones();

                if (_FacturaEncabezado == null)
                {
                    MessageBox.Show("Error al crear factura!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                //toolStripBtnNuevo_Click(null, null);


                // Si existe borrelo
                if (File.Exists(rutaImagen))
                {
                    File.Delete(rutaImagen);
                }


                // Crear imagen quickresponse
                Image quickResponseImage = QuickResponse.QuickResponseGenerador(numeroFactura.ToString(), 53);



                // Salvarla en c:\temp para luego ser leida
                quickResponseImage.Save(rutaImagen, ImageFormat.Png);

                frmFacturaImpresion ofrmFacturaImpresion = new frmFacturaImpresion((int)numeroFactura, _BLLHuesped.GetHuespedById(Double.Parse(this.txtIdHuesped.Text)).Nombre);


                ofrmFacturaImpresion.ShowDialog();


                this.txtNumeroTarjeta.Text    = "";
                this.txtNumHabitacion.Text    = "";
                this.txtNUMDetalle.Text       = "1";
                this.txtImpuesto.Text         = "";
                this.txtIdHuesped.Text        = "";
                this.txtCantDias.Text         = "";
                this.txtPrecio.Text           = "";
                this.txtSubtotal.Text         = "";
                this.txtTotal.Text            = "";
                this.cmbEstado.SelectedIndex  = 0;
                this.cmbTarjeta.SelectedIndex = 0;
                this.Subtotal.Text            = "";
                this.mskIDReserva.Text        = "";
                this.dgvDetalleFactura.Rows.Clear();
                this.dgvDetalleFactura.Refresh();
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                // Log error
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                // Mensaje de Error
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #7
0
        private void toolStripBtnReservar_Click(object sender, EventArgs e)
        {
            try
            {
                Reservacion oReservacion = null;

                IBLLReservacion _IBLLReservacion = new BLLReservacion();

                IBLLHabitacion _BLLHabitacion = new BLLHabitacion();

                IBLLHuesped _BLLHuesped = new BLLHuesped();

                if (this.txtHuespedId == null)
                {
                    MessageBox.Show(" Es un dato requerido !", "Atención");
                    return;
                }



                oReservacion = new Reservacion();

                oReservacion.ID = double.Parse(this.txtNumeroReservacion.Text);

                oReservacion._Huesped = _BLLHuesped.GetHuespedById(double.Parse(this.txtHuespedId.Text.ToString()));

                oReservacion._Habitacion = _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString()));


                foreach (var item in _IBLLReservacion.GetAllReservacion())
                {
                    if (item.CheckIN.DayOfYear <= this.dtpCheckIN.Value.DayOfYear && item.CheckOUT.DayOfWeek > this.dtpCheckOut.Value.DayOfWeek &&


                        item.CheckIN.Month == this.dtpCheckIN.Value.Month

                        && item._Habitacion.NUM == _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).NUM)
                    {
                        MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención");
                        return;
                    }
                    //else
                    //{

                    //    if (item.CheckIN.Day < this.dtpCheckIN.Value.Day &&

                    //    item.CheckIN.Month == this.dtpCheckIN.Value.Month)
                    //    {
                    //        MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención");
                    //        return;
                    //    }

                    //}


                    if (item.CheckOUT.DayOfYear == this.dtpCheckOut.Value.DayOfYear && item.CheckOUT.Month == this.dtpCheckOut.Value.Month &&

                        item._Habitacion.NUM == _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).NUM)
                    {
                        MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención");
                        return;
                    }
                    //else
                    //{

                    //    if (item.CheckOUT.Day > this.dtpCheckOut.Value.Day

                    //    && item.CheckOUT.Month == this.dtpCheckOut.Value.Month)
                    //    {
                    //        MessageBox.Show(" La Habitacion se encuantra Ocupada !", "Atención");
                    //        return;
                    //    }

                    //}
                }



                if (this.dtpCheckIN.Value.DayOfYear < DateTime.Now.DayOfYear || this.dtpCheckIN.Value.Month < DateTime.Now.Month)
                {
                    MessageBox.Show(" No puede reservar fechas anteriores a la actual !", "Atención");
                    return;
                }


                if (this.dtpCheckOut.Value.DayOfYear < DateTime.Now.DayOfYear || this.dtpCheckOut.Value.Month < DateTime.Now.Month

                    || this.dtpCheckOut.Value.DayOfYear < this.dtpCheckIN.Value.DayOfYear || this.dtpCheckOut.Value.Month < dtpCheckIN.Value.Month)
                {
                    MessageBox.Show(" No puede reservar fechas anteriores a la actual !", "Atención");
                    return;
                }


                oReservacion.CheckIN = (DateTime)this.dtpCheckIN.Value;

                oReservacion.CheckOUT = (DateTime)this.dtpCheckOut.Value;

                oReservacion.CantDias = double.Parse(this.mskCantidad.Text);

                oReservacion.Subtotal = double.Parse(this.mskCantidad.Text) * _BLLHabitacion.GetHabitacionById(double.Parse(this.mskNUMHabitacion.Text.ToString())).Precio;

                txtSub.Text = oReservacion.Subtotal.ToString();

                _IBLLReservacion.SaveReserva(oReservacion);

                if (oReservacion != null)
                {
                    this.CargarDatos();
                }
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Message        {0}\n", er.Message);
                msg.AppendFormat("Source         {0}\n", er.Source);
                msg.AppendFormat("InnerException {0}\n", er.InnerException);
                msg.AppendFormat("StackTrace     {0}\n", er.StackTrace);
                msg.AppendFormat("TargetSite     {0}\n", er.TargetSite);
                // Log error
                _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString());
                // Mensaje de Error
                MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }