Пример #1
0
        private async void btnimprimir2_Click(object sender, RoutedEventArgs e)
        {
            string _venid = txtnumero.Text.Replace("-", "");

            if (Ent_Global._canal_venta == "AQ")
            {
                //MessageBox.Show(Ent_Global._impresora_etiquetas);
                GenerarEtiqueta genera_etiqueta = new GenerarEtiqueta();
                await Task.Run(() => genera_etiqueta.aq_imp_etiqueta2(_venid));
            }
            else
            {
                GenerarEtiqueta genera_etiqueta = new GenerarEtiqueta();
                //-----INICIO---SB-VTEX2020---20201222_12:57----
                string tienda_id = Ent_Global._tienda_id;
                //await Task.Run(() => genera_etiqueta.imp_etiqueta2(_venid));
                await Task.Run(() => genera_etiqueta.imp_etiqueta2(_venid, tienda_id));

                //-----FIN---SB-VTEX2020---20201222_12:57----
            }
        }
Пример #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);
                    }
                }
            }
        }
Пример #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;
        }
Пример #4
0
        private async void btndespachar_Click(object sender, RoutedEventArgs e)
        {
            int             i = 0;
            int             contadorseleccionados = 0;
            int             muestramensaje        = 0;
            bool            enviadespacho         = false;
            bool            imptickets            = false;
            string          nroguiasecuencia      = "";
            string          msj_eccomer           = "";
            int             _valida_guia;
            List <CheckBox> checkBoxlist = new List <CheckBox>();

            nroguiasecuencia = txtSecuenciaGuia.Text;


            FindChildGroup <CheckBox>(dg1, "chksel", ref checkBoxlist);

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

            foreach (CheckBox c in checkBoxlist)
            {
                if (c.IsChecked == true)
                {
                    if (muestramensaje == 0)
                    {
                        MessageDialogResult result = await this.ShowMessageAsync(Ent_Msg.msginfomacion,
                                                                                 "¿Realmente desea Despachar los pedidos seleccionados ? ",
                                                                                 MessageDialogStyle.AffirmativeAndNegative, mySettings);

                        if (result == MessageDialogResult.Affirmative)
                        {
                            var    dataGridCellInfoValida = new DataGridCellInfo(dg1.Items[i], dg1.Columns[1]);
                            string liq_idvalida           = ((System.Data.DataRowView)dataGridCellInfoValida.Item).Row.ItemArray[8].ToString();
                            Dat_ConfigGuia.insertar_guia((long.Parse(nroguiasecuencia) + contadorseleccionados).ToString(), 1, liq_idvalida, out _valida_guia);

                            if (_valida_guia == 0)
                            {
                                enviadespacho = true;
                            }
                            else
                            {
                                enviadespacho = false;
                                MessageBox.Show("Es probable que la guia ya exista, por favor dígite un nuevo numero de guia.");
                                return;
                            }
                        }
                        muestramensaje = 1;
                    }
                    else
                    {
                        var    dataGridCellInfoValida = new DataGridCellInfo(dg1.Items[i], dg1.Columns[1]);
                        string liq_idvalida           = ((System.Data.DataRowView)dataGridCellInfoValida.Item).Row.ItemArray[8].ToString();
                        Dat_ConfigGuia.insertar_guia((long.Parse(nroguiasecuencia) + contadorseleccionados).ToString(), 1, liq_idvalida, out _valida_guia);
                    }

                    if (enviadespacho)
                    {
                        var    dataGridCellInfo = new DataGridCellInfo(dg1.Items[i], dg1.Columns[1]);
                        string liq_id           = ((System.Data.DataRowView)dataGridCellInfo.Item).Row.ItemArray[8].ToString();
                        string ven_id           = ((System.Data.DataRowView)dataGridCellInfo.Item).Row.ItemArray[0].ToString();


                        if (Despachar(ven_id, (long.Parse(nroguiasecuencia) + contadorseleccionados).ToString(), liq_id))
                        {
                            imptickets = true;
                        }
                        else
                        {
                            imptickets = false;
                        }
                        contadorseleccionados = contadorseleccionados + 1;
                    }
                }
                i = i + 1;
            }

            if (imptickets)
            {
                msj_eccomer = "¿Desea Imprimir la etiqueta de los pedido seleccionados?";
                MessageDialogResult resultetiq = await this.ShowMessageAsync(Ent_Msg.msginfomacion, msj_eccomer, MessageDialogStyle.AffirmativeAndNegative, mySettings);

                if (resultetiq == MessageDialogResult.Affirmative)
                {
                    i = 0;
                    foreach (CheckBox c in checkBoxlist)
                    {
                        if (c.IsChecked == true)
                        {
                            var             dataGridCellInfo = new DataGridCellInfo(dg1.Items[i], dg1.Columns[1]);
                            string          ven_id           = ((System.Data.DataRowView)dataGridCellInfo.Item).Row.ItemArray[0].ToString();
                            GenerarEtiqueta genera_etiqueta  = new GenerarEtiqueta();
                            //await Task.Run(() =>
                            genera_etiqueta.imp_etiqueta2(ven_id, Ent_Global._tienda_id);
                        }
                        i = i + 1;
                    }
                }
            }
            consultar();
        }