private async void btnanular_Click(object sender, RoutedEventArgs e)
        {
            DataRowView row = (DataRowView)((Button)e.Source).DataContext;

            string  _not_id  = (string)row["ven_id"].ToString();  // dg1.Rows[e.RowIndex].Cells["ven_id"].Value.ToString();
            string  _tipo    = (string)row["tipodoc"].ToString(); //dg1.Rows[e.RowIndex].Cells["tipodoc"].Value.ToString();
            string  _numdoc  = (string)row["numdoc"].ToString();  //dg1.Rows[e.RowIndex].Cells["numdoc"].Value.ToString();
            string  _doc     = (string)row["ven_id"].ToString();  //dg1.Rows[e.RowIndex].Cells["ven_id"].Value.ToString();
            Boolean _anulado = (Boolean)row["anulado"];           // Convert.ToBoolean(dg1.Rows[e.RowIndex].Cells["anulado"].Value);
            //verificar si el documento paso las 72 horas de enviarse a la web service efact
            Boolean _valida = (Boolean)row["docu_vencido"];       // Convert.ToBoolean(dg1.Rows[e.RowIndex].Cells["docu_vencido"].Value);



            //string _not_numero = dg1.Rows[e.RowIndex].Cells["not_numero"].Value.ToString();

            if (_anulado)
            {
                MessageBox.Show("!El documento de tipo : " + _tipo + " con numero : " + _numdoc + " no se puede anular, porque YA ESTA ANULADO...", Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            _valida = false;

            if (_valida)
            {
                MessageBox.Show("!El documento de tipo : " + _tipo + " con numero : " + _numdoc + " no se puede anular, porque no es de la fecha actual...", Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

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

            MessageDialogResult result = await this.ShowMessageAsync(Ent_Msg.msginfomacion, "¿Realmente desea anular el documento de tipo : " + _tipo + " con numero : " + _numdoc,
                                                                     MessageDialogStyle.AffirmativeAndNegative, mySettings);


            if (result == MessageDialogResult.Affirmative)
            {
                //Mouse.OverrideCursor = Cursors.Wait;
                string _error = "";

                //Facturacion_Electronica.anular_facturacion_electronica(_doc, ref _error,"NC");


                //if (_error.Length == 0)
                //{
                var ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Anulando Documento N°:" + _not_id); //show message

                ProgressAlert.SetIndeterminate();                                                                          //Infinite

                string _error_venta = await Task.Run(() => Dat_Venta._anular_venta(_not_id.ToString()));

                //show info

                #region <REGION EXCLUSIVA PARA E-COMMERCE>
                if (Ent_Global._canal_venta == "BA")
                {
                    string _tipo_doc = "";
                    if (_tipo == "Factura")
                    {
                        _tipo_doc = "FA";
                    }
                    if (_tipo == "Boleta")
                    {
                        _tipo_doc = "BO";
                    }
                    string _error_act_venta = await Task.Run(() => Dat_Venta._act_estado_anular_venta(_tipo_doc.ToString(), _not_id.ToString()));
                }
                #endregion

                //string _error_venta =Dat_Venta._anular_venta(_not_id.ToString());
                string _codigo_hashn = ""; String _url_pdf = "";

                if (_error_venta.Length == 0)
                {
                    await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica("F", _not_id.ToString(), ref _codigo_hashn, ref _error, ref _url_pdf));

                    if (_error.Length == 0)
                    {
                        await Task.Run(() => Basico._enviar_webservice_xml());

                        Boolean  _tipoc_b    = chkactivar.IsChecked.Value;
                        DateTime _fechaini_b = Convert.ToDateTime(dtpdesde.Text);
                        DateTime _fechafin_b = Convert.ToDateTime(dtphasta.Text);
                        string   _doc_b      = txtdoc.Text;
                        //MessageBox.Show("!El documento de tipo : " + _tipo + " con numero : " + _numdoc + " Se Anulo con exito...", Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Information);
                        DataTable dt = await Task.Run(() => Dat_Venta.dt_consulta_pedido(_tipoc_b, _fechaini_b, _fechafin_b, _doc_b));

                        await ProgressAlert.CloseAsync();

                        dg1.ItemsSource = dt.DefaultView;
                        await this.ShowMessageAsync(Ent_Msg.msginfomacion, "!El documento de tipo : " + _tipo + " con numero : " + _numdoc + " Se Anulo con exito...");
                    }
                    else
                    {
                        await ProgressAlert.CloseAsync();

                        await this.ShowMessageAsync(Ent_Msg.msginfomacion, _error);

                        //MessageBox.Show(_error, Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    await ProgressAlert.CloseAsync();

                    await this.ShowMessageAsync(Ent_Msg.msginfomacion, _error_venta);

                    //MessageBox.Show(_error_venta, Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            //}
            //Mouse.OverrideCursor = null;
        }