Example #1
0
 private void button7_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentRow.Cells[1].Value.ToString() != "")
     {
         try
         {
             DialogResult result = MessageBox.Show("¿De verdad desea cancelar esta nota de credito?", "Confirmacion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (result == DialogResult.Yes)
             {
                 DAO.FelWebServiceDAO webservice = new EquimarFac.DAO.FelWebServiceDAO();
                 webservice.UUID = dataGridView1.CurrentRow.Cells["UUID"].Value.ToString();
                 string[]        respuesta    = new string[3];
                 DAO.FacturasDAO facturasdao1 = new EquimarFac.DAO.FacturasDAO();
                 facturasdao1.Nombre      = comboBox2.Text;
                 dataGridView2.DataSource = facturasdao1.devuelvedatospacpornombre();
                 foreach (DataGridViewRow row in dataGridView2.Rows)
                 {
                     webservice.CuentaFEL   = row.Cells[1].Value.ToString();
                     webservice.emisorRFC   = row.Cells[0].Value.ToString();
                     webservice.PasswordFEL = row.Cells[2].Value.ToString();
                 }
                 respuesta = webservice.cancelacdfi();
                 if (respuesta[0] == "True")
                 {
                     DAO.FacturasDAO facturas = new EquimarFac.DAO.FacturasDAO();
                     facturas.IDNotaCredito = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
                     facturas.ConceptoT     = respuesta[2];
                     string resultado = facturas.cancelanotasdecreditocfdi();
                     if (resultado != "Correcto")
                     {
                         MessageBox.Show("Error :" + resultado[1].ToString());
                     }
                     else
                     {
                         MessageBox.Show("Operacion exitosa" + ' ' +
                                         respuesta[1].ToString());
                         carganotasgrid();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error " + ex.ToString());
         }
     }
     else
     {
         MessageBox.Show("Para cancelar un CFDI es necesario emitirlo primero");
     }
 }