Пример #1
0
        internal static String Save(DB.ITM_BOM_Document entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityInventoryContext.ITM_BOM_Document.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Пример #2
0
        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;
                }
            }
        }
Пример #3
0
 public static DB.ITM_BOM_Document GetPreviousItem(DB.ITM_BOM_Document ITM_BOM_Document, DataContext dataContext)
 {
     return(dataContext.EntityInventoryContext.ITM_BOM_Document.OrderByDescending(o => o.Id).Where(n => n.Id == ITM_BOM_Document.Id && n.Id < ITM_BOM_Document.Id).FirstOrDefault());
 }
Пример #4
0
 public static DB.ITM_BOM_Document GetNextItem(DB.ITM_BOM_Document ITM_BOM_Document, DataContext dataContext)
 {
     return(dataContext.EntityInventoryContext.ITM_BOM_Document.OrderBy(o => o.Id).Where(n => n.Id == ITM_BOM_Document.Id && n.Id > ITM_BOM_Document.Id).FirstOrDefault());
 }
Пример #5
0
        private void btnComplete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                ValidateLayout();

                if (((DB.ITM_BOM_Document)BindingSource.DataSource).QuantityActualResult == null)
                {
                    Essential.BaseAlert.ShowAlert("Quantity Actual Result Required", "Enter Quantity Actual Result before continuing ?", Essential.BaseAlert.Buttons.Ok, Essential.BaseAlert.Icons.Error);
                    return;
                }

                DialogResult result = Essential.BaseAlert.ShowAlert("Cancel Document", "You are about the cancel this document do you wish to continue ?", Essential.BaseAlert.Buttons.OkCancel, Essential.BaseAlert.Icons.Information);

                Int64 printerId = 0;
                switch (result)
                {
                case System.Windows.Forms.DialogResult.Yes:
                    printerId = BL.ApplicationDataContext.Instance.LoggedInUser.DefaultPrinterId.Value;
                    break;

                case System.Windows.Forms.DialogResult.No:
                    printerId = 0;
                    break;

                case System.Windows.Forms.DialogResult.Cancel:
                    printerId = -1;
                    break;
                }

                DB.SYS_DOC_Header   sys_doc_header   = BL.SYS.SYS_DOC_Document.New(BL.SYS.SYS_DOC_Type.BOMComplete);
                DB.ITM_BOM_Document itm_bom_document = DataContext.EntityInventoryContext.ITM_BOM_Document.FirstOrDefault(n => n.HeaderId == sys_doc_header.Id);//sys_doc_header.ITM_BOM_Document.FirstOrDefault();
                foreach (DB.SYS_DOC_Line line in ((DB.SYS_DOC_Header)BindingSourceDocument.DataSource).SYS_DOC_Line)
                {
                    if (line.ItemId == ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).ItemResultId)
                    {
                        line.IsBOMCompleteResultItem = true;
                    }

                    var newLine = BL.ApplicationDataContext.DeepClone(line, BL.SYS.SYS_DOC_Line.New);
                    if (newLine.LineItem == null)
                    {
                        newLine.LineItem = DataContext.ReadonlyContext.VW_LineItem.FirstOrDefault(n => n.Id == line.ItemId);
                    }

                    sys_doc_header.SYS_DOC_Line.Add(newLine);
                }
                sys_doc_header.BOMDocumentId = ((DB.ITM_BOM_Document)BindingSource.DataSource).Id;
                //Werner: This was moved to the DataService
                //itm_bom_document.RecipeId = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).Id;
                //itm_bom_document.ItemResultId = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).ItemResultId;
                //itm_bom_document.QuantityExpectedResult = ((DB.ITM_BOM_Recipe)BindingSourceRecipe.DataSource).QuantityResult;
                //itm_bom_document.QuantityActualResult = 0;
                //itm_bom_document.CancelParent = ((DB.ITM_BOM_Document)BindingSource.DataSource).Id;

                BL.ApplicationDataContext.Instance.Service.SaveDocument(sys_doc_header, printerId);

                //If you ever remove this make sure that you refresh all the datasources as the BindingSource.DataSource is save disjoint from the DataContext
                ForceClose = true;
                this.Close();
            }
            catch (Exception ex)
            {
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
            }
        }