public void RecalculateAnimationProduct(AnimationProduct animationProduct = null, LongTaskExecutor executor = null) { if (animationProduct != null) { animationProduct.CalculateTotals(); animationProduct.CalculateTotalCapacity(); if (executor != null) { executor.SendProgressMessage(" Calculating capacities for " + animationProduct.ProductIdentifier); } return; } foreach (AnimationProduct ap in AnimationProducts) { ap.CalculateTotals(); ap.CalculateTotalCapacity(); if (executor != null) { executor.SendProgressMessage(" Calculating capacities for " + ap.ProductIdentifier); } } }
protected AnimationProduct CreateAnimationProduct(Division division, Animation animation, int normalMultiple, int warehouseMultiple, Signature signature) { AnimationProduct animationProduct = new AnimationProduct(); animationProduct.ID = Guid.NewGuid(); animationProduct.Animation = animation; animationProduct.ItemType = CreateItemType(division); animationProduct.ItemGroup = CreateItemGroup(division); animationProduct.Product = CreateProduct(division); animationProduct.Signature = signature; if (normalMultiple == warehouseMultiple) { Multiple multiple = CreateMultiple(animationProduct.Product, normalMultiple); animationProduct.Multiple = multiple; animationProduct.Multiple1 = multiple; } else { animationProduct.Multiple = CreateMultiple(animationProduct.Product, normalMultiple); animationProduct.Multiple1 = CreateMultiple(animationProduct.Product, warehouseMultiple); } animationProduct.OnCAS = true; animationProduct.ConfirmedMADMonth = DateTime.Now; animationProduct.StockRisk = true; animationProduct.DeliveryRisk = true; animationProduct.SortOrder = 1; return animationProduct; }
protected AnimationProductDetail CreateAnimationProductDetail(AnimationProduct animationProduct, SalesArea salesArea) { AnimationProductDetail animationProductDetail = new AnimationProductDetail(); animationProductDetail.ID = Guid.NewGuid(); animationProductDetail.AnimationProduct = animationProduct; animationProductDetail.SalesArea = salesArea; //animationProductDetail.BDCQuantity = 10; return animationProductDetail; }
public void RecalculateAnimationProduct(RecalculationType calcType, AnimationProduct entity = null) { if (calcType == RecalculationType.CalculateTotal) { LongTaskExecutor recalculationExecutor = new LongTaskExecutor("Recalculating capacities ..."); recalculationExecutor.DoWork += new DoWorkEventHandler(recalculationExecutor_DoWork); recalculationExecutor.Run(entity); } else if (calcType == RecalculationType.CalculateActiveAnimations) { LongTaskExecutor calcActiveAnimationExecutor = new LongTaskExecutor("Recalculating active animations ..."); calcActiveAnimationExecutor.DoWork += new DoWorkEventHandler(calcActiveAnimationExecutor_DoWork); calcActiveAnimationExecutor.Run(); } else if (calcType == RecalculationType.CalculateTotalCapacity && entity != null) { LongTaskExecutor calcTotalCapacityExecutor = new LongTaskExecutor("Recalculating total capacity for " + entity.ProductIdentifier); calcTotalCapacityExecutor.DoWork += new DoWorkEventHandler(calcTotalCapacityExecutor_DoWork); calcTotalCapacityExecutor.Run(); } else if (calcType == RecalculationType.CalculateProductRecieved && entity != null) { LongTaskExecutor calcTotalCapacityExecutor = new LongTaskExecutor("Recalculating product recieved "); calcTotalCapacityExecutor.DoWork += new DoWorkEventHandler(calcProductRecievedExecutor_DoWork); calcTotalCapacityExecutor.Run(); } else if (calcType == RecalculationType.CalculateTotalAnimationQuantity) { Animation.AnimationProducts.ToList().ForEach(ap => ap.TotalAnimationQuantity = -1); } }
public void ProductDelete(AnimationProduct entity) { try { Db.AnimationProducts.DeleteOnSubmit(entity); Db.SubmitChanges(); RecalculateAnimationProduct(RecalculationType.CalculateActiveAnimations); RecalculateAnimationProduct(RecalculationType.CalculateTotalAnimationQuantity); Animation.ObservableProductDetails = null; } catch (Exception exc) { MessageBox.Show(SystemMessagesManager.Instance.GetMessage("TableViewExceptionSql", Utility.GetExceptionsMessages(exc))); } }
public void ProductInsertUpdate(AnimationProduct entity) { if (entity.IDBrandAxe == Guid.Empty) { entity.IDBrandAxe = null; } if (entity.IDCategory == Guid.Empty) { entity.IDCategory = null; } if (entity.IDSignature == Guid.Empty) { entity.IDSignature = null; } if (entity.IDItemType == Guid.Empty) { entity.IDItemType = null; } if (entity.IDMultipleNormal == Guid.Empty) { entity.IDMultipleNormal = null; } if (entity.IDMultipleWarehouse == Guid.Empty) { entity.IDMultipleWarehouse = null; } if (entity.ID == Guid.Empty) { Db.AnimationProducts.InsertOnSubmit(entity); } try { bool isInsert = entity.ID == Guid.Empty; submitDBChanges(); //Db.SubmitChanges(); if (isInsert) { //TV: Allocations are recreated in trigger recreateAllocationsForProduct(entity); } } catch (SqlException exc) { SqlException sqlExc = exc as SqlException; if (sqlExc.Number == 50000 && sqlExc.Class == 16) { AnimationProduct originalEntity = new DbDataContext().AnimationProducts.Single(ap => ap.ID == entity.ID); if (originalEntity != null) { switch(sqlExc.State) { case 28: entity.CleanEntityRef("IDItemType"); entity.IDItemType = originalEntity.IDItemType; entity.CleanEntityRef("IDSignature"); entity.IDSignature = originalEntity.IDSignature; entity.CleanEntityRef("IDBrandAxe"); entity.IDBrandAxe = originalEntity.IDBrandAxe; entity.CleanEntityRef("IDCategory"); entity.IDCategory = originalEntity.IDCategory; break; case 30: case 32: case 33: case 34: case 35: entity.CleanEntityRef("IDMultipleNormal"); entity.IDMultipleNormal = originalEntity.IDMultipleNormal; entity.IDMultipleWarehouse = originalEntity.IDMultipleWarehouse; break; } Db.SubmitChanges(); } else { ProductDelete(entity); Animation.AnimationProducts.Remove(entity); } } throw; } catch (LorealChangeConflictException exc) { ResolveChangeConflict(exc); } catch (Exception exc) { if (entity.ID == Guid.Empty) { Db.AnimationProducts.DeleteOnSubmit(entity); } MessageBox.Show(SystemMessagesManager.Instance.GetMessage("TableViewExceptionSql", Utility.GetExceptionsMessages(exc))); } }
private void recreateAllocationsForProduct(AnimationProduct animationProduct) { LongTaskExecutor recreateAllocationsExecutor = new LongTaskExecutor("Recreating allocations"); recreateAllocationsExecutor.DoWork += new DoWorkEventHandler(recreateAllocationsForProductExecutor_DoWork); recreateAllocationsExecutor.Run(animationProduct); }
private void TableView_RowCanceled(object sender, RowEventArgs e) { if (NewItemRow != null) { if (NewItemRow.Animation != null) NewItemRow.Animation.AnimationProducts.Remove(NewItemRow); if (NewItemRow.Product != null) NewItemRow.Product.AnimationProducts.Remove(NewItemRow); NewItemRow = null; } }
private void TableView_InitNewRow(object sender, DevExpress.Xpf.Grid.InitNewRowEventArgs e) { AnimationProduct product = grdProduct.GetRow(e.RowHandle) as AnimationProduct; // Sometimes DevExpress throws an ArgumentOutOfRangeException, if there is any sort or filtering // now, we just block the application from crushing down try { product.Product = new Product(); } catch { } try { product.Animation = animationManager.Animation; } catch { } try { product.ConfirmedMADMonth = DateTime.Now; } catch { } NewItemRow = product; }
void InsertOrUpdate(AnimationProduct entity) { try { entity.Animation = animationManager.Animation; animationManager.ProductInsertUpdate(entity); } catch (SqlException exc) { SqlException sqlExc = exc as SqlException; if (sqlExc.Number == 50000 && sqlExc.Class == 16) { if (sqlExc.Errors.Count > 0) { MessageBox.Show(sqlExc.Errors[0].Message); } else { MessageBox.Show(sqlExc.Message); } } else { MessageBox.Show(exc.Message); Logger.Log(exc.ToString(), LogLevel.Error); throw; } } catch (Exception exc) { //MessageBox.Show("An error occured when inserting the product:" + Utility.GetExceptionsMessages(exc)); Logger.Log(exc.ToString(), LogLevel.Error); MessageBox.Show(SystemMessagesManager.Instance.GetMessage("ProductAnimationUpdateException", Utility.GetExceptionsMessages(exc))); (grdProduct.View as TableView).DeleteRow(grdProduct.View.FocusedRowHandle); } }