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

            strSql.Append("update qihaoinfo set ");
            strSql.Append("createtime=@createtime, qihao=@qihao, starttime=@starttime, endtime=@endtime, kjtime=@kjtime, remark=@remark, czid=@czid, czname=@czname, kjcode=@kjcode, kjcode2=@kjcode2, code1=@code1, code2=@code2, code3=@code3  ");
            strSql.Append(" where id=@id ");
            using (var connection = ConnectionFactory.GetOpenConnection(ConnStr))
            {
                int i = connection.Execute(strSql.ToString(), model);
                return(i > 0);
            }
        }
Example #2
0
        /// <summary>得到一个对象实体
        ///
        /// </summary>
        public Niunan.CaiPiao.Model.Qihaoinfo GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            strSql.Append("insert into qihaoinfo(");
            strSql.Append("createtime, qihao, starttime, endtime, kjtime, remark, czid, czname, kjcode, kjcode2, code1, code2, code3  )");
            strSql.Append(" values (");
            strSql.Append("@createtime, @qihao, @starttime, @endtime, @kjtime, @remark, @czid, @czname, @kjcode, @kjcode2, @code1, @code2, @code3  ) ;select @@IDENTITY");

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

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