Exemple #1
0
        public static String Save(DB.ITM_StockTakeItem entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityInventoryContext.ITM_StockTakeItem.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.EntityInventoryContext.PackageValidationException());
            }

            return("Success");
        }
Exemple #2
0
        private void wizStockTake_SelectedPageChanged(object sender, DevExpress.XtraWizard.WizardPageChangedEventArgs e)
        {
            if (AllowSave)
            {
                SaveSuccessful();
                OpenRecord(((DB.ITM_StockTake)BindingSource.DataSource).Id);
            }
            DB.ITM_StockTake stockTake = (DB.ITM_StockTake)BindingSource.DataSource;

            if (wizStockTake.SelectedPage == wizStockTakeWelcome)
            {
                AllowExport = false;
            }
            else if (wizStockTake.SelectedPage == wizStockTakeStart)
            {
                stockTake.StatusId = (byte)BL.ITM.ITM_StockTakeStatus.New;
                AllowExport        = true;
            }
            else if (wizStockTake.SelectedPage == wizStockTakeQuantities)
            {
                if (!itmStockTake.Description.Contains("Filter : "))
                {
                    itmStockTake.Description += " Filter : " + grvStockTakeItems.ActiveFilterString;
                }

                if (itmStockTake.ITM_StockTakeItem.Count == 0)
                {
                    //using (new CDS.Client.Desktop.Essential.UTL.WaitCursor())
                    {
                        List <DB.ITM_StockTakeItem> stockTakeItems = new List <DB.ITM_StockTakeItem>();
                        int dataRowCount = grvStockTakeItems.DataRowCount;

                        for (int i = 0; i < dataRowCount; i++)
                        {
                            while (grvStockTakeItems.GetRow(i) is DevExpress.Data.NotLoadedObject)
                            {
                                Application.DoEvents();
                            }

                            DB.VW_Inventory VW_Inventory = (DB.VW_Inventory)((DevExpress.Data.Async.Helpers.ReadonlyThreadSafeProxyForObjectFromAnotherThread)(grvStockTakeItems.GetRow(i))).OriginalRow;// grvStockTakeItems.GetRow(i);

                            if (VW_Inventory != null)
                            {
                                DB.ITM_StockTakeItem item = BL.ITM.ITM_StockTakeItem.New;
                                item.InventoryId = VW_Inventory.EntityId;
                                item.LineNumber  = i;
                                item.OnHand      = VW_Inventory.OnHand;
                                item.UnitAverage = VW_Inventory.UnitAverage;
                                item.UnitPrice   = VW_Inventory.UnitPrice;
                                item.UnitCost    = VW_Inventory.UnitCost;
                                stockTakeItems.Add(item);
                            }
                            else
                            {
                            }
                        }
                        foreach (DB.ITM_StockTakeItem item in stockTakeItems.OrderBy(o => o.LineNumber))
                        {
                            itmStockTake.ITM_StockTakeItem.Add(item);
                        }

                        SaveSuccessful();
                        OpenRecord(((DB.ITM_StockTake)BindingSource.DataSource).Id);
                    }
                }
                BindingSourceStockTakeItem.DataSource = itmStockTake.ITM_StockTakeItem;
                grvStockTakeQuantity.RefreshData();
                wizStockTakeQuantities.AllowBack = false;
                stockTake.StatusId            = (byte)BL.ITM.ITM_StockTakeStatus.StocktakeCount;
                btnPrintCountSheet.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                AllowExport = true;
            }
            else if (wizStockTake.SelectedPage == wizStockTakeVariance)
            {
                ServerModeSourceVariance.QueryableSource = DataContext.ReadonlyContext.VW_StockTakeVariance.Where(n => n.StockTakeId == itmStockTake.Id);
                stockTake.StatusId = (byte)BL.ITM.ITM_StockTakeStatus.StocktakeCountVariance;

                wizStockTake.SelectedPage.AllowNext = SECL.SecurityLibrary.AccessGranted(SECL.AccessCodes.INSKRE02);

                if (!wizStockTake.SelectedPage.AllowNext)
                {
                    wizStockTakeVariance.DescriptionText = "Below shows you a detail stock variance" + Environment.NewLine +
                                                           "You do not have access to complete the stock take. \nPlease log in with a user that has access to finalize stock takes (INST07)." + Environment.NewLine +
                                                           "Close tab to save stock take at its current status";
                }
                btnPrintCountSheet.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
                AllowExport = true;
            }
            else if (wizStockTake.SelectedPage == wizStockTakeSummary)
            {
                AllowExport = false;
            }
            else if (wizStockTake.SelectedPage == wizStockTakeCompleted)
            {
                AllowExport = false;
            }
            if (AllowSave)
            {
                SaveSuccessful();
                OpenRecord(((DB.ITM_StockTake)BindingSource.DataSource).Id);
            }

            if (ReadOnly)
            {
                e.Page.AllowCancel            = false;
                e.Page.AllowNext              = false;
                e.Page.AllowBack              = false;
                btnPrintCountSheet.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            }
        }