コード例 #1
0
 partial void DeleteProductAttribute(ProductAttribute instance);
コード例 #2
0
 partial void InsertProductAttribute(ProductAttribute instance);
コード例 #3
0
 partial void UpdateProductAttribute(ProductAttribute instance);
コード例 #4
0
		private void detach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.BaseAttribute = null;
		}
コード例 #5
0
		private void attach_ProductAttributes(ProductAttribute entity)
		{
			this.SendPropertyChanging();
			entity.Product = this;
		}
コード例 #6
0
        private bool UpdateAttribute(long newProductId)
        {
            DataGridViewRowCollection selectedRows = dgvBaseAttributes.Rows;
            ProductAttributeService productAttributeService = new ProductAttributeService();

            bool result = true;
            List<int> newAttr = new List<int>();
            List<int> addAttr, removeAttr;

            foreach (DataGridViewRow dgv in selectedRows)
            {
                DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)dgv.Cells[0];
                if (checkbox.Value != null &&
                    (checkbox.Value.ToString().Equals(bool.TrueString) || checkbox.Value.ToString().Equals("1")))
                {
                    newAttr.Add(((BaseAttribute)dgv.DataBoundItem).Id);
                }
            }

            addAttr = newAttr.Except(oldAttr).ToList();
            removeAttr = oldAttr.Except(newAttr).ToList();

            foreach (int add in addAttr)
            {
                ProductAttribute pa = new ProductAttribute()
                {
                    ProductId = (int)newProductId,
                    AttributeId = add
                };
                result = productAttributeService.AddProductAttribute(pa);
            }

            foreach (int remove in removeAttr)
            {
                int removeId = -1;
                using (BaoHienDBDataContext context = new BaoHienDBDataContext(SettingManager.BuildStringConnection()))
                {
                    ProductAttribute pa = context.ProductAttributes
                        .Where(p => p.AttributeId == remove && p.ProductId == (int)newProductId).SingleOrDefault();
                    if (pa != null)
                        removeId = pa.Id;
                }
                if (removeId != -1)
                    result = productAttributeService.DeleteProductAttribute(removeId);
            }
            BaoHienRepository.ResetDBDataContext();
            return result;
        }
コード例 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProductAttributes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProductAttributes(ProductAttribute productAttribute)
 {
     base.AddObject("ProductAttributes", productAttribute);
 }
コード例 #8
0
 /// <summary>
 /// Create a new ProductAttribute object.
 /// </summary>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="attributeId">Initial value of the AttributeId property.</param>
 /// <param name="value">Initial value of the Value property.</param>
 public static ProductAttribute CreateProductAttribute(global::System.Int32 productId, global::System.Int32 attributeId, global::System.String value)
 {
     ProductAttribute productAttribute = new ProductAttribute();
     productAttribute.ProductId = productId;
     productAttribute.AttributeId = attributeId;
     productAttribute.Value = value;
     return productAttribute;
 }