public void AgregarTipos(DTOType tipo)
        {
            string sSel;
            string sSelCount;
            bool exist;

            sSelCount = "SELECT COUNT (*) FROM \"tbl_ChannelType\" ct WHERE ct.\"channelType\"='"+ tipo.Type +"'";
            NpgsqlDataAdapter daCount;
            DataSet dtCount = new DataSet();
            try
            {
                daCount = new NpgsqlDataAdapter(sSelCount, sConexion);
                daCount.Fill(dtCount);
                if (dtCount.Tables[0].Rows[0][0].ToString() == "0")
                    exist = false;
                else
                    exist = true;
            }
            catch (Exception)
            {
                exist = false;
            }
            if (!exist)
            {
                sSel = "INSERT INTO \"tbl_ChannelType\"(\"channelType\") VALUES('" + tipo.Type + "');";

                NpgsqlDataAdapter da;
                DataSet dt = new DataSet();

                try
                {
                    da = new NpgsqlDataAdapter(sSel, sConexion);
                    da.Fill(dt);
                }
                catch (Exception)
                {

                }
            }
        }
예제 #2
0
        static void InsertType(XmlDocument xmlDoc)
        {
            try
            {
                Console.WriteLine("Tipo de Canales");
                DTOType tipo = new DTOType();
                XmlNodeList channels = xmlDoc.GetElementsByTagName("glf")[0].ChildNodes[2].ChildNodes;

                foreach (XmlNode channel in channels)
                {
                    tipo.Type = channel.Attributes["t"].Value;
                    conexion.AgregarTipos(tipo);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }