Пример #1
0
        /// <summary>
        /// Carrega o artigo pelo id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <VideoActionGrant> LoadAllFrom(VideoAction na)
        {
            List <VideoActionGrant> lst = new List <VideoActionGrant>();

            SqlCommand sel = new SqlCommand();

            sel.CommandText = "SELECT awardid, grantedby, granted FROM " + Base.conf.prefix + "[newsvideoactiongrant] WHERE id=@id ORDER BY granted";
            sel.Parameters.Add(new SqlParameter("@id", na.id));

            sel.Connection = Base.conf.Open();
            SqlDataReader rdr = sel.ExecuteReader();

            if (rdr.Read())
            {
                // Pega as informações

                VideoActionGrant nga = new VideoActionGrant(na);

                nga.awardidInt  = rdr.GetString(0);
                nga.grantedById = rdr.GetString(1);
                nga.granted     = rdr.GetDateTime(2);

                lst.Add(nga);
            }

            rdr.Close();
            sel.Connection.Close();

            return(lst);
        }
Пример #2
0
        /// <summary>
        /// Cria novo
        /// </summary>
        public VideoActionGrant(VideoAction n)
        {
            actionInt = n;

            awardidInt   = "";
            grantedbyInt = "";
            grantedInt   = RacMsg.NullDateTime;
        }
Пример #3
0
        /// <summary>
        /// Posição do call
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public int GetPosition(VideoAction n)
        {
            for (int i = 0; i < actions.Count; i++)
            {
                if (actions[i].id == n.id)
                {
                    return(i);
                }
            }

            return(-1);
        }
Пример #4
0
        /// <summary>
        /// Carrega a lista de classes de licença para este sistema
        /// </summary>
        /// <returns></returns>
        List <VideoAction> ActionForNews()
        {
            List <string>      ids = Base.conf.LoadStringList(id, "newsvideoaction", "videoid", "id", "date");
            List <VideoAction> lst = new List <VideoAction>();

            for (int i = 0; i < ids.Count; i++)
            {
                VideoAction npc = new VideoAction(this);
                if (npc.Load(ids[i]))
                {
                    lst.Add(npc);
                }
            }

            return(lst);
        }
Пример #5
0
        /// <summary>
        /// Salva a ticket
        /// </summary>
        /// <returns></returns>
        public static bool SaveAll(VideoAction va, List <VideoActionGrant> lst)
        {
            bool res = false;

            SqlCommand del = new SqlCommand();

            del.CommandText = "DELETE FROM " + Base.conf.prefix + "[newsvideoactiongrant] WHERE id=@id";
            del.Parameters.Add(new SqlParameter("@id", va.id));

            del.Connection = Base.conf.Open();
            del.ExecuteNonQuery();
            del.Connection.Close();

            SqlCommand ins = new SqlCommand();

            ins.CommandText = "INSERT INTO " + Base.conf.prefix + "[newsvideoactiongrant] (id, awardid, grantedby, granted) VALUES (@id, @awardid, @grantedby, @granted)";
            ins.Parameters.Add(new SqlParameter("@id", va.id));

            SqlParameter varAttribute = new SqlParameter("@awardid", "0");

            ins.Parameters.Add(varAttribute);

            SqlParameter varGrantedBy = new SqlParameter("@grantedby", "0");

            ins.Parameters.Add(varGrantedBy);

            SqlParameter varGranted = new SqlParameter("@granted", DateTime.Now);

            ins.Parameters.Add(varGranted);

            ins.Connection = Base.conf.Open();

            for (int i = 0; i < lst.Count; i++)
            {
                varAttribute.Value = lst[i].awardidInt;
                varGrantedBy.Value = lst[i].grantedbyInt;
                varGranted.Value   = lst[i].grantedInt;

                ins.ExecuteNonQuery();
            }

            ins.Connection.Close();

            return(res);
        }