Exemple #1
0
 public override void OpenRecord(long Id)
 {
     base.OpenRecord(Id);
     itmStockTake = BL.ITM.ITM_StockTake.Load(Id, DataContext, new List <string>()
     {
         "ITM_StockTakeItem"
     });                                                                                                   //DataContext.EntityInventoryContext.ITM_StockTake.Where(n => n.Id == Id).FirstOrDefault();
 }
Exemple #2
0
        public static String Save(DB.ITM_StockTake entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityInventoryContext.ITM_StockTake.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.EntityInventoryContext.PackageValidationException());
            }

            return("Success");
        }
Exemple #3
0
 protected override void OnNewRecord()
 {
     base.OnNewRecord();
     itmStockTake        = BL.ITM.ITM_StockTake.New;
     itmStockTake.SiteId = defaultSiteId;
 }
Exemple #4
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;
            }
        }
Exemple #5
0
 public static DB.ITM_StockTake GetPreviousItem(DB.ITM_StockTake ITM_StockTake, DataContext dataContext)
 {
     return(dataContext.EntityInventoryContext.ITM_StockTake.OrderByDescending(o => o.StartDate).Where(n => n.StartDate < ITM_StockTake.StartDate).FirstOrDefault());
 }
Exemple #6
0
 public static DB.ITM_StockTake GetNextItem(DB.ITM_StockTake ITM_StockTake, DataContext dataContext)
 {
     return(dataContext.EntityInventoryContext.ITM_StockTake.OrderBy(o => o.StartDate).Where(n => n.StartDate > ITM_StockTake.StartDate).FirstOrDefault());
 }