public void PictureSetCover(string puid, int pid) { //设置当前图片封面 ProductPicture curr = this.PictureSingle(pid); Product pro = new ContentsCom().ProductSingle(puid); DbTransaction tran = Gateway.Default.BeginTransaction(); try { //去除当前相册的封面 Gateway.Default.Update <ProductPicture>(new PropertyItem[] { ProductPicture._.Pp_IsCover }, new object[] { false }, ProductPicture._.Pd_Uid == puid, tran); Gateway.Default.Update <ProductPicture>(new PropertyItem[] { ProductPicture._.Pp_IsCover }, new object[] { true }, ProductPicture._.Pp_Id == pid, tran); pro.Pd_Logo = curr.Pp_File; pro.Pd_LogoSmall = curr.Pp_FileSmall; Gateway.Default.Save <Product>(pro, tran); tran.Commit(); } catch (Exception e) { tran.Rollback(); throw e; } finally { Gateway.Default.CloseTransaction(tran); } }
/// <summary> /// 修改 /// </summary> /// <param name="entity">业务实体</param> public void PictureSave(ProductPicture entity) { Song.Entities.Product pd = new ContentsCom().ProductSingle(entity.Pd_Uid); if (pd != null) { entity.Pd_Id = pd.Pd_Id; entity.Pd_Name = pd.Pd_Name; } Gateway.Default.Save <ProductPicture>(entity); }
public int MessageAdd(ProductMessage entity) { if (entity.Pd_Id >= 0) { Song.Entities.Product p = new ContentsCom().ProductSingle((int)entity.Pd_Id); if (p != null) { entity.Pd_Name = p.Pd_Name; } } Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } return(Gateway.Default.Save <ProductMessage>(entity)); }
/// <summary> /// 删除 /// </summary> /// <param name="entity">业务实体</param> public void PictureDelete(ProductPicture entity) { //如果不是封面图片,直接删除 if (!entity.Pp_IsCover) { Gateway.Default.Delete <ProductPicture>(ProductPicture._.Pp_Id == entity.Pp_Id); Song.CustomControl.FileUpload.Delete("Product", entity.Pp_File); } else { Song.Entities.Product pd = new ContentsCom().ProductSingle(entity.Pd_Uid); //如果是封面图片,删除后需再指定一个封面 DbTransaction tran = Gateway.Default.BeginTransaction(); try { Song.Entities.ProductPicture pp = Gateway.Default.From <ProductPicture>().Where(ProductPicture._.Pd_Id == entity.Pd_Id && ProductPicture._.Pp_Id != entity.Pp_Id).OrderBy(ProductPicture._.Pp_Tax.Asc).ToFirst <ProductPicture>(); if (pp != null) { pp.Pp_IsCover = true; pd.Pd_Logo = pp.Pp_File; pd.Pd_LogoSmall = pp.Pp_FileSmall; Gateway.Default.Save <Product>(pd, tran); Gateway.Default.Save <ProductPicture>(pp, tran); Gateway.Default.Delete <ProductPicture>(ProductPicture._.Pp_Id == entity.Pp_Id, tran); Song.CustomControl.FileUpload.Delete("Product", entity.Pp_File); tran.Commit(); } } catch (Exception e) { tran.Rollback(); throw e; } finally { Gateway.Default.CloseTransaction(tran); } } }
/// <summary> /// 添加产品图片 /// </summary> /// <param name="entity"></param> public void PictureAdd(ProductPicture entity) { //创建时间 entity.Pp_CrtTime = DateTime.Now; entity.Pp_IsUse = true; entity.Pp_IsCover = false; Song.Entities.Product pd = new ContentsCom().ProductSingle(entity.Pd_Uid); if (pd != null) { entity.Pd_Id = pd.Pd_Id; entity.Pd_Name = pd.Pd_Name; } object obj = Gateway.Default.Count <ProductPicture>(ProductPicture._.Pd_Uid == entity.Pd_Uid); //设置当前图片封面 DbTransaction tran = Gateway.Default.BeginTransaction(); try { if ((int)obj < 1) { entity.Pp_IsCover = true; pd.Pd_Logo = entity.Pp_File; pd.Pd_LogoSmall = entity.Pp_FileSmall; Gateway.Default.Save <Product>(pd, tran); } Gateway.Default.Save <ProductPicture>(entity, tran); tran.Commit(); } catch (Exception e) { tran.Rollback(); throw e; } finally { Gateway.Default.CloseTransaction(tran); } }