예제 #1
0
        /// <summary>
        /// Método que hace la facturación del envío
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnFacturar_Click(object sender, EventArgs e)
        {
            IBLLFactura _BLLFactura   = new BLLFactura();
            string      rutaImagen    = @"c:\temp\qr.png";
            string      numeroFactura = "";

            if (pCliente == null)
            {
                MessageBox.Show("Debe Seleccionar un Cliente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (_EncabezadoFactura == null)
            {
                MessageBox.Show("No hay datos por facturar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (_EncabezadoFactura._ListDetFactura.Count == 0)
            {
                MessageBox.Show("No hay items en la factura ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            _EncabezadoFactura = _BLLFactura.GuardarFactura(_EncabezadoFactura);
            numeroFactura      = _EncabezadoFactura.IDEncFactura.ToString();
            pnumerofactura     = numeroFactura;

            if (_EncabezadoFactura == null)
            {
                MessageBox.Show("Error al crear factura!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (File.Exists(rutaImagen))
                {
                    File.Delete(rutaImagen);
                }

                Image quickResponseImage = QuickResponse.QuickResponseGenerador(numeroFactura.ToString(), 53);
                quickResponseImage.Save(rutaImagen, ImageFormat.Png);

                frmReporteFactura ofrmReporteFactura = new frmReporteFactura(pnumerofactura);
                ofrmReporteFactura.ShowDialog();
                if (ofrmReporteFactura.DialogResult == DialogResult.OK || ofrmReporteFactura.DialogResult == DialogResult.Cancel)
                {
                    this.Close();
                }
                else
                {
                    this.Close();
                }
            }
        }
예제 #2
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);
            }
        }