예제 #1
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            try
            {
                if (dglista2.Rows.Count > 0)
                {
                    var correl        = txtcorrelativo2.Text;
                    var documentoBaja = new ComunicacionBaja
                    {
                        IdDocumento     = string.Format("RA-{0:yyyyMMdd}-" + correl, DateTime.Today),
                        FechaEmision    = DateTime.Today.ToString("yyyy-MM-dd"),
                        FechaReferencia = DateTime.Today.ToString("yyyy-MM-dd"),//DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"),
                        Emisor          = CrearEmisor(),
                        Bajas           = new List <DocumentoBaja>()
                    };
                    var nomdoc = "RA-" + string.Format("{0:yyyyMMdd}-" + correl, DateTime.Today);
                    foreach (DataGridViewRow row in dglista2.Rows)
                    {
                        DocumentoBaja baja = new DocumentoBaja();
                        baja.Id            = Convert.ToInt32(row.Cells[0].Value);
                        baja.TipoDocumento = Convert.ToString(row.Cells[1].Value);
                        baja.Serie         = Convert.ToString(row.Cells[2].Value);
                        baja.Correlativo   = Convert.ToString(row.Cells[3].Value);
                        baja.MotivoBaja    = Convert.ToString(row.Cells[4].Value);

                        documentoBaja.Bajas.Add(baja);
                    }
                    var invoice       = GeneradorXML.GenerarVoidedDocuments(documentoBaja);
                    var serializador3 = new Serializador();
                    TramaXmlSinFirma = serializador3.GenerarXml(invoice);
                    RutaArchivo      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Documentos\\" +
                                                    $"{documentoBaja.IdDocumento}.xml");
                    File.WriteAllBytes(RutaArchivo, Convert.FromBase64String(TramaXmlSinFirma));
                    IdDocumento = nomdoc;

                    DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("No hay Registros para Generar Documento");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #2
0
        private void kryptonButton6_Click(object sender, EventArgs e)
        {
            var documentoBaja = new ComunicacionBaja
            {
                IdDocumento     = "",
                FechaEmision    = DateTime.Today.ToString("yyyy-MM-dd"),
                FechaReferencia = "",//DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"),
                Emisor          = CrearEmisor(),
                Bajas           = new List <DocumentoBaja>()
            };

            documentoBaja.Bajas.Clear();

            comboBox1.SelectedIndex = -1;
            textBox1.Text           = "";
            txtmotivo.Text          = "";
            dglista2.Rows.Clear();
        }