示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_diancai_caipin_manage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_diancai_caipin_manage(");
            strSql.Append("categoryid,cpName,categoryName,cpPrice,zkPrice,priceUnite,cpPic,picUrl,detailContent,createDate,shopid,sortid,scan)");
            strSql.Append(" values (");
            strSql.Append("@categoryid,@cpName,@categoryName,@cpPrice,@zkPrice,@priceUnite,@cpPic,@picUrl,@detailContent,@createDate,@shopid,@sortid,@scan)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryid",    SqlDbType.Int,         4),
                new SqlParameter("@cpName",        SqlDbType.VarChar,   100),
                new SqlParameter("@categoryName",  SqlDbType.VarChar,   100),
                new SqlParameter("@cpPrice",       SqlDbType.Float,       8),
                new SqlParameter("@zkPrice",       SqlDbType.Float,       8),
                new SqlParameter("@priceUnite",    SqlDbType.VarChar,   100),
                new SqlParameter("@cpPic",         SqlDbType.VarChar,   300),
                new SqlParameter("@picUrl",        SqlDbType.VarChar,   300),
                new SqlParameter("@detailContent", SqlDbType.VarChar,   300),
                new SqlParameter("@createDate",    SqlDbType.DateTime),
                new SqlParameter("@shopid",        SqlDbType.Int,         4),
                new SqlParameter("@sortid",        SqlDbType.Int,         4),
                new SqlParameter("@scan",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.categoryid;
            parameters[1].Value  = model.cpName;
            parameters[2].Value  = model.categoryName;
            parameters[3].Value  = model.cpPrice;
            parameters[4].Value  = model.zkPrice;
            parameters[5].Value  = model.priceUnite;
            parameters[6].Value  = model.cpPic;
            parameters[7].Value  = model.picUrl;
            parameters[8].Value  = model.detailContent;
            parameters[9].Value  = model.createDate;
            parameters[10].Value = model.shopid;
            parameters[11].Value = model.sortid;
            parameters[12].Value = model.scan;

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

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

            strSql.Append("select  top 1 id,categoryid,cpName,categoryName,cpPrice,zkPrice,priceUnite,cpPic,picUrl,detailContent,createDate,shopid,sortid,scan from wx_diancai_caipin_manage ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_diancai_caipin_manage DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_diancai_caipin_manage model = new XCWeiXin.Model.wx_diancai_caipin_manage();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["categoryid"] != null && row["categoryid"].ToString() != "")
         {
             model.categoryid = int.Parse(row["categoryid"].ToString());
         }
         if (row["cpName"] != null)
         {
             model.cpName = row["cpName"].ToString();
         }
         if (row["categoryName"] != null)
         {
             model.categoryName = row["categoryName"].ToString();
         }
         if (row["cpPrice"] != null && row["cpPrice"].ToString() != "")
         {
             model.cpPrice = decimal.Parse(row["cpPrice"].ToString());
         }
         if (row["zkPrice"] != null && row["zkPrice"].ToString() != "")
         {
             model.zkPrice = decimal.Parse(row["zkPrice"].ToString());
         }
         if (row["priceUnite"] != null)
         {
             model.priceUnite = row["priceUnite"].ToString();
         }
         if (row["cpPic"] != null)
         {
             model.cpPic = row["cpPic"].ToString();
         }
         if (row["picUrl"] != null)
         {
             model.picUrl = row["picUrl"].ToString();
         }
         if (row["detailContent"] != null)
         {
             model.detailContent = row["detailContent"].ToString();
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["shopid"] != null && row["shopid"].ToString() != "")
         {
             model.shopid = int.Parse(row["shopid"].ToString());
         }
         if (row["sortid"] != null)
         {
             model.sortid = int.Parse(row["sortid"].ToString());
         }
         if (row["scan"] != null && row["scan"].ToString() != "")
         {
             model.scan = int.Parse(row["scan"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_diancai_caipin_manage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_caipin_manage set ");
            strSql.Append("categoryid=@categoryid,");
            strSql.Append("cpName=@cpName,");
            strSql.Append("categoryName=@categoryName,");
            strSql.Append("cpPrice=@cpPrice,");
            strSql.Append("zkPrice=@zkPrice,");
            strSql.Append("priceUnite=@priceUnite,");
            strSql.Append("cpPic=@cpPic,");
            strSql.Append("picUrl=@picUrl,");
            strSql.Append("detailContent=@detailContent,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("shopid=@shopid,");
            strSql.Append("sortid=@sortid,");
            strSql.Append("scan=@scan");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@categoryid",    SqlDbType.Int,         4),
                new SqlParameter("@cpName",        SqlDbType.VarChar,   100),
                new SqlParameter("@categoryName",  SqlDbType.VarChar,   100),
                new SqlParameter("@cpPrice",       SqlDbType.Float,       8),
                new SqlParameter("@zkPrice",       SqlDbType.Float,       8),
                new SqlParameter("@priceUnite",    SqlDbType.VarChar,   100),
                new SqlParameter("@cpPic",         SqlDbType.VarChar,   300),
                new SqlParameter("@picUrl",        SqlDbType.VarChar,   300),
                new SqlParameter("@detailContent", SqlDbType.VarChar,   300),
                new SqlParameter("@createDate",    SqlDbType.DateTime),
                new SqlParameter("@shopid",        SqlDbType.Int,         4),
                new SqlParameter("@sortid",        SqlDbType.Int,         4),
                new SqlParameter("@scan",          SqlDbType.Int,         4),
                new SqlParameter("@id",            SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.categoryid;
            parameters[1].Value  = model.cpName;
            parameters[2].Value  = model.categoryName;
            parameters[3].Value  = model.cpPrice;
            parameters[4].Value  = model.zkPrice;
            parameters[5].Value  = model.priceUnite;
            parameters[6].Value  = model.cpPic;
            parameters[7].Value  = model.picUrl;
            parameters[8].Value  = model.detailContent;
            parameters[9].Value  = model.createDate;
            parameters[10].Value = model.shopid;
            parameters[11].Value = model.sortid;
            parameters[12].Value = model.scan;
            parameters[13].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }