/// <summary> /// 向数据库中插入一条新记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_ProductClsModel">ProductCls实体</param> /// <returns>新插入记录的编号</returns> public int Insert(SqlTransaction sp, ProductClsEntity _ProductClsModel) { string sqlStr = "insert into ProductCls([ShopId],[Clsname],[ParentId],[Status],[Addtime],[Updatetime],[orderby],[Image],[Description]) values(@ShopId,@Clsname,@ParentId,@Status,@Addtime,@Updatetime,@orderby,@Image,@Description) select @@identity"; int res; SqlParameter[] _param = { new SqlParameter("@ShopId", SqlDbType.Int), new SqlParameter("@Clsname", SqlDbType.VarChar), new SqlParameter("@ParentId", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@Addtime", SqlDbType.DateTime), new SqlParameter("@Updatetime", SqlDbType.DateTime), new SqlParameter("@orderby", SqlDbType.Int), new SqlParameter("@Image", SqlDbType.VarChar), new SqlParameter("@Description", SqlDbType.VarChar) }; _param[0].Value = _ProductClsModel.ShopId; _param[1].Value = _ProductClsModel.Clsname; _param[2].Value = _ProductClsModel.ParentId; _param[3].Value = _ProductClsModel.Status; _param[4].Value = _ProductClsModel.Addtime; _param[5].Value = _ProductClsModel.Updatetime; _param[6].Value = _ProductClsModel.orderby; _param[7].Value = _ProductClsModel.Image; _param[8].Value = _ProductClsModel.Description; res = Convert.ToInt32(SqlHelper.ExecuteScalar(sp, CommandType.Text, sqlStr, _param)); return(res); }
/// <summary> /// 向数据表ProductCls更新一条记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_ProductClsModel">_ProductClsModel</param> /// <returns>影响的行数</returns> public int Update(SqlTransaction sp, ProductClsEntity _ProductClsModel) { string sqlStr = "update ProductCls set [ShopId]=@ShopId,[Clsname]=@Clsname,[ParentId]=@ParentId,[Status]=@Status,[Addtime]=@Addtime,[Updatetime]=@Updatetime,[orderby]=@orderby,[Image]=@Image,[Description]=@Description where ClsId=@ClsId"; SqlParameter[] _param = { new SqlParameter("@ClsId", SqlDbType.Int), new SqlParameter("@ShopId", SqlDbType.Int), new SqlParameter("@Clsname", SqlDbType.VarChar), new SqlParameter("@ParentId", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Int), new SqlParameter("@Addtime", SqlDbType.DateTime), new SqlParameter("@Updatetime", SqlDbType.DateTime), new SqlParameter("@orderby", SqlDbType.Int), new SqlParameter("@Image", SqlDbType.VarChar), new SqlParameter("@Description", SqlDbType.VarChar) }; _param[0].Value = _ProductClsModel.ClsId; _param[1].Value = _ProductClsModel.ShopId; _param[2].Value = _ProductClsModel.Clsname; _param[3].Value = _ProductClsModel.ParentId; _param[4].Value = _ProductClsModel.Status; _param[5].Value = _ProductClsModel.Addtime; _param[6].Value = _ProductClsModel.Updatetime; _param[7].Value = _ProductClsModel.orderby; _param[8].Value = _ProductClsModel.Image; _param[9].Value = _ProductClsModel.Description; return(SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param)); }
/// <summary> /// 得到 productcls 数据实体 /// </summary> /// <param name="dr">dr</param> /// <returns>productcls 数据实体</returns> public ProductClsEntity Populate_ProductClsEntity_FromDr(IDataReader dr) { ProductClsEntity Obj = new ProductClsEntity(); Obj.ClsId = ((dr["ClsId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ClsId"]); Obj.ShopId = ((dr["ShopId"]) == DBNull.Value)?0:Convert.ToInt32(dr["ShopId"]); Obj.Clsname = dr["Clsname"].ToString(); Obj.ParentId = ((dr["ParentId"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["ParentId"]); Obj.Status = ((dr["Status"]) == DBNull.Value)?0:Convert.ToInt32(dr["Status"]); Obj.Addtime = ((dr["Addtime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["Addtime"]); Obj.Updatetime = ((dr["Updatetime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(dr["Updatetime"]); Obj.orderby = ((dr["orderby"]) == DBNull.Value)?0:Convert.ToInt32(dr["orderby"]); Obj.Image = dr["Image"].ToString(); Obj.Description = dr["Description"].ToString(); return(Obj); }
/// <summary> /// 根据ID,返回一个ProductCls对象 /// </summary> /// <param name="clsId">clsId</param> /// <returns>ProductCls对象</returns> public ProductClsEntity Get_ProductClsEntity(int clsId) { ProductClsEntity _obj = null; SqlParameter[] _param = { new SqlParameter("@ClsId", SqlDbType.Int) }; _param[0].Value = clsId; string sqlStr = "select * from ProductCls with(nolock) where ClsId=@ClsId"; using (SqlDataReader dr = SqlHelper.ExecuteReader(WebConfig.WfxRW, CommandType.Text, sqlStr, _param)) { while (dr.Read()) { _obj = Populate_ProductClsEntity_FromDr(dr); } } return(_obj); }
/// <summary> /// 删除商品分类,通过店铺id和分类id(如果分类下还有商品不能删除) /// </summary> /// <param name="shopid"></param> /// <param name="clsid"></param> /// <returns></returns> public int DeleteProductCls(int shopid, int clsid) { try { bool b = Weifenxiao.BLL.ProductsBLL.GetInstance().Exists(shopid, clsid); if (!b) { ProductClsEntity model = GetAdminSingle(clsid); model.Status = 0; model.Updatetime = DateTime.Now; Update(model); return(1); } else { return(0); } } catch (Exception ex) { return(-1); } }
/// <summary> /// 得到 productcls 数据实体 /// </summary> /// <param name="row">row</param> /// <returns>productcls 数据实体</returns> public ProductClsEntity Populate_ProductClsEntity_FromDr(DataRow row) { ProductClsEntity Obj = new ProductClsEntity(); if (row != null) { Obj.ClsId = ((row["ClsId"]) == DBNull.Value)?0:Convert.ToInt32(row["ClsId"]); Obj.ShopId = ((row["ShopId"]) == DBNull.Value)?0:Convert.ToInt32(row["ShopId"]); Obj.Clsname = row["Clsname"].ToString(); Obj.ParentId = ((row["ParentId"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["ParentId"]); Obj.Status = ((row["Status"]) == DBNull.Value)?0:Convert.ToInt32(row["Status"]); Obj.Addtime = ((row["Addtime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["Addtime"]); Obj.Updatetime = ((row["Updatetime"]) == DBNull.Value)?Convert.ToDateTime("1900-1-1"):Convert.ToDateTime(row["Updatetime"]); Obj.orderby = ((row["orderby"]) == DBNull.Value)?0:Convert.ToInt32(row["orderby"]); Obj.Image = row["Image"].ToString(); Obj.Description = row["Description"].ToString(); } else { return(null); } return(Obj); }
protected void selectcity_Load(object sender, EventArgs e) { UserIdentity identity = User.Identity as UserIdentity; if (!string.IsNullOrEmpty(selectcity.Text)) { IList <Weifenxiao.Entity.ProductClsEntity> list = Weifenxiao.BLL.ProductClsBLL.GetInstance().GetListByParentId(int.Parse(selectcity.Text), identity.ShopID); if (list != null && list.Count > 0) { ProductClsEntity model = new ProductClsEntity(); ddl_produclsid.DataSource = list; ddl_produclsid.DataTextField = "Clsname"; ddl_produclsid.DataValueField = "ClsId"; ddl_produclsid.DataBind(); for (int i = 0; i < ddl_produclsid.Items.Count; i++) { if (ddl_produclsid.Items[i].Value == selecteurozone.Text) { ddl_produclsid.Items[i].Selected = true; } } } } }
public void Update(ProductClsEntity productClsEntity) { productClsdal.Update(productClsEntity); }
public int Insert(ProductClsEntity productClsEntity) { return(productClsdal.Insert(productClsEntity)); }