Пример #1
0
        private void _Mtd_CrearArchivoISLR(string _P_Str_ID_Archivo)
        {
            System.IO.DirectoryInfo _DirInf = new System.IO.DirectoryInfo("c:\\seniat");
            if (!_DirInf.Exists)
            {
                _DirInf.Create();
            }
            string  _Str_Cadena = "SELECT REPLACE(crifagenretencion,'-','') AS crifagenretencion,cfecha FROM TARCHIVOISLRD WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' AND ccompany='" + Frm_Padre._Str_Comp + "' AND cidarchivoislr='" + _P_Str_ID_Archivo + "'";
            DataSet _Ds         = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena);

            if (_Ds.Tables[0].Rows.Count > 0)
            {
                string _Str_RifAgente = _Ds.Tables[0].Rows[0]["crifagenretencion"].ToString().Trim();
                string _Str_Periodo   = _Ds.Tables[0].Rows[0]["cfecha"].ToString().Trim();
                _Str_Cadena             = "SELECT REPLACE(crifprovee,'-','') AS RifRetenido,REPLACE(cnumfact,'-','') AS NumeroFactura, REPLACE(cnumcont,'-','') AS NumeroControl,CONVERT(VARCHAR,cfechaoperacion,103) AS FechaOperacion,ccodigoconcepto AS CodigoConcepto,REPLACE(cmontdocu,',','.') AS MontoOperacion,REPLACE(cporcenreten,',','.') AS PorcentajeRetencion FROM TARCHIVOISLRD WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' AND ccompany='" + Frm_Padre._Str_Comp + "' AND cidarchivoislr='" + _P_Str_ID_Archivo + "'";
                _Ds                     = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena);
                _Ds.Tables[0].TableName = "DetalleRetencion";
                //const string _Str_Comillas = "\"";
                //_Ds.DataSetName = "RelacionRetencionesISLR RifAgente=" + _Str_Comillas + _Str_RifAgente + _Str_Comillas + " Periodo=" + _Str_Periodo;
                _Ds.DataSetName        = "RelacionRetencionesISLR";
                _Ds.EnforceConstraints = false;
                XmlDataDocument _Xml_d    = new XmlDataDocument(_Ds);
                XmlDeclaration  _Xml_Decl = _Xml_d.CreateXmlDeclaration("1.0", "ISO-8859-1", null);
                XmlElement      _Xml_Elem = _Xml_d.DocumentElement;
                _Xml_d.InsertBefore(_Xml_Decl, _Xml_Elem);
                XmlAttribute _Xml_a = _Xml_d.CreateAttribute("RifAgente");
                _Xml_a.Value = _Str_RifAgente;
                _Xml_d["RelacionRetencionesISLR"].Attributes.Append(_Xml_a);
                _Xml_a       = _Xml_d.CreateAttribute("Periodo");
                _Xml_a.Value = _Str_Periodo;
                _Xml_d["RelacionRetencionesISLR"].Attributes.Append(_Xml_a);
                _Xml_d.Save("c:\\seniat\\XML_relacionRetencionesISLR_.xml");
            }
        }
Пример #2
0
        public void CreateXml(DataSet dataset_for_index_doc, DataSet dataset_for_folder, string indexing, string fullPath, string filename, SqlConnection connection, string folderID, string docID)
        {
            string temp_string     = System.IO.Path.GetExtension(filename);
            string output_filename = filename.Replace(temp_string, ".xml");

            string temp_fullpath = string.Format("{0}\\{1}", fullPath, output_filename);

            //String SQLCommand = " select * from obj where parent_id =" + indexing ;

            DataRow[] indexRow = dataset_for_index_doc.Tables[0].Select("DocID = " + docID);

            XmlDataDocument doc            = new XmlDataDocument();
            XmlDeclaration  xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement      root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);
            DataRow[]  r = dataset_for_folder.Tables[0].Select("folderID = " + folderID);
            string     temp_index_name = r[0].ItemArray[0].ToString().Replace(" ", "");
            XmlElement element1        = doc.CreateElement(string.Empty, temp_index_name, string.Empty);

            doc.AppendChild(element1);
            //Create an element representing the first customer record.
            //foreach (DataRow row in ds.Tables[0].Rows)
            //{
            //    string temp_index_name1 = row.ItemArray[3].ToString().Replace(" ", "");
            //    XmlElement element2 = doc.CreateElement(string.Empty, temp_index_name1, string.Empty);
            //    XmlText text1 = doc.CreateTextNode(row.ItemArray[3].ToString());
            //    element2.AppendChild(text1);
            //    element1.AppendChild(element2);
            //}
            foreach (DataRow index in indexRow)
            {
                string     temp_index_name1 = index.ItemArray[4].ToString().Replace(" ", "");
                XmlElement element2         = doc.CreateElement(string.Empty, temp_index_name1, string.Empty);
                XmlText    text1            = doc.CreateTextNode(index.ItemArray[3].ToString());
                element2.AppendChild(text1);
                element1.AppendChild(element2);
            }
            doc.Save(temp_fullpath);
        }