private async void btnxml_Click(object sender, RoutedEventArgs e) { ProgressDialogController ProgressAlert = null; try { DataRowView row = (DataRowView)((Button)e.Source).DataContext; var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Si", NegativeButtonText = "No", //FirstAuxiliaryButtonText = "Cancelar", ColorScheme = MetroDialogOptions.ColorScheme, }; string _codigo_hash = (string)row["Not_Cod_Hash"].ToString(); // dg1.Rows[e.RowIndex].Cells["Not_Cod_Hash"].Value.ToString(); ; decimal _not_id_imp = Convert.ToDecimal(row["Not_Id"]); // Convert.ToDecimal(dg1.Rows[e.RowIndex].Cells["Not_Id"].Value.ToString()); string _numdoc_r = (string)row["numdoc"].ToString(); // dg1.Rows[e.RowIndex].Cells["numdoc"].Value.ToString(); ; MessageDialogResult result = await this.ShowMessageAsync(Ent_Msg.msginfomacion, "¿Realmente desea enviar a sunat el XML DEL DOCUMENTO de tipo : Nota de Credito con numero : " + _numdoc_r, MessageDialogStyle.AffirmativeAndNegative, mySettings); if (result == MessageDialogResult.Affirmative) { ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Enviando a sunat la Nota de Credito..."); //string _codigo_hash = ""; string _error = ""; String _url_pdf = ""; await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica("N", _not_id_imp.ToString(), ref _codigo_hash, ref _error, ref _url_pdf)); if (_error.Length > 0) { if (ProgressAlert != null) { await ProgressAlert.CloseAsync(); } await this.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR AL ENVIAR EL XML A SUNAT. CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _error + ")"); return; } //EN ESTE PASO VAMOS A GRABAR EL CODIGO HASH await Task.Run(() => Dat_Venta.insertar_codigo_hash(_not_id_imp.ToString(), _codigo_hash, "N", _url_pdf)); //****enviar los xml al server await Task.Run(() => Basico._enviar_webservice_xml()); await Task.Run(() => consultar_refresh()); if (ProgressAlert != null) { await ProgressAlert.CloseAsync(); } //Mouse.OverrideCursor = Cursors.Wait; } else { if (ProgressAlert != null) { await ProgressAlert.CloseAsync(); } } } catch { if (ProgressAlert != null) { await ProgressAlert.CloseAsync(); } } }
private async void btnanular_Click(object sender, RoutedEventArgs e) { DataRowView row = (DataRowView)((Button)e.Source).DataContext; decimal _not_id = Convert.ToDecimal(row["Not_Id"]); // 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 = (string)row["not_numero"].ToString(); //dg1.Rows[e.RowIndex].Cells["not_numero"].Value.ToString(); //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 Nota de Credito N°:" + _numdoc); //show message ProgressAlert.SetIndeterminate(); //Infinite string _error_venta = await Task.Run(() => Dat_NotaCredito._anular_ncredito(_not_id, Ent_Global._bas_id_codigo)); //string _error_venta =Dat_NotaCredito._anular_ncredito(_not_id, Ent_Global._bas_id_codigo); string _codigo_hashn = ""; string _url_pdf = ""; if (_error_venta.Length == 0) { await Task.Run(() => Facturacion_Electronica.ejecutar_factura_electronica("N", _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); //consultar(); DataTable dt = await Task.Run(() => Dat_NotaCredito.dt_consulta_notacredito(_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_venta, Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Error); } } else { await ProgressAlert.CloseAsync(); await this.ShowMessageAsync(Ent_Msg.msginfomacion, _error_venta); } //} //else //{ // MessageBox.Show(_error, Ent_Msg.msginfomacion, MessageBoxButton.OK, MessageBoxImage.Error); //} } //} Mouse.OverrideCursor = null; }