Ejemplo n.º 1
0
        private void btnDone_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure you want to commit changes ?", "Confirm", MessageBoxButtons.YesNo);

            if (dr.Equals(DialogResult.No))
            {
                return;
            }


            foreach (ProductStock product in _scanProducts)
            {
                product.ApplyChanges();

                Bsi_LocationLog logEntry = new Bsi_LocationLog();
                logEntry.Item         = product.Item;
                logEntry.User         = _user;
                logEntry.BeforeChange = product.PreviousBin;
                logEntry.Location     = "+ " + _scanBin;
                logEntry.UpdateDate   = DateTime.Now;
                logEntry.Quantity     = product.QtyScan;
            }

            _dataContext.SaveChanges();

            this.Close();
        }
Ejemplo n.º 2
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            var locations = lbDeleteList.Items.Cast <string>();

            if (locations.Count() == 0)
            {
                MessageBox.Show("delete list is empty");
                return;
            }

            DialogResult dr = MessageBox.Show("Are you sure you want to clean all locations in delete list ?", "Confirm", MessageBoxButtons.OKCancel);

            if (dr.Equals(DialogResult.Cancel))
            {
                return;
            }

            int deleteCount = 0;

            using (berkeleyEntities dataContext = new berkeleyEntities())
            {
                foreach (string location in locations)
                {
                    var items = dataContext.Items.Where(p => p.BinLocation.Contains(location));

                    foreach (Item item in items)
                    {
                        List <string> currentBins = item.BinLocation.Split(new Char[1] {
                            ' '
                        }).ToList();

                        currentBins.ForEach(p => p = p.ToUpper().Trim());

                        if (currentBins.Any(p => p.Equals(location)))
                        {
                            Bsi_LocationLog logEntry = new Bsi_LocationLog();
                            logEntry.Item         = item;
                            logEntry.Location     = "- " + location;
                            logEntry.Quantity     = 0;
                            logEntry.User         = _user;
                            logEntry.UpdateDate   = DateTime.Now;
                            logEntry.BeforeChange = item.BinLocation;

                            deleteCount     += currentBins.RemoveAll(p => p.Equals(location));
                            item.BinLocation = String.Join(" ", currentBins).Trim();
                        }
                    }
                }
                dataContext.SaveChanges();
            }

            MessageBox.Show(deleteCount.ToString() + " locations deleted");


            this.Close();
        }
Ejemplo n.º 3
0
        public void Update()
        {
            List <InventoryEntry> entryGroups = _dataContext.InventoryEntries.Where(p => p.PhysicalInventory.ID == _inventoryRef.ID).ToList();

            var groups = entryGroups.GroupBy(p => p.Item.ID);

            //var entryGroups = _dataContext.InventoryEntries.Where(p => p.PhysicalInventory.ID == _inventoryRef.ID && p.Bin.Equals("WALL")).GroupBy(p => p.Item.ID);

            foreach (var entryGroup in groups)
            {
                Item item = _dataContext.Items.Single(p => p.ID == entryGroup.Key);

                var expectedBins = item.BinLocation.Split(new Char[1] {
                    ' '
                }).Distinct().Where(p => !string.IsNullOrWhiteSpace(p));

                var actualBins = entryGroup.Select(p => p.Bin);

                List <string> currentBin = new List <string>(expectedBins);

                currentBin.ForEach(p => p = p.Trim().ToUpper());

                foreach (string bin in expectedBins.Except(actualBins))
                {
                    Bsi_LocationLog log = new Bsi_LocationLog();
                    log.Item         = item;
                    log.Location     = "- " + bin;
                    log.Quantity     = 0;
                    log.UpdateDate   = DateTime.Now;
                    log.User         = _inventoryRef.Code;
                    log.BeforeChange = string.Join(" ", currentBin);
                    currentBin.Remove(bin);
                }

                foreach (InventoryEntry entry in entryGroup)
                {
                    Bsi_LocationLog log = new Bsi_LocationLog();
                    log.Item         = item;
                    log.Location     = "+ " + entry.Bin;
                    log.Quantity     = entry.Counted;
                    log.UpdateDate   = DateTime.Now;
                    log.User         = entry.User + " (" + _inventoryRef.Code + ")";
                    log.BeforeChange = string.Join(" ", currentBin);

                    if (!currentBin.Any(p => p.Equals(entry.Bin)))
                    {
                        currentBin.Add(entry.Bin);
                    }
                }

                var newBin = string.Join(" ", currentBin);

                if (newBin.Count() > 20)
                {
                    item.BinLocation = newBin.Substring(0, 20);
                }
                else
                {
                    item.BinLocation = newBin;
                }


                //int charCount = currentBin.Sum(s => s.Count()) + (currentBin.Count() - 1);

                //List<string> notesField = new List<string>();

                //while (charCount > 20)
                //{
                //    string bin = currentBin.First();
                //    currentBin.Remove(bin);
                //    notesField.Add(bin);
                //    charCount = currentBin.Sum(s => s.Count()) + (currentBin.Count() - 1);
                //}

                //if (notesField.Count > 0)
                //{
                //    item.Notes = item.Notes.Trim() + string.Join(" ", notesField);
                //}
            }

            _dataContext.SaveChanges();
        }