Exemple #1
0
        public void MostrarLoteOperIntracom()
        {
            // Creamos un lote de factura recibidas
            ITInvoicesBatch LoteOperIntracom =
                CrearLoteOperIntracom();

            string tmpath = Path.GetTempFileName();

            // Genera el archivo xml y lo guarda en la ruta facilitada comno parámetro
            LoteOperIntracom.GetXml(tmpath);

            formXmlViewer frmXmlViewer = new formXmlViewer();

            frmXmlViewer.Path = tmpath;

            frmXmlViewer.ShowDialog();
        }
Exemple #2
0
        private void mnViewXML_Click(object sender, EventArgs e)
        {
            try
            {
                string tmpath = Path.GetTempFileName();

                // Genera el archivo xml y lo guarda en la ruta facilitada comno parámetro
                _LoteOperIntracom.GetXml(tmpath);

                FormXmlViewer frmXmlViewer = new FormXmlViewer
                {
                    Path = tmpath
                };

                frmXmlViewer.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
        private void MnViewXML_Click(object sender, EventArgs e)
        {
            try
            {
                string tmpath = Path.GetTempFileName();

                // Genera el archivo xml y lo guarda en la ruta facilitada comno parámetro
                _LoteOperIntracom.GetXml(tmpath);

                FormXmlViewer frmXmlViewer = new FormXmlViewer
                {
                    Path = tmpath
                };

                frmXmlViewer.ShowDialog();
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
        public void GenerarXMLIntracom(string _NombreFichero)
        {
            Intracom funcion        = new Intracom();
            string   _NomFicheroWrk = _NombreFichero;

            try
            {
                ITInvoicesBatch _LoteOperIntracom = new ITInvoicesBatch();
                ITInvoice       _OperIntracomAct  = new ITInvoice();
                Party           _Titular          = new Party();

                using (StreamReader _Lector = new StreamReader(_NomFicheroWrk))
                {
                    while (_Lector.Peek() > -1)
                    {
                        string _RegFichero = _Lector.ReadLine();
                        if (!String.IsNullOrEmpty(_RegFichero))
                        {
                            // Con creamos un Array con los distintos campos que contiene el registro separados por ";"
                            string[] _CamposReg = _RegFichero.Split(';');
                            string   _TipoReg   = _CamposReg[0];

                            switch (_TipoReg)
                            {
                            case "CABE":
                                _Titular = funcion.TratarRegCabecera(_CamposReg);
                                _LoteOperIntracom.Titular = _Titular;
                                string _TipoComunicacion = _CamposReg[3];
                                switch (_TipoComunicacion)
                                {
                                case "A0":
                                    _LoteOperIntracom.CommunicationType = CommunicationType.A0;
                                    break;

                                case "A1":
                                    _LoteOperIntracom.CommunicationType = CommunicationType.A1;
                                    break;

                                case "A4":
                                    _LoteOperIntracom.CommunicationType = CommunicationType.A4;
                                    break;
                                }
                                break;

                            case "FACT":
                                _OperIntracomAct = new ITInvoice();
                                _OperIntracomAct = funcion.TratarOperIntracom(_CamposReg, _Titular);
                                _LoteOperIntracom.ITInvoices.Add(_OperIntracomAct);
                                break;

                            case "FINI":
                                // Procedemos a generar el XML final.
                                DateTime _FechaActual  = DateTime.Today;    //Obtenemos la fecha actual sin la hora
                                string   nombrefichero = "SII_Intracom_" + _Titular.TaxIdentificationNumber + "_" + _FechaActual.ToString("yyyyMMdd") + ".XML";
                                string   XmlResult     = "C:/Temp/" + nombrefichero;
                                _LoteOperIntracom.GetXml(XmlResult);

                                string _msg = "Fichero XML generado: " + XmlResult;
                                MessageBox.Show(_msg, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                break;

                            default:
                                string _msgAviso = "Tipo Registro incorrecto: " + _TipoReg;
                                MessageBox.Show(_msgAviso, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }