Example #1
0
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public GenVoteUser Get(int Id)
        {
            GenVoteUser     returnValue        = null;
            MySqlConnection oc                 = ConnectManager.Create();
            MySqlCommand    _cmdGetGenVoteUser = cmdGetGenVoteUser.Clone() as MySqlCommand;

            _cmdGetGenVoteUser.Connection = oc;
            try
            {
                _cmdGetGenVoteUser.Parameters["@Id"].Value = Id;

                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }

                MySqlDataReader reader = _cmdGetGenVoteUser.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    returnValue = new GenVoteUser().BuildSampleEntity(reader);
                }
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdGetGenVoteUser.Dispose();
                _cmdGetGenVoteUser = null;
                GC.Collect();
            }
            return(returnValue);
        }
Example #2
0
        /// <summary>
        /// 添加数据
        /// <param name="es">数据实体对象数组</param>
        /// <returns></returns>
        /// </summary>
        public bool Insert(GenVoteUser e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdInsertGenVoteUser = cmdInsertGenVoteUser.Clone() as MySqlCommand;
            bool            returnValue           = false;

            _cmdInsertGenVoteUser.Connection = oc;
            try
            {
                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }
                _cmdInsertGenVoteUser.Parameters["@Vid"].Value        = e.Vid;
                _cmdInsertGenVoteUser.Parameters["@UserId"].Value     = e.UserId;
                _cmdInsertGenVoteUser.Parameters["@CreateTime"].Value = e.CreateTime;
                _cmdInsertGenVoteUser.Parameters["@VIp"].Value        = e.VIp;
                _cmdInsertGenVoteUser.Parameters["@Id"].Value         = e.Id;

                _cmdInsertGenVoteUser.ExecuteNonQuery();
                return(returnValue);
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdInsertGenVoteUser.Dispose();
                _cmdInsertGenVoteUser = null;
            }
        }
Example #3
0
        /// <summary>
        /// 修改指定的数据
        /// <param name="e">修改后的数据实体对象</param>
        /// <para>数据对应的主键必须在实例中设置</para>
        /// </summary>
        public void Update(GenVoteUser e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdUpdateGenVoteUser = cmdUpdateGenVoteUser.Clone() as MySqlCommand;

            _cmdUpdateGenVoteUser.Connection = oc;

            try
            {
                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }

                _cmdUpdateGenVoteUser.Parameters["@Vid"].Value        = e.Vid;
                _cmdUpdateGenVoteUser.Parameters["@UserId"].Value     = e.UserId;
                _cmdUpdateGenVoteUser.Parameters["@CreateTime"].Value = e.CreateTime;
                _cmdUpdateGenVoteUser.Parameters["@VIp"].Value        = e.VIp;
                _cmdUpdateGenVoteUser.Parameters["@Id"].Value         = e.Id;

                _cmdUpdateGenVoteUser.ExecuteNonQuery();
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdUpdateGenVoteUser.Dispose();
                _cmdUpdateGenVoteUser = null;
                GC.Collect();
            }
        }