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

            strSql.Append("update [chongzhi] set ");
            strSql.Append("[createtime]=@createtime, [userid]=@userid, [username]=@username, [status]=@status, [remark]=@remark, [money]=@money, [bankname]=@bankname, [realname]=@realname, [bankno]=@bankno, [paytype]=@paytype  ");
            strSql.Append(" where id=@id ");
            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                int i = connection.Execute(strSql.ToString(), model);
                return(i > 0);
            }
        }
Esempio n. 2
0
        /// <summary>得到一个对象实体
        ///
        /// </summary>
        public Niunan.CaiPiao.Model.Chongzhi GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            strSql.Append("insert into [chongzhi](");
            strSql.Append("[createtime], [userid], [username], [status], [remark], [money], [bankname], [realname], [bankno], [paytype]  )");
            strSql.Append(" values (");
            strSql.Append("@createtime, @userid, @username, @status, @remark, @money, @bankname, @realname, @bankno, @paytype  ) ;select @@IDENTITY");

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

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