Beispiel #1
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(Niunan.CaiPiao.Model.Userinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update userinfo set ");
            strSql.Append("createtime=@createtime, username=@username, email=@email, password=@password, txpassword=@txpassword, mobile=@mobile, address=@address, bankno=@bankno, bankname=@bankname, remark=@remark, status=@status, realname=@realname, idcard=@idcard, balance=@balance, password3=@password3, erweima=@erweima, parentid=@parentid, parentname=@parentname, parentpath=@parentpath, question=@question, answer=@answer  ");
            strSql.Append(" where id=@id ");
            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                int i = connection.Execute(strSql.ToString(), model);
                return(i > 0);
            }
        }
Beispiel #2
0
        /// <summary>得到一个对象实体
        ///
        /// </summary>
        public Niunan.CaiPiao.Model.Userinfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from userinfo ");
            strSql.Append(" where id=@id ");
            Niunan.CaiPiao.Model.Userinfo model = null;
            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                model = connection.QuerySingleOrDefault <Niunan.CaiPiao.Model.Userinfo>(strSql.ToString(), new { id = id });
            }
            return(model);
        }
Beispiel #3
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Niunan.CaiPiao.Model.Userinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into userinfo(");
            strSql.Append("createtime, username, email, password, txpassword, mobile, address, bankno, bankname, remark, status, realname, idcard, balance, password3, erweima, parentid, parentname, parentpath, question, answer  )");
            strSql.Append(" values (");
            strSql.Append("@createtime, @username, @email, @password, @txpassword, @mobile, @address, @bankno, @bankname, @remark, @status, @realname, @idcard, @balance, @password3, @erweima, @parentid, @parentname, @parentpath, @question, @answer  ) returning id;");

            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                int i = connection.QueryFirst <int>(strSql.ToString(), model);
                return(i);
            }
        }
Beispiel #4
0
        /// <summary>根据条件得到一个对象实体
        ///
        /// </summary>
        public Niunan.CaiPiao.Model.Userinfo GetModelByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  * from userinfo ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            strSql.Append(" limit 1");
            Niunan.CaiPiao.Model.Userinfo model = null;
            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                model = connection.QuerySingleOrDefault <Niunan.CaiPiao.Model.Userinfo>(strSql.ToString());
            }
            return(model);
        }