/// <summary> /// Checks if stock is availble for work to start /// </summary> /// <param name="sys_doc_type"></param> /// <returns></returns> private bool HasItems(BL.SYS.SYS_DOC_Type sys_doc_type) { bool hasItems = true; //Recipe Items foreach (DB.ITM_BOM_RecipeLine line in ((DB.ITM_BOM_Recipe)BindingSource.DataSource).ITM_BOM_RecipeLine) { if (line.Quantity * (sys_doc_type == BL.SYS.SYS_DOC_Type.BOMAssemblyStarted ? 1 : -1) < 0) { DB.ITM_History itm_history = BL.ITM.ITM_History.GetItemCurrentHistory(DataContext.EntityInventoryContext.ITM_Inventory.FirstOrDefault(n => n.EntityId == line.ItemId), DataContext); if (itm_history.OnHand < -line.Quantity) { hasItems = false; break; } } } //Source Item DB.ITM_BOM_Recipe recipe = (DB.ITM_BOM_Recipe)BindingSource.DataSource; DB.ITM_History itm_historyItemResult = BL.ITM.ITM_History.GetItemCurrentHistory(DataContext.EntityInventoryContext.ITM_Inventory.FirstOrDefault(n => n.EntityId == recipe.ItemResultId), DataContext); if (recipe.QuantityResult * (sys_doc_type == BL.SYS.SYS_DOC_Type.BOMAssemblyStarted ? 1 : -1) < 0) { if (itm_historyItemResult.OnHand < -recipe.QuantityResult * (sys_doc_type == BL.SYS.SYS_DOC_Type.BOMAssemblyStarted ? 1 : -1)) { hasItems = false; } } if (!hasItems) { Essential.BaseAlert.ShowAlert("Insufficient On Hand", "Insufficient On Hand to start work", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Error); } return(hasItems); }
internal static String Save(DB.ITM_BOM_Recipe entry, DataContext dataContext) { try { if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached) { dataContext.EntityInventoryContext.ITM_BOM_Recipe.Add(entry); } } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { return(dataContext.PackageValidationException()); } return("Success"); }
public override void OpenRecord(long Id) { try { base.OpenRecord(Id); BindingSource.DataSource = BL.ITM.ITM_BOM_Document.Load(Id, DataContext, new List <String>() { "ITM_BOM_Recipe" }); //DataContext.EntityInventoryContext.ITM_BOM_Document.FirstOrDefault(n => n.Id == Id); DB.ITM_BOM_Document itm_bom_document = ((DB.ITM_BOM_Document)BindingSource.DataSource); BindingSourceDocument.DataSource = BL.SYS.SYS_DOC_Header.Load(itm_bom_document.HeaderId, DataContext, new List <String>() { "SYS_DOC_Line" }); //DataContext.EntityInventoryContext.ITM_BOM_Document.FirstOrDefault(n => n.HeaderId == itm_bom_document.Id); //((DB.ITM_BOM_Document)BindingSource.DataSource).SYS_DOC_Header; BindingSourceRecipe.DataSource = ((DB.ITM_BOM_Document)BindingSource.DataSource).ITM_BOM_Recipe; DB.ITM_BOM_Recipe recipe = ((DB.ITM_BOM_Document)BindingSource.DataSource).ITM_BOM_Recipe; //DB.SYS_DOC_Header sys_doc_header = BL.SYS.SYS_DOC_Header.Load(itm_bom_document.HeaderId, DataContext, new List<String>() { "SYS_DOC_Line" }); BindingSourceDocumentLine.DataSource = ((DB.SYS_DOC_Header)BindingSourceDocument.DataSource).SYS_DOC_Line;//sys_doc_header.SYS_DOC_Line.Where(n => n.ItemId != recipe.ItemResultId); //BOM hase been Completed or Canceled if (((DB.ITM_BOM_Document)BindingSource.DataSource).QuantityActualResult != null) { btnCancel.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; btnComplete.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; ReadOnly = true; } else { AllowSave = false; } } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
public static DB.ITM_BOM_Recipe GetPreviousItem(DB.ITM_BOM_Recipe itm_bom_recipe, DataContext dataContext) { return(dataContext.EntityInventoryContext.ITM_BOM_Recipe.OrderByDescending(o => o.Id).Where(n => n.Id == itm_bom_recipe.Id && n.Id < itm_bom_recipe.Id).FirstOrDefault()); }