Beispiel #1
0
        public void AgregarMarcaHorario(DTOScheduleFlag flag)
        {
            string sSel;
            string sSelCount;
            bool   exist;

            sSelCount = "SELECT COUNT(*) FROM \"tbl_ScheduleFlag\" WHERE \"idScheduleFlag\" = " + flag.IdScheduleFlag;
            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_ScheduleFlag\" VALUES(" + flag.IdScheduleFlag + ",'" + flag.Name + "','" + flag.Pname + "','" + flag.Description + "')";

                NpgsqlDataAdapter da;
                DataSet           dt = new DataSet();

                try
                {
                    da = new NpgsqlDataAdapter(sSel, sConexion);
                    da.Fill(dt);
                }
                catch (Exception)
                {
                }
            }
        }
Beispiel #2
0
        static void InsertScheduleFlags(XmlDocument doc)
        {
            try
            {
                Console.WriteLine("Marca de Horarios");
                DTOScheduleFlag marca         = new DTOScheduleFlag();
                XmlNodeList     scheduleFlags = doc.GetElementsByTagName("glf")[0].ChildNodes[0].ChildNodes[3].ChildNodes;

                foreach (XmlNode flag in scheduleFlags)
                {
                    marca.IdScheduleFlag = Int64.Parse(flag.Attributes["id"].Value);
                    marca.Name           = flag.Attributes["name"].Value;
                    marca.Pname          = flag.Attributes["pname"].Value;
                    marca.Description    = flag.Attributes["desc"].Value;
                    conexion.AgregarMarcaHorario(marca);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }