Example #1
0
        /// <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);
        }
Example #2
0
        public void NewDocument(Int64 recipeId, BL.SYS.SYS_DOC_Type itm_bom_type)
        {
            try
            {
                //Werner: Need to run this to get the NewRecord behaviour of the form
                OnNewRecord();
                btnComplete.Visibility          = DevExpress.XtraBars.BarItemVisibility.Never;
                btnCancel.Visibility            = DevExpress.XtraBars.BarItemVisibility.Never;
                txtQuantityActualResult.Enabled = false;
                //Recipe
                BindingSourceRecipe.DataSource = BL.ITM.ITM_BOM_Recipe.Load(recipeId, DataContext, new List <string>()
                {
                    "ITM_BOM_RecipeLine"
                });                                                                                                                              //DataContext.EntityInventoryContext.ITM_BOM_Recipe.FirstOrDefault(n => n.Id == recipeId);
                //SYS DOC Header
                BindingSourceDocument.DataSource = BL.SYS.SYS_DOC_Document.New(itm_bom_type);
                //BOM Document
                BindingSource.DataSource = BL.ITM.ITM_BOM_Document.New;//((DB.SYS_DOC_Header)BindingSourceDocument.DataSource).ITM_BOM_Document.FirstOrDefault();
                //Link item to BOM Document
                ((DB.ITM_BOM_Document)BindingSource.DataSource).RecipeId               = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).Id;
                ((DB.ITM_BOM_Document)BindingSource.DataSource).ItemResultId           = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).ItemResultId;
                ((DB.ITM_BOM_Document)BindingSource.DataSource).QuantityExpectedResult = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).QuantityResult * (itm_bom_type == BL.SYS.SYS_DOC_Type.BOMAssemblyStarted ? 1 : -1);

                //Link Lines
                ((DB.SYS_DOC_Header)BindingSourceDocument.DataSource).SYS_DOC_Line = sys_doc_line;
                BindingSourceDocumentLine.DataSource = sys_doc_line;

                //Populate the SYS_DOC_Header's lines
                foreach (var recipeLine in ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).ITM_BOM_RecipeLine)
                {
                    DB.SYS_DOC_Line line = BL.SYS.SYS_DOC_Line.New;
                    line.ItemId      = recipeLine.ItemId;
                    line.Description = BL.SYS.SYS_Entity.Load(recipeLine.ItemId, DataContext).Description;
                    line.Quantity    = recipeLine.Quantity * (itm_bom_type == BL.SYS.SYS_DOC_Type.BOMAssemblyStarted ? 1 : -1);
                    line.Amount      = recipeLine.Amount;
                    line.Total       = line.Quantity * line.Amount;
                    line.TotalTax    = 0;

                    //SYS DOC Lines
                    sys_doc_line.Add(line);
                }
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }
Example #3
0
 public BaseDocumentList(BL.SYS.SYS_DOC_Type documentType)
 {
     InitializeComponent();
     DocumentType = documentType;
 }