Пример #1
0
        public PartialViewResult ListaAnalisisMov(string dwtienda, string fecini, string fecfinc, string articulo, string talla)
        {
            if (dwtienda == null)
            {
                dwtienda = Session["Tienda"].ToString();
            }

            string _cod_art = Basico.Left(articulo, 7);
            string _calidad = Basico.Right(articulo, 1);

            if (talla.Trim().Length == 0)
            {
                talla = "-1";
            }

            List <Ent_Analisis_Mov> lista_mov = lista(dwtienda, Convert.ToDateTime(fecini), Convert.ToDateTime(fecfinc), _cod_art, _calidad, talla);

            Int32 inicial = 0; Int32 saldo = 0;

            if (lista_mov != null)
            {
                if (lista_mov.Count > 0)
                {
                    Int32 filas = lista_mov.Count();
                    inicial = lista_mov.Where(i => i.item == 1).Sum(s => s.inicial);
                    saldo   = lista_mov.Where(i => i.item == filas).Sum(s => s.saldo);
                }
            }
            ViewBag.inicial = inicial;
            ViewBag.saldo   = saldo;
            return(PartialView(lista_mov));
        }
Пример #2
0
        /// <summary>
        /// Realizar facturacion
        /// </summary>
        /// <returns></returns>
        public void invoice()
        {
            /// Instanciar
            _InvHdrVM = new Invoice_HdrViewModel();

            /// 1ero. Verificar el tipo de cliente, si es CEDI realizar traspaso, si es cliente realizar factura
            ///
            if (!_CustomerType.Equals(_typeCoordCedi))
            {
                /// Coordinador tipo cliente comun
                ///

                string grabar_numerodoc = Venta.insertar_venta(Liquidation_Hdr._liq_id);
                //String newNoInvoice = _InvHdrVM.doInvoice(_noLiquidation,0);
                ///
                if (!grabar_numerodoc.Equals("-1"))
                {
                    ///
                    lblMessage.Text = " > Factura generada con exito - Número : " + grabar_numerodoc + ".";
                    ///
                    this.afterInvoice();
                    try
                    {
                        string _codigo_hash = "";
                        string _error       = "";
                        Facturacion_Electronica.ejecutar_factura_electronica(Basico.Left(grabar_numerodoc, 1), grabar_numerodoc, ref _codigo_hash, ref _error);



                        if (_error.Length > 0)
                        {
                            MessageBox.Show("ERROR EN LA GENERACION POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")", ValuesDB.captionHeaderErrorWindow, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                            return;
                        }

                        //EN ESTE PASO VAMOS A GRABAR EL CODIGO HASH
                        Facturacion_Electronica.insertar_codigo_hash(grabar_numerodoc, _codigo_hash, "V");
                        ///
                        // es para enviar a imprimir a la ticketera
                        ReportInvoiceWindow._idv_invoice = grabar_numerodoc;
                        ReportInvoiceWindow rpI = new ReportInvoiceWindow();
                        rpI.Show();

                        try
                        {
                            int    varOriginal = 1;
                            string noInvoice   = grabar_numerodoc.ToUpper();
                            string _genera_tk  = Impresora_Epson.Config_Imp.GenerarTicketFact(grabar_numerodoc, 1, _codigo_hash);

                            if (_genera_tk == null)
                            {
                                lblMessageErrTick.Text = " >> Se producjo un error en la impresion del ticket";
                            }
                            else
                            {
                                lblMessageErrTick.Text = " > Ticket Generado con exito";
                            }
                        }
                        catch (Exception ex)
                        {
                            lblMessageErrTick.Text = ex.Message;
                        }
                    }
                    catch
                    {
                        lblMessage.Text += " > Imposible generar reporte local; se enviara a { Aquarella } Web, espere por favor.";
                    }
                }
                else
                {
                    this.afterInvoice();
                    /// Problemas en la generacion de la factura
                    lblMessage.Foreground = Brushes.Maroon;
                    ///
                    lblMessage.Text = " > Ha ocurrido un problema y no se ha podido generar la factura.";
                    ///
                    MessageBox.Show("Ha ocurrido un problema y no se ha podido generar la factura.",
                                    ValuesDB.captionHeaderErrorWindow, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            else if (_CustomerType.Equals(_typeCoordCedi))
            {
                /// Coordinador tipo CEDI
                /// REALIZAR UN TRASPASO DE BODEGA NO UNA FACTURA
                _WhtranVM = new WhtransfersViewModel();
                /// 0 documento de salida, 1 documento de entrada
                String[] trax = new String[2];
                ///
                trax = _WhtranVM.saveWhTransference(_noLiquidation);
                ///
                if (trax != null && trax.Length > 0)
                {
                    ///
                    lblMessage.Text = " > Factura generada con exito - Número : " + trax[0] + ".";
                    ///
                    this.afterInvoice();
                }
                else
                {
                    this.afterInvoice();
                    /// Problemas en la generacion de la factura
                    lblMessage.Foreground = Brushes.Maroon;
                    ///
                    lblMessage.Text = " > Ha ocurrido un problema y no se ha podido generar la factura.";
                    ///
                    MessageBox.Show("Ha ocurrido un problema y no se ha podido generar la factura.",
                                    ValuesDB.captionHeaderErrorWindow, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            ///return null;
        }
Пример #3
0
        private async void facturar()
        {
            var metroWindow = this;

            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogOptions.ColorScheme;
            ProgressDialogController ProgressAlert = null;

            try
            {
                Int32 _valida = await valida_facturar();

                if (_valida == 1)
                {
                    return;
                }


                var mySettings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Si",
                    NegativeButtonText    = "No",
                    //FirstAuxiliaryButtonText = "Cancelar",
                    ColorScheme = MetroDialogOptions.ColorScheme,
                };

                var okSettings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Ok",
                    ColorScheme           = MetroDialogOptions.ColorScheme,
                };


                MessageDialogResult result = await this.ShowMessageAsync(Ent_Msg.msginfomacion, "¿Realmente desea FACTURAR este pedido ? " + _liq_id,
                                                                         MessageDialogStyle.AffirmativeAndNegative, mySettings);


                if (result == MessageDialogResult.Affirmative)
                {
                    string _error_venta = "";
                    //Mouse.OverrideCursor = Cursors.Wait;
                    ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Generando Facturación Electrónica del pedido N°:" + _liq_id);  //show message

                    ProgressAlert.SetIndeterminate();
                    string grabar_numerodoc = await Task.Run(() => Dat_Venta.insertar_venta(_liq_id, ref _error_venta));

                    //if (grabar_numerodoc == "0")
                    //{
                    //    //string _error = "";
                    //    lblmensaje.Content = "El número de pedido "+ _liq_id + " ya fue facturado posiblemente por tienda , actualice la bandeja de pedidos.";
                    //    return;

                    //}

                    //string grabar_numerodoc = Dat_Venta.insertar_venta(_liq_id);

                    if (grabar_numerodoc != "-1")
                    {
                        lblmensaje.Content = " > Factura generada con exito - Número : " + grabar_numerodoc + ".";
                        ///
                        deshabilita_controles();

                        //aca generamos el codigo hash
                        string _codigo_hash = "";
                        string _error       = "";
                        string _url_pdf     = "";

                        await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica(Basico.Left(grabar_numerodoc, 1), grabar_numerodoc, ref _codigo_hash, ref _error, ref _url_pdf));

                        //await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica_ws (Basico.Left(grabar_numerodoc, 1), grabar_numerodoc, ref _codigo_hash, ref _error,ref _url_pdf));

                        //*************


                        //****enviar los xml al server

                        if (_codigo_hash.Length == 0 || _codigo_hash == null)
                        {
                            await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica(Basico.Left(grabar_numerodoc, 1), grabar_numerodoc, ref _codigo_hash, ref _error, ref _url_pdf));
                        }
                        if (_codigo_hash.Length == 0 || _codigo_hash == null)
                        {
                            _error = "GENERACION DE HASH";
                            await ProgressAlert.CloseAsync();

                            await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA GENERACION POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);

                            _error = "";
                            //MessageBox.Show("ERROR EN LA GENERACION POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")", Ent_Msg.msginfomacion,MessageBoxButton.OK,MessageBoxImage.Error);
                            //return;
                        }

                        if (_error.Length > 0)
                        {
                            await ProgressAlert.CloseAsync();

                            await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA GENERACION POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);

                            //MessageBox.Show("ERROR EN LA GENERACION POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")", Ent_Msg.msginfomacion,MessageBoxButton.OK,MessageBoxImage.Error);
                            return;
                        }

                        //await Task.Run(() => Basico._enviar_webservice_xml()); ==>>SE COMENTO PORQUE YA NO SE TRABAJA CON FACTURACION ELECTRONICA CARVAJAL
                        //EN ESTE PASO VAMOS A GRABAR EL CODIGO HASH
                        if (_codigo_hash.Length > 0)
                        {
                            await Task.Run(() => Dat_Venta.insertar_codigo_hash(grabar_numerodoc, _codigo_hash, "V", _url_pdf));
                        }
                        ///
                        //byte[] img_qr = null;
                        string _genera_tk = await Task.Run(() => Imprimir_Doc.Generar_Impresion("F", grabar_numerodoc) /*Impresora_Epson.Config_Imp.GenerarTicketFact(grabar_numerodoc, 1, _codigo_hash)*/);

                        /*IMPRESION DE ETIQUETAS*/
                        if (Ent_Global._canal_venta == "AQ")
                        {
                            GenerarEtiqueta genera_etiqueta = new GenerarEtiqueta();
                            await Task.Run(() => genera_etiqueta.aq_imp_etiqueta2(grabar_numerodoc));
                        }

                        #region <SOLO PARA E-CCOMMERCE>

                        if (Ent_Global._canal_venta == "BA")
                        {
                            string _cod_urbano = "";
                            //-----INICIO---SB-VTEX2020---20201222_12:57--
                            //await Task.Run(() => Basico.act_presta_urbano(grabar_numerodoc, ref _error, ref _cod_urbano));
                            await Task.Run(() => Basico.act_presta_urbano(grabar_numerodoc, "", ref _error, ref _cod_urbano));

                            //-----FIN---SB-VTEX2020---20201222_12:57--
                            //string mensaje_urb = (_cod_urbano.Trim().Length == 0) ? "" : "Se envío correctamente la solicitud a Urbano, Nro guía obtenida: " + _cod_urbano + "\n\n";
                            await ProgressAlert.CloseAsync();

                            string msj_eccomer = "";

                            /*si el codigo de urbano esta null entonces no va el mensaje*/
                            if (_cod_urbano.Trim().Length > 0)
                            {
                                msj_eccomer = "Se Genero correctamente la factura nro: " + grabar_numerodoc + "\n"
                                              + "Se envío correctamente la solicitud al Courier, Nro guía obtenida: " + _cod_urbano + "\n\n"
                                              + "¿Desea imprimir la etiqueta de este pedido? " + _liq_id;

                                MessageDialogResult resultetiq = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.AffirmativeAndNegative, mySettings);

                                if (resultetiq == MessageDialogResult.Affirmative)
                                {
                                    ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Generando Facturacion Electronica del pedido N°:" + _liq_id);  //show message

                                    ProgressAlert.SetIndeterminate();
                                    /*FALTA PONER LA VALIDACION DE LA ETIQUETA*/
                                    //resultetiq
                                    GenerarEtiqueta genera_etiqueta = new GenerarEtiqueta();
                                    //-----INICIO---SB-VTEX2020---20201222_12:57--
                                    //await Task.Run(() => genera_etiqueta.imp_etiqueta2(grabar_numerodoc));
                                    await Task.Run(() => genera_etiqueta.imp_etiqueta2(grabar_numerodoc, ""));

                                    //-----FIN---SB-VTEX2020---20201222_12:57--
                                }
                                else
                                {
                                    ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Generando Facturacion Electronica del pedido N°:" + _liq_id);  //show message

                                    ProgressAlert.SetIndeterminate();
                                }
                                // await ProgressAlert.CloseAsync();
                            }
                            else
                            {
                                msj_eccomer = "Se Genero correctamente la factura nro: " + grabar_numerodoc + "\n"
                                              + "No se pudo enviar la solicitud a Courier.\n\n";
                                MessageDialogResult resultetiq = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.Affirmative, okSettings);
                            }

                            //await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);
                        }
                        #endregion

                        //string _genera_tk = Impresora_Epson.Config_Imp.GenerarTicketFact(grabar_numerodoc, 1, _codigo_hash);

                        if (_genera_tk == null)
                        {
                            lbltickets.Content = " >> Se producjo un error en la impresion del ticket";
                        }
                        else
                        {
                            lbltickets.Content = " > Ticket Generado con exito";
                        }
                        Reporte_Guia_Remision._idv_invoice = grabar_numerodoc;
                        Reporte_Guia_Remision form = new Reporte_Guia_Remision();
                        form.Show();

                        if (ProgressAlert.IsOpen)
                        {
                            await ProgressAlert.CloseAsync();
                        }
                    }
                    else
                    {
                        deshabilita_controles();
                        lblmensaje.Foreground = Brushes.Maroon;
                        ///
                        //lblmensaje.Content = " > Ha ocurrido un problema y no se ha podido generar la factura.";
                        lblmensaje.Content = _error_venta;
                        ///
                        await ProgressAlert.CloseAsync();

                        await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, _error_venta, MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);
                    }
                }
            }
            catch (Exception exc)
            {
                deshabilita_controles();
                lblmensaje.Foreground = Brushes.Maroon;
                ///
                lblmensaje.Content = exc.Message;
                ///
                if (ProgressAlert != null)
                {
                    await ProgressAlert.CloseAsync();
                }
                await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, exc.Message, MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);
            }
            //Mouse.OverrideCursor = null;
        }