Пример #1
0
        public ActionResult GenerarFactura(FormCollection form)
        {
            string idtraslado = form["selected"];

            if (string.IsNullOrWhiteSpace(idtraslado))
            {
                throw new Exception("Debe seleccionar al menos un translado");
            }
            var translations = idtraslado.Split(new char[] { ',' }).Select(x => Convert.ToInt32(x));
            var bll          = new BLLFactura();
            var factura      = new Cliente();


            factura.IdTipo       = Convert.ToInt32(form["IdTipoComprobante"]);
            factura.IdLetra      = Convert.ToInt32(form["IdLetra"]);
            factura.FechaFactura = Convert.ToDateTime(form["FechaFactura"]);
            factura.IdCliente    = Convert.ToInt32(form["IdCliente"]);
            var user = User.Identity.Name;

            bll.CrearFactura(factura, user);
            var Lista = new System.Collections.ArrayList();

            Lista.Add(new Cliente());
            foreach (int value in translations)
            {
                factura.IdTraslado = value;

                bll.CrearFacturaDetalle(factura, user);
            }
            bll.CrearTotales(factura, user);

            return(RedirectToAction("BuscarComprobante"));
        }
Пример #2
0
        public ActionResult PDF4()
        {
            var bll     = new BLLFactura();
            var factura = new Cliente();
            var doc     = bll.VW_FACTURA_HISTORICO2(GIdFactura);

            Models.FacturaPDFViewModels Vista = MapVista(doc);
            return(View(Vista));
        }
Пример #3
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();
                }
            }
        }
Пример #4
0
        public ActionResult BuscarComprobantes(Cliente factura)
        {
            var bllempresa = new BLLEmpresa();

            ViewData["Cliente"] = bllempresa.AllCliente();
            var fac = new BLLFactura();

            ViewData["ListaFacturas"] = fac.VW_FACTURA_SALDO(factura).ToList();
            var cob = new BLLCobranza();

            ViewData["ListaCobranzas"]       = cob.BuscarCobranza_View(factura).ToList();
            ViewData["SaldoCuentaCorriente"] = cob.SaldoCuentaCorriente(factura).ToList();
            return(View());
        }
Пример #5
0
        public ActionResult BuscarComprobante(Cliente factura)
        {
            var btcomp = new BLLTipoComprobante();

            ViewData["TipoComprobante"] = btcomp.All();
            var letra = new BLLLetra();

            ViewData["Letra"] = letra.All();
            var bllempresa = new BLLEmpresa();

            ViewData["Cliente"] = bllempresa.AllCliente();
            factura.IdTipo      = 1;
            var fac = new BLLFactura();

            ViewData["ListaFacturas"] = fac.VW_FACTURA_CABECERA(factura).ToList();
            return(View());
        }
