Ejemplo n.º 1
0
        public bool GetItemInfo(uint itemId, ref ItemItem item)
        {
            MySqlCommand command = new MySqlCommand();

            command.CommandText = getItemInfoStr;
            command.CommandType = System.Data.CommandType.Text;
            command.Connection  = conn;
            command.Parameters.Add(new MySqlParameter("@itemId", itemId));

            conn.Open();
            try
            {
                var res = command.ExecuteReader();
                if (res.Read())
                {
                    item.VoteId     = (uint)res[1];
                    item.Desc       = (string)res[3];
                    item.DescPicUrl = (string)res[4];
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool UpdateItenItem(ItemItem item)
        {
            //private string updateItenItemStr = "UPDATE `voters`.`item` SET `desc`=@desc, `desc_pic_url`=@descPicUrl WHERE `id`=@itemId";
            MySqlCommand command = new MySqlCommand();

            command.CommandText = updateItenItemStr;
            command.CommandType = System.Data.CommandType.Text;
            command.Connection  = conn;
            command.Parameters.Add(new MySqlParameter("@desc", item.Desc));
            command.Parameters.Add(new MySqlParameter("@descPicUrl", item.DescPicUrl));
            command.Parameters.Add(new MySqlParameter("@itemId", item.ItemId));

            conn.Open();
            try
            {
                int res = command.ExecuteNonQuery();
                if (res <= 0)
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }

            return(true);
        }
Ejemplo n.º 3
0
        public bool InsertItem(ItemItem item)
        {
            MySqlCommand command = new MySqlCommand();

            command.CommandText = insertItemStr;
            command.CommandType = System.Data.CommandType.Text;
            command.Connection  = conn;
            command.Parameters.Add(new MySqlParameter("@voteId", item.VoteId));
            command.Parameters.Add(new MySqlParameter("@desc", item.Desc));
            command.Parameters.Add(new MySqlParameter("@descPicUrl", item.DescPicUrl));

            conn.Open();
            try
            {
                int res = command.ExecuteNonQuery();
                if (res <= 0)
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }

            return(true);
        }