partial void DeleteProductAttribute(ProductAttribute instance);
partial void InsertProductAttribute(ProductAttribute instance);
partial void UpdateProductAttribute(ProductAttribute instance);
private void detach_ProductAttributes(ProductAttribute entity) { this.SendPropertyChanging(); entity.BaseAttribute = null; }
private void attach_ProductAttributes(ProductAttribute entity) { this.SendPropertyChanging(); entity.Product = this; }
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; }
/// <summary> /// Deprecated Method for adding a new object to the ProductAttributes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProductAttributes(ProductAttribute productAttribute) { base.AddObject("ProductAttributes", productAttribute); }
/// <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; }