private void SetNewXMLParams(Documento doc, Configuracion conf) { //xmlDoc.Load(doc.RutaArchivoTimbrado); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(doc.RutaArchivoOk); XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable); nsMgr.AddNamespace("cfdi", conf.CFDINameSpace); nsMgr.AddNamespace("nomina12", "http://www.sat.gob.mx/nomina12"); XmlNode nodoComprobante = xmlDoc.SelectSingleNode("/cfdi:Comprobante", nsMgr); XmlNode nodoReceptor = xmlDoc.SelectSingleNode("/cfdi:Comprobante/cfdi:Receptor", nsMgr); XmlNode nodoConcepto = xmlDoc.SelectSingleNode("/cfdi:Comprobante/cfdi:Conceptos/cfdi:Concepto", nsMgr); XmlNode nodoNomina = xmlDoc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento", nsMgr).FirstChild; XmlNode nodoNominaReceptor = xmlDoc.SelectSingleNode("/cfdi:Comprobante/cfdi:Complemento/nomina12:Nomina/nomina12:Receptor", nsMgr); InsertParams param = new InsertParams(); param.Fecha = (nodoComprobante.Attributes["fecha"] != null) ? DateTime.Parse(nodoComprobante.Attributes["fecha"].Value) : (DateTime?)null; param.Total = (nodoComprobante.Attributes["total"] != null) ? decimal.Parse(nodoComprobante.Attributes["total"].Value) : 0; param.Nombre = (nodoReceptor.Attributes["nombre"] != null) ? nodoReceptor.Attributes["nombre"].Value : string.Empty; param.Descripcion = (nodoConcepto.Attributes["descripcion"] != null) ? nodoConcepto.Attributes["descripcion"].Value : string.Empty; param.FechaPago = (nodoNomina.Attributes["FechaPago"] != null) ? DateTime.Parse(nodoNomina.Attributes["FechaPago"].Value) : (DateTime?)null; param.Departamento = (nodoNominaReceptor.Attributes["Departamento"] != null) ? nodoNominaReceptor.Attributes["Departamento"].Value : string.Empty; param.NumEmpleado = (nodoNominaReceptor.Attributes["NumEmpleado"] != null) ? nodoNominaReceptor.Attributes["NumEmpleado"].Value : string.Empty; param.Puesto = (nodoNominaReceptor.Attributes["Puesto"] != null) ? nodoNominaReceptor.Attributes["Puesto"].Value : string.Empty; doc.Parametros = param; }
private void SetEmptyInsertParams(Documento doc) { InsertParams param = new InsertParams(); param.Fecha = (DateTime?)null; param.Total = 0; param.Nombre = string.Empty; param.Descripcion = string.Empty; param.FechaPago = null; param.Departamento = string.Empty; param.NumEmpleado = string.Empty; param.Puesto = string.Empty; doc.Parametros = param; }