Example #1
0
 public bool Delete(Guid Id)
 {
     bool toReturn = false;
     using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
     {
         ProductSubEntity _ProductSubEntity = new ProductSubEntity(Id);
         if (adapter.FetchEntity(_ProductSubEntity))
         {
             adapter.DeleteEntity(_ProductSubEntity);
             toReturn = true;
         }
     }
     return toReturn;
 }
Example #2
0
        //主子表保存
        public void SubmitForm(ProductEntity productEntity, string keyValue, List <ProductSubEntity> listProductSub)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                productEntity.Modify(keyValue);
            }
            else
            {
                productEntity.Create();
            }
            List <ProductSubEntity> listProductSubUpdate = new List <ProductSubEntity>();
            List <FileEntity>       listFile             = new List <FileEntity>();

            foreach (var itemId in listProductSub)
            {
                ProductSubEntity productSubEntity = new ProductSubEntity();
                productSubEntity.F_ParentId      = productEntity.F_Id;
                productSubEntity.Attribute       = itemId.Attribute;
                productSubEntity.PictureGuId     = itemId.PictureGuId;
                productSubEntity.SKU             = itemId.SKU;
                productSubEntity.Supplier        = itemId.Supplier;
                productSubEntity.PurchaseAddress = itemId.PurchaseAddress;
                productSubEntity.HWeight         = itemId.HWeight;
                productSubEntity.GWeight         = itemId.GWeight;
                productSubEntity.SWeight         = itemId.SWeight;
                productSubEntity.Long            = itemId.Long;
                productSubEntity.Wide            = itemId.Wide;
                productSubEntity.High            = itemId.High;
                productSubEntity.PurchaseCost    = itemId.PurchaseCost;
                productSubEntity.TransportCost   = itemId.TransportCost;
                productSubEntity.OtherCost       = itemId.OtherCost;
                productSubEntity.F_Description   = itemId.F_Description;
                productSubEntity.Create();
                var      guid  = productSubEntity.F_Id;
                string[] files = itemId.PictureGuId.Split(',');
                foreach (string f in files)
                {
                    FileEntity file = new FileEntity();
                    file.F_ParentId = guid;
                    file.F_File     = f;
                    file.Create();
                    listFile.Add(file);
                }
                listProductSubUpdate.Add(productSubEntity);
            }
            service.SubmitForm(productEntity, listProductSubUpdate, keyValue);
        }
Example #3
0
        public bool Update(Guid Id, Guid ProductId, string ProductName, decimal Price, string Description, string CreatedBy)
        {
            bool toReturn = false;
            using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                ProductSubEntity _ProductSubEntity = new ProductSubEntity(Id);
                if (adapter.FetchEntity(_ProductSubEntity))
                {

                    _ProductSubEntity.ProductId = ProductId;
                    _ProductSubEntity.ProductName = ProductName;
                    _ProductSubEntity.Price = Price;
                    _ProductSubEntity.Description = Description;
                    _ProductSubEntity.CreatedBy = CreatedBy;
                    adapter.SaveEntity(_ProductSubEntity, true);
                    toReturn = true;
                }
            }
            return toReturn;
        }
Example #4
0
 public bool Update(ProductSubEntity _ProductSubEntity, RelationPredicateBucket filter)
 {
     bool toReturn = false;
     using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
     {
         adapter.UpdateEntitiesDirectly(_ProductSubEntity, filter);
         toReturn = true;
     }
     return toReturn;
 }
Example #5
0
        public bool Update(ProductSubEntity _ProductSubEntity)
        {
            bool toReturn = false;
            using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {
                RelationPredicateBucket filter = new RelationPredicateBucket();
                IPredicateExpression _PredicateExpression = new PredicateExpression();
                _PredicateExpression.Add(ProductSubFields.Id == _ProductSubEntity.Id);

                filter.PredicateExpression.Add(_PredicateExpression);

                adapter.UpdateEntitiesDirectly(_ProductSubEntity, filter);
                toReturn = true;
            }
            return toReturn;
        }
Example #6
0
 public ProductSubEntity SelectOne(Guid Id)
 {
     ProductSubEntity toReturn = null;
     using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
     {
         ProductSubEntity _ProductSubEntity = new ProductSubEntity(Id);
         if (adapter.FetchEntity(_ProductSubEntity))
         {
             toReturn = _ProductSubEntity;
         }
     }
     return toReturn;
 }
Example #7
0
        public ProductSubEntity Insert(Guid ProductId, string ProductName, decimal Price, string Description, string CreatedBy)
        {
            ProductSubEntity _ProductSubEntity = new ProductSubEntity();
            using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
            {

                _ProductSubEntity.ProductId = ProductId;
                _ProductSubEntity.ProductName = ProductName;
                _ProductSubEntity.Price = Price;
                _ProductSubEntity.Description = Description;
                _ProductSubEntity.CreatedBy = CreatedBy;
                adapter.SaveEntity(_ProductSubEntity, true);
            }
            return _ProductSubEntity;
        }
Example #8
0
 public ProductSubEntity Insert(ProductSubEntity _ProductSubEntity)
 {
     using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
     {
         adapter.SaveEntity(_ProductSubEntity, true);
     }
     return _ProductSubEntity;
 }
Example #9
0
    ProductSubEntity getProductSub()
    {
        ProductSubEntity sub = new ProductSubEntity();

        sub.Id = Guid.NewGuid();
        sub.ProductId = ProductId;
        sub.ProductName = Filter.GetMaxString(txtProductName.Text.Trim(), ProductSubFields.ProductName.MaxLength);
        sub.Price = FNumber.ConvertDecimal(txtPriceSub.Text.Trim());
        sub.Description = Filter.GetMaxString(txtDescription.Text.Trim(), ProductSubFields.Description.MaxLength);
        sub.CreatedBy = Util.CurrentUserName;

        return sub;
    }