示例#1
0
    private void loadTC(int year, int month)
    {
        try
        {
            Tipo_Cambio_BCNSoapClient objServ = new Tipo_Cambio_BCNSoapClient();
            XmlElement objElement;
            XmlNodeList xmlNodLista;
            DataTable dt = new DataTable();

            //CONSUMIMOS EL SERVICIO
            objElement = objServ.RecuperaTC_Mes(year, month);
            xmlNodLista = objElement.GetElementsByTagName("Tc");

            //AGREGAMOS LAS COLUMNAS AL DATATABLE
            foreach (XmlNode node in xmlNodLista.Item(0).ChildNodes)
            {
                DataColumn col = new DataColumn(node.Name, System.Type.GetType("System.String"));
                dt.Columns.Add(col);
            }

            //AGREGAR LA INFORMACION AL DATATABLE
            for (int i = 0; i < xmlNodLista.Count; i++)
            {
                DataRow dr = dt.NewRow();
            }

            for (int IntVal = 0; IntVal <= xmlNodLista.Count - 1; IntVal++)
            {
                DataRow dr = dt.NewRow();
                for (int Col = 0; Col <= dt.Columns.Count - 1; Col++)
                {
                    if (xmlNodLista.Item(IntVal).ChildNodes[Col].InnerText != null)
                        dr[Col] = xmlNodLista.Item(IntVal).ChildNodes[Col].InnerText;
                    else
                        dr[Col] = null;
                }
                dt.Rows.Add(dr);
            }
            clsLst cls = new clsLst();
            cls.createTC(dt);

        }
        catch (Exception ex) { }
    }