Ejemplo n.º 1
0
        public static ProductKitComponentCollection LoadForKitComponent(Int32 kitComponentId)
        {
            ProductKitComponentCollection ProductKitComponents = new ProductKitComponentCollection();
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT!
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT " + ProductKitComponent.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_ProductKitComponents");
            selectQuery.Append(" WHERE KitComponentId = @kitComponentId");
            selectQuery.Append(" ORDER BY OrderBy");
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@kitComponentId", System.Data.DbType.Int32, kitComponentId);
            //EXECUTE THE COMMAND
            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read())
                {
                    ProductKitComponent productKitComponent = new ProductKitComponent();
                    ProductKitComponent.LoadDataReader(productKitComponent, dr);
                    ProductKitComponents.Add(productKitComponent);
                }
                dr.Close();
            }
            return(ProductKitComponents);
        }
 /// <summary>
 /// Loads the given ProductKitComponent object from the given database data reader.
 /// </summary>
 /// <param name="productKitComponent">The ProductKitComponent object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(ProductKitComponent productKitComponent, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     productKitComponent.ProductId      = dr.GetInt32(0);
     productKitComponent.KitComponentId = dr.GetInt32(1);
     productKitComponent.OrderBy        = dr.GetInt16(2);
     productKitComponent.IsDirty        = false;
 }
Ejemplo n.º 3
0
        public static bool Delete(Int32 productId, Int32 kitComponentId)
        {
            ProductKitComponent productKitComponent = new ProductKitComponent();

            if (productKitComponent.Load(productId, kitComponentId))
            {
                return(productKitComponent.Delete());
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new KitComponent object based on this KitComponent object and attaches it as a component to the given product
        /// </summary>
        /// <param name="productId">Id of the product to which to attach the branched component</param>
        /// <returns>The newly created KitComponent</returns>
        public KitComponent Branch(int productId)
        {
            //REMOVE SPECIFIED PRODUCT FROM ORIGINAL COMPONENT
            short orderBy = -1;
            int   index   = this.ProductKitComponents.IndexOf(productId, this.KitComponentId);

            if (index > -1)
            {
                orderBy = this.ProductKitComponents[index].OrderBy;
                this.ProductKitComponents.DeleteAt(index);
            }
            //CREATE A COPY
            KitComponent branchedComponent = this.InternalCopy();
            //ATTACH THE CURRENT PRODUCT
            ProductKitComponent pkc = new ProductKitComponent(productId, branchedComponent.KitComponentId);

            pkc.OrderBy = orderBy;
            branchedComponent.ProductKitComponents.Add(pkc);
            branchedComponent.Save();
            //RETURN THE BRANCHED COMPONENT
            return(branchedComponent);
        }
Ejemplo n.º 5
0
 public static SaveResult Insert(ProductKitComponent productKitComponent)
 {
     return(productKitComponent.Save());
 }
Ejemplo n.º 6
0
 public static bool Delete(ProductKitComponent productKitComponent)
 {
     return(productKitComponent.Delete());
 }
Ejemplo n.º 7
0
 public static SaveResult Update(ProductKitComponent productKitComponent)
 {
     return(productKitComponent.Save());
 }