示例#1
0
        private bool Despachar(string ven_id, string nro_guiasecuencia, string id_liquidacion)
        {
            int    _valida_guia;
            string _error      = "";
            string _cod_urbano = "";
            bool   resultado   = true;

            try
            {
                //Dat_ConfigGuia.insertar_guia(nro_guiasecuencia, 1, id_liquidacion, out _valida_guia);

                //if (_valida_guia == 0)
                //{chkactivar_Click
                Dat_ConfigGuia.insertar_guia_remision(ven_id);

                Basico.act_presta_urbano(ven_id, Ent_Global._tienda_id, ref _error, ref _cod_urbano);
                if (_error == "")
                {
                    //IMPRESION CON VISTA PREVIA
                    //Reporte_Guia_Remision_VTEX._idv_invoice = ven_id;
                    //Reporte_Guia_Remision_VTEX._tienda_id = Ent_Global._tienda_id;
                    //Reporte_Guia_Remision_VTEX form = new Reporte_Guia_Remision_VTEX();
                    //form.Show();
                    //IMPRESION DIRECTA
                    ImpresionDirecta objImpresionD = new ImpresionDirecta(); // objeto para la impresion directa
                    objImpresionD.ImpresionD(ven_id, Ent_Global._tienda_id);
                }
                resultado = true;
                //}
                //else
                //{
                //    MessageBox.Show("Es probable que la guia ya exista, por favor dígite un nuevo numero de guia.");
                //    resultado = false;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                resultado = true;
                throw;
            }

            return(resultado);
        }
示例#2
0
        private async void btnenviar_Click(object sender, RoutedEventArgs e)
        {
            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Si",
                NegativeButtonText    = "No",
                ColorScheme           = MetroDialogOptions.ColorScheme,
            };
            var okSettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Aceptar",
                ColorScheme           = MetroDialogOptions.ColorScheme,
            };
            DataRowView row         = (DataRowView)((Button)e.Source).DataContext;
            string      msj_eccomer = "";
            string      _cod_urbano = "";
            string      _error      = "";
            string      _venid      = (string)row["Ven_Id"].ToString();
            //-----INICIO---SB-VTEX2020---20201222_12:57----
            string tienda_id = Ent_Global._tienda_id;

            //-----FIN---SB-VTEX2020---20201222_12:57----

            msj_eccomer = "¿Está seguro de Enviar la Solicitud al courier referente al Doc. Nro. " + _venid + "?";
            MessageDialogResult resultetiq = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.AffirmativeAndNegative, mySettings);

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

                    //-----FIN---SB-VTEX2020---20201222_12:57----



                    /*si el codigo de urbano esta null entonces no va el mensaje*/
                    if (_cod_urbano.Trim().Length > 0)
                    {
                        msj_eccomer = "Se envío correctamente la solicitud al courier, Nro. Código obtenido: " + _cod_urbano + ".\n¿Desea Imprimir la etiqueta de este pedido?";
                        resultetiq  = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.AffirmativeAndNegative, mySettings);

                        if (resultetiq == MessageDialogResult.Affirmative)
                        {
                            GenerarEtiqueta genera_etiqueta = new GenerarEtiqueta();
                            //-----INICIO---SB-VTEX2020---20201222_12:57----
                            //await Task.Run(() => genera_etiqueta.imp_etiqueta2(_venid));
                            await Task.Run(() => genera_etiqueta.imp_etiqueta2(_venid, tienda_id));

                            //-----FIN---SB-VTEX2020---20201222_12:57----
                        }
                        // Actualizar
                        consultar();
                    }
                    else
                    {
                        msj_eccomer = "No se pudo enviar la solicitud.";
                        resultetiq  = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.Affirmative, okSettings);
                    }
                }
            }
        }
        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;
        }