Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Buy model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update Buy set ");

            sql.Append(" title = @title , ");
            sql.Append(" sn = @sn , ");
            sql.Append(" brief = @brief , ");
            sql.Append(" cate_id = @cate_id , ");
            sql.Append(" type = @type , ");
            sql.Append(" level = @level , ");
            sql.Append(" level_child = @level_child , ");
            sql.Append(" detail = @detail , ");
            sql.Append(" start_price = @start_price , ");
            sql.Append(" end_price = @end_price , ");
            sql.Append(" validDay = @validDay , ");
            sql.Append(" stocks = @stocks , ");
            sql.Append(" status = @status , ");
            sql.Append(" v_status = @v_status , ");
            sql.Append(" p_status = @p_status , ");
            sql.Append(" remark = @remark , ");
            sql.Append(" qq = @qq , ");
            sql.Append(" user_name = @user_name , ");
            sql.Append(" mobile = @mobile , ");
            sql.Append(" good_rating = @good_rating , ");
            sql.Append(" user_id = @user_id , ");
            sql.Append(" rating = @rating , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" created = @created , ");
            sql.Append(" credentials = @credentials , ");
            sql.Append(" click = @click , ");
            sql.Append(" role_id = @role_id , ");
            sql.Append(" admin_id = @admin_id  ");
            sql.Append(" where id=@id ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("更新数据无效");
            }
        }
Пример #2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.Buy obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            var old = dao.Get(obj.Id);

            if (old == null)
            {
                throw new ApplicationException("非法操作记录不存在");
            }

            dao.Delete(obj.Id);
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.Buy obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            if (obj.Title.IsNullOrWhiteSpace())
            {
                throw new ApplicationException("标题不能为空!");
            }

            if (obj.Brief.IsNullOrWhiteSpace())
            {
                throw new ApplicationException("求购描述不能为空!");
            }

            if (obj.Stocks.IsNull() || obj.Stocks == 0)
            {
                throw new ApplicationException("求购数量不能为空!");
            }

            if (obj.Cate_Id == 0)
            {
                throw new ApplicationException("请选择网店类型!");
            }

            if (obj.User_Name.IsNullOrWhiteSpace())
            {
                throw new ApplicationException("请填写您的姓名!");
            }

            if (obj.Mobile.IsNullOrWhiteSpace())
            {
                throw new ApplicationException("请填写您的手机!");
            }

            obj.Sn = string.Format("{0:yyMMddmmss}{1}", DateTime.Now, dao.GetMaxId() + 1);

            dao.Insert(obj);
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.Buy model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_buy(");
            sql.Append("title,sn,brief,cate_id,type,level,level_child,detail,start_price,end_price,validDay,stocks,status,v_status,p_status,remark,qq,user_name,mobile,good_rating,user_id,rating,add_time,created,credentials,click,role_id,admin_id");
            sql.Append(") values (");
            sql.Append("@title,@sn,@brief,@cate_id,@type,@level,@level_child,@detail,@start_price,@end_price,@validDay,@stocks,@status,@v_status,@p_status,@remark,@qq,@user_name,@mobile,@good_rating,@user_id,@rating,@add_time,@created,@credentials,@click,@role_id,@admin_id");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("插入数据无效");
            }
        }