Beispiel #1
0
        private static bool lfCreaAdendaHP(HP objHP, ref string sBody_XML)
        {
            //XDocument xd = XDocument.Load(@"C:\Users\developer\Documents\Z\ejemplo.xml");
            XDocument xd = XDocument.Parse(sBody_XML);
            try
            {
                XNamespace xcfdi = @"http://www.sat.gob.mx/cfd/3";
                XElement xeAdenda = new XElement(xcfdi + "Addenda",
                                    new XElement("Inicial",
                                    new XElement("OrdenCompra", objHP.OrdenCompra),
                                    new XElement("NumeroFacturaOriginal"),
                                    new XElement("NombreContactoCliente", objHP.NombreContactoCliente),
                                    new XElement("CorreoContactoCliente", objHP.CorreoContactoCliente),
                                    new XElement("DireccionEntrega",
                                        new XAttribute("CalleEntrega", objHP.DE_CalleEntrega),
                                        new XAttribute("EstadoEntrega", objHP.DE_EstadoEntrega),
                                        new XAttribute("MunicipioEntrega", objHP.DE_MunicipioEntrega),
                                        new XAttribute("ColoniaEntrega", objHP.DE_ColoniaEntrega),
                                        new XAttribute("CodigoPostal", objHP.DE_CodigoPostal),
                                        new XAttribute("NombreCliente", objHP.NombreContactoCliente), " ")));
                xd.Root.Add(xeAdenda);
                sBody_XML = xd.ToString();

                return true;
            }
            catch
            {
                return false;

            }
        }
Beispiel #2
0
        public static bool AdendaHP(string sNombreDB, int iNumeroRegistro, int iNumeroEmpresa, ref string xml)
        {
            //CfdiBLL ctrl = new CfdiBLL();
            HP objHP = new HP();
            try
            {
                DataSet ds = new DataSet();
                SQLConection context = new SQLConection();
                context.Parametros.Clear();
                context.Parametros.Add(new SqlParameter("@Numero_Empresa", iNumeroEmpresa));
                context.Parametros.Add(new SqlParameter("@Numero_Factura", iNumeroRegistro));
                ds = context.ExecuteStoredProcedure("[" + sNombreDB + "].[dbo].[sp_AdendaHP_OrdenCompra]", true).Copy();

                for (int indiceTablas = 0; indiceTablas < ds.Tables.Count; indiceTablas++)
                {
                    // EMAIL
                    if (indiceTablas == 0)
                    {
                        objHP.DE_NombreCliente = ds.Tables[indiceTablas].Rows[0][0].ToString();
                        objHP.NombreContactoCliente = ds.Tables[1].Rows[0]["Observaciones2"].ToString();
                        objHP.CorreoContactoCliente = ds.Tables[indiceTablas].Rows[0][1].ToString();
                        continue;
                    }
                    if (indiceTablas == 1)
                    {
                        objHP.OrdenCompra = ds.Tables[indiceTablas].Rows[0][0].ToString();
                        objHP.DE_CalleEntrega = ds.Tables[indiceTablas].Rows[0]["Domicilio"].ToString();
                        objHP.DE_EstadoEntrega = ds.Tables[indiceTablas].Rows[0]["Estado"].ToString();
                        objHP.DE_MunicipioEntrega = ds.Tables[indiceTablas].Rows[0]["Delegacion_municipio"].ToString();
                        objHP.DE_ColoniaEntrega = ds.Tables[indiceTablas].Rows[0]["Colonia"].ToString();
                        objHP.DE_CodigoPostal = ds.Tables[indiceTablas].Rows[0]["Codigo_postal"].ToString();
                        continue;
                    }
                }
                return lfCreaAdendaHP(objHP, ref xml);
            }
            catch
            {
                return false;
            }
        }