Пример #6
0
        /// <summary>
        /// Metodo para eliminar un cliente de la base de datos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            IBLLCliente _BLLCliente = new BLLCliente();
            IBLLFactura _BLLFactura = new BLLFactura();

            erpErrores.Clear();
            string IDCliente = "";

            try
            {
                if (string.IsNullOrEmpty(dgvClientes.SelectedRows[0].Cells[0].Value.ToString()))
                {
                    erpErrores.SetError(dgvClientes, "Debe seleccionar un cliente de la lista");
                }
                else
                {
                    IDCliente = dgvClientes.SelectedRows[0].Cells[0].Value.ToString();
                    if (_BLLFactura.ObtenerFacturaByIDCliente(IDCliente) != null)
                    {
                        MessageBox.Show("No se puede eliminar un cliente con registros en la base de datos");
                    }
                    else
                    {
                        _BLLCliente.EliminarCliente(IDCliente);
                        MessageBox.Show("Cliente eliminado");
                    }
                }
            }
            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("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #7
0
        /// <summary>
        /// Metodo para eliminar un mensajero de la base de datos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            IBLLMensajero _BLLMensajero = new BLLMensajero();
            IBLLFactura   _BLLFactura   = new BLLFactura();

            erpErrores.Clear();
            string IDMensajero = "";

            try
            {
                if (dgvMensajeros.SelectedRows.Count == 0)
                {
                    erpErrores.SetError(dgvMensajeros, "Debe seleccionar un valor");
                }
                else
                {
                    IDMensajero = dgvMensajeros.SelectedRows[0].Cells[0].Value.ToString();
                    if (_BLLFactura.ObtenerFacturaByIDMensajero(IDMensajero) != null)
                    {
                        MessageBox.Show("No se pueden borrar mensajeros con registros en la base de datos");
                    }
                    else
                    {
                        _BLLMensajero.EliminarMensajero(IDMensajero);
                        MessageBox.Show("Mensajero eliminado");
                    }
                }
            }
            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("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        public ActionResult Buscar(Cliente factura)
        {
            try
            {
                var btc = new BLLTipoContribuyente();
                ViewData["TipoContribuyente"] = btc.All();
                var btcomp = new BLLTipoComprobante();
                ViewData["TipoComprobante"] = btcomp.All();
                var letra = new BLLLetra();
                ViewData["Letra"] = letra.All();
                var bllempresa = new BLLEmpresa();
                ViewData["Cliente"] = bllempresa.AllCliente();
                var fac = new BLLFactura();
                ViewData["ListaTraslados"] = fac.LISTAR_COMPROBANTE_DETALLE(factura).ToList();

                return(View(factura));
            }
            catch
            {
                return(View());
            }
        }
Пример #9
0
        /// <summary>
        /// Metodo load del form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmProcesos_Load(object sender, EventArgs e)
        {
            IBLLFactura _BLLFactura = new BLLFactura();

            try
            {
                ComponentesIniciales();
                Utilitarios.CulturaInfo();
                this.txtNoFactura.Text = _BLLFactura.GetNextNumeroFactura().ToString();
                llenarCombos();
                Control.CheckForIllegalCrossThreadCalls = false;
            }
            catch (Exception er)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendFormat("Mensaje    :{0}\n", er.Message);
                msg.AppendFormat("Source     :{0}\n", er.Source);
                msg.AppendFormat("StackTrace :{0}\n", er.StackTrace);

                MessageBox.Show(msg.ToString(), "Atención");
            }

            //Marcadores();
        }
Пример #10
0
        /// <summary>
        /// Método que guarda el detalle de factura en el encabezado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            IBLLImpuesto    _BLLImpuesto       = new BLLImpuesto();
            IBLLPrecioEnvio _BLLPrecioEnvio    = new BLLPrecioEnvio();
            IBLLFactura     _BLLFactura        = new BLLFactura();
            DetFactura      oDetFactura        = new DetFactura();
            string          descripcionPaquete = "";
            string          descripcionruta    = "";

            try
            {
                erpErrores.Clear();
                if (_EncabezadoFactura == null)
                {
                    MessageBox.Show("Debe agregar los datos del encabezado de la factura para continuar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (string.IsNullOrEmpty(txtIDMensajero.Text))
                    {
                        erpErrores.SetError(txtIDMensajero, "Debe ingresar la identificación del mensajero");
                        return;
                    }
                    if (string.IsNullOrEmpty(txtNombreMensajero.Text))
                    {
                        erpErrores.SetError(txtNombreMensajero, "Debe ingresar el nombre del mensajero");
                        return;
                    }
                    if (string.IsNullOrEmpty(mskNoTarjeta.Text))
                    {
                        erpErrores.SetError(mskNoTarjeta, "Debe ingresar el número de tarjeta");
                        return;
                    }
                    int cantidad = 0;
                    foreach (var item in mskNoTarjeta.Text)
                    {
                        cantidad++;
                    }
                    if (cantidad < 16)
                    {
                        erpErrores.SetError(mskNoTarjeta, "Debe ingresar un número válido");
                        return;
                    }
                    if (Convert.ToInt32(txtCantidadPaquetes.Text) == 0 || string.IsNullOrEmpty(txtCantidadPaquetes.Text))
                    {
                        erpErrores.SetError(txtCantidadPaquetes, "Debe ingresar un paquete");
                        return;
                    }
                    if ((Convert.ToDouble(txtKilometros.Text) == 0 || string.IsNullOrEmpty(txtKilometros.Text)))
                    {
                        erpErrores.SetError(txtKilometros, "Debe ingresar una ruta válida");
                        return;
                    }
                    if (lstUbicaciones.Items.Count <= 1)
                    {
                        erpErrores.SetError(lstUbicaciones, "Debe ingresar una ruta válida");
                        return;
                    }
                    oDetFactura.CantidadKilometros = (int)Math.Round(Convert.ToDouble(txtKilometros.Text));
                    for (int i = 0; i < lstPaquetes.Items.Count; i++)
                    {
                        descripcionPaquete += lstPaquetes.Items[i].ToString() + "\n";
                    }
                    oDetFactura.DescripcionPaquete = descripcionPaquete;
                    for (int i = 0; i < lstUbicaciones.Items.Count; i++)
                    {
                        descripcionruta += lstUbicaciones.Items[i].ToString() + "\n";
                    }
                    oDetFactura.DescripcionRuta  = descripcionruta;
                    oDetFactura.Impuesto         = Convert.ToDouble(txtImpuesto.Text);
                    oDetFactura.NoFactura        = _EncabezadoFactura.IDEncFactura;
                    oDetFactura.PrecioKilometro  = _BLLPrecioEnvio.MostrarXID(cboTipoEnvio.SelectedItem.ToString()).PrecioRango;
                    oDetFactura.Secuencial       = _BLLFactura.GetNextNumeroFactura();
                    oDetFactura.CantidadPaquetes = Convert.ToInt32(txtCantidadPaquetes.Text);
                    oDetFactura.TipoEnvio        = _BLLPrecioEnvio.MostrarXID(cboTipoEnvio.SelectedItem.ToString());
                    _EncabezadoFactura.AgregrarDetalle(oDetFactura);
                    txtSubTotal.Text       = _EncabezadoFactura.SubTotal() + "";
                    txtTotal.Text          = _EncabezadoFactura.SubTotal() + ((_EncabezadoFactura.SubTotal() * _EncabezadoFactura.Impuesto())) + "";
                    oDetFactura.Total      = _EncabezadoFactura.SubTotal() + ((_EncabezadoFactura.SubTotal() * _EncabezadoFactura.Impuesto()));
                    _EncabezadoFactura.XML = _EncabezadoFactura.GenerarXML();
                    File.WriteAllText(@"c:\temp\proyecto.xml", _EncabezadoFactura.GenerarXML());
                }
            }
            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);
            }
        }