Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Tea.Model.goods_sales model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "goods_sales set ");
            strSql.Append("main_id=@main_id,");
            strSql.Append("parent_id=@parent_id,");
            strSql.Append("goods_id=@goods_id,");
            strSql.Append("title=@title,");
            strSql.Append("add_time=@add_time,");
            strSql.Append("company=@company");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@main_id",   SqlDbType.Int,         4),
                new SqlParameter("@parent_id", SqlDbType.Int,         4),
                new SqlParameter("@goods_id",  SqlDbType.Int,         4),
                new SqlParameter("@title",     SqlDbType.NVarChar,  100),
                new SqlParameter("@add_time",  SqlDbType.DateTime),
                new SqlParameter("@company",   SqlDbType.Int,         4),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.main_id;
            parameters[1].Value = model.parent_id;
            parameters[2].Value = model.goods_id;
            parameters[3].Value = model.title;
            parameters[4].Value = model.add_time;
            parameters[5].Value = model.company;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Tea.Model.goods_sales DataRowToModel(DataRow row)
 {
     Tea.Model.goods_sales model = new Tea.Model.goods_sales();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["main_id"] != null && row["main_id"].ToString() != "")
         {
             model.main_id = int.Parse(row["main_id"].ToString());
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["goods_id"] != null && row["goods_id"].ToString() != "")
         {
             model.goods_id = int.Parse(row["goods_id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
         if (row["company"] != null && row["company"].ToString() != "")
         {
             model.company = int.Parse(row["company"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tea.Model.goods_sales model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "goods_sales(");
            strSql.Append("main_id,parent_id,goods_id,title,add_time,company)");
            strSql.Append(" values (");
            strSql.Append("@main_id,@parent_id,@goods_id,@title,@add_time,@company)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@main_id",   SqlDbType.Int,         4),
                new SqlParameter("@parent_id", SqlDbType.Int,         4),
                new SqlParameter("@goods_id",  SqlDbType.Int,         4),
                new SqlParameter("@title",     SqlDbType.NVarChar,  100),
                new SqlParameter("@add_time",  SqlDbType.DateTime),
                new SqlParameter("@company",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.main_id;
            parameters[1].Value = model.parent_id;
            parameters[2].Value = model.goods_id;
            parameters[3].Value = model.title;
            parameters[4].Value = model.add_time;
            parameters[5].Value = model.company;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tea.Model.goods_sales GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,main_id,parent_id,goods_id,title,add_time,company from " + databaseprefix + "goods_sales ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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