示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Tea.Model.chu_shop_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "chu_shop_goods set ");
            strSql.Append("chu_shop=@chu_shop,");
            strSql.Append("chu_goods=@chu_goods,");
            strSql.Append("chu_add_date=@chu_add_date,");
            strSql.Append("chu_begin_date=@chu_begin_date,");
            strSql.Append("chu_end_date=@chu_end_date,");
            strSql.Append("chu_where=@chu_where,");
            strSql.Append("chu_status=@chu_status,");
            strSql.Append("chu_type=@chu_type,");
            strSql.Append("chu_typeid=@chu_typeid,");
            strSql.Append("chu_title=@chu_title,");
            strSql.Append("chu_sort=@chu_sort");
            strSql.Append(" where chu_id=@chu_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@chu_shop",       SqlDbType.Int,         4),
                new SqlParameter("@chu_goods",      SqlDbType.Int,         4),
                new SqlParameter("@chu_add_date",   SqlDbType.DateTime),
                new SqlParameter("@chu_begin_date", SqlDbType.DateTime),
                new SqlParameter("@chu_end_date",   SqlDbType.DateTime),
                new SqlParameter("@chu_where",      SqlDbType.NVarChar,   32),
                new SqlParameter("@chu_status",     SqlDbType.Int,         4),
                new SqlParameter("@chu_type",       SqlDbType.NVarChar,   64),
                new SqlParameter("@chu_typeid",     SqlDbType.Int,         4),
                new SqlParameter("@chu_title",      SqlDbType.NVarChar,  256),
                new SqlParameter("@chu_sort",       SqlDbType.Int,         4),
                new SqlParameter("@chu_id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.chu_shop;
            parameters[1].Value  = model.chu_goods;
            parameters[2].Value  = model.chu_add_date;
            parameters[3].Value  = model.chu_begin_date;
            parameters[4].Value  = model.chu_end_date;
            parameters[5].Value  = model.chu_where;
            parameters[6].Value  = model.chu_status;
            parameters[7].Value  = model.chu_type;
            parameters[8].Value  = model.chu_typeid;
            parameters[9].Value  = model.chu_title;
            parameters[10].Value = model.chu_sort;
            parameters[11].Value = model.chu_id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Tea.Model.chu_shop_goods DataRowToModel(DataRow row)
 {
     Tea.Model.chu_shop_goods model = new Tea.Model.chu_shop_goods();
     if (row != null)
     {
         if (row["chu_id"] != null && row["chu_id"].ToString() != "")
         {
             model.chu_id = int.Parse(row["chu_id"].ToString());
         }
         if (row["chu_shop"] != null && row["chu_shop"].ToString() != "")
         {
             model.chu_shop = int.Parse(row["chu_shop"].ToString());
         }
         if (row["chu_goods"] != null && row["chu_goods"].ToString() != "")
         {
             model.chu_goods = int.Parse(row["chu_goods"].ToString());
         }
         if (row["chu_add_date"] != null && row["chu_add_date"].ToString() != "")
         {
             model.chu_add_date = DateTime.Parse(row["chu_add_date"].ToString());
         }
         if (row["chu_begin_date"] != null && row["chu_begin_date"].ToString() != "")
         {
             model.chu_begin_date = DateTime.Parse(row["chu_begin_date"].ToString());
         }
         if (row["chu_end_date"] != null && row["chu_end_date"].ToString() != "")
         {
             model.chu_end_date = DateTime.Parse(row["chu_end_date"].ToString());
         }
         if (row["chu_where"] != null)
         {
             model.chu_where = row["chu_where"].ToString();
         }
         if (row["chu_status"] != null && row["chu_status"].ToString() != "")
         {
             model.chu_status = int.Parse(row["chu_status"].ToString());
         }
         if (row["chu_type"] != null)
         {
             model.chu_type = row["chu_type"].ToString();
         }
         if (row["chu_typeid"] != null && row["chu_typeid"].ToString() != "")
         {
             model.chu_typeid = int.Parse(row["chu_typeid"].ToString());
         }
         if (row["chu_title"] != null)
         {
             model.chu_title = row["chu_title"].ToString();
         }
         if (row["chu_sort"] != null && row["chu_sort"].ToString() != "")
         {
             model.chu_sort = int.Parse(row["chu_sort"].ToString());
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tea.Model.chu_shop_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "chu_shop_goods(");
            strSql.Append("chu_shop,chu_goods,chu_add_date,chu_begin_date,chu_end_date,chu_where,chu_status,chu_type,chu_typeid,chu_title,chu_sort)");
            strSql.Append(" values (");
            strSql.Append("@chu_shop,@chu_goods,@chu_add_date,@chu_begin_date,@chu_end_date,@chu_where,@chu_status,@chu_type,@chu_typeid,@chu_title,@chu_sort)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@chu_shop",       SqlDbType.Int,         4),
                new SqlParameter("@chu_goods",      SqlDbType.Int,         4),
                new SqlParameter("@chu_add_date",   SqlDbType.DateTime),
                new SqlParameter("@chu_begin_date", SqlDbType.DateTime),
                new SqlParameter("@chu_end_date",   SqlDbType.DateTime),
                new SqlParameter("@chu_where",      SqlDbType.NVarChar,   32),
                new SqlParameter("@chu_status",     SqlDbType.Int,         4),
                new SqlParameter("@chu_type",       SqlDbType.NVarChar,   64),
                new SqlParameter("@chu_typeid",     SqlDbType.Int,         4),
                new SqlParameter("@chu_title",      SqlDbType.NVarChar,  256),
                new SqlParameter("@chu_sort",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.chu_shop;
            parameters[1].Value  = model.chu_goods;
            parameters[2].Value  = model.chu_add_date;
            parameters[3].Value  = model.chu_begin_date;
            parameters[4].Value  = model.chu_end_date;
            parameters[5].Value  = model.chu_where;
            parameters[6].Value  = model.chu_status;
            parameters[7].Value  = model.chu_type;
            parameters[8].Value  = model.chu_typeid;
            parameters[9].Value  = model.chu_title;
            parameters[10].Value = model.chu_sort;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tea.Model.chu_shop_goods GetModel(int chu_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 chu_id,chu_shop,chu_goods,chu_add_date,chu_begin_date,chu_end_date,chu_where,chu_status,chu_type,chu_typeid,chu_title,chu_sort from " + databaseprefix + "chu_shop_goods ");
            strSql.Append(" where chu_id=@chu_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@chu_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = chu_id;

            Tea.Model.chu_shop_goods model = new Tea.Model.chu_shop_goods();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }