Example #1
0
        // Close the form and process the wallets.
        public void doClose()
        {
            ModuleScanning.setScannedOut(scannedOut);

            // Actually process the scanned items!
            for (int i = 0; i <= (lstScanned.Items.Count - 1); i++)
            {
                ListViewItem item = lstScanned.Items[i];
                // If the item exists, just update the quantity.
                Listener theListener = serviceLayer.GetListenerById(int.Parse(item.SubItems[0].Text));
                if ((theListener != null))
                {
                    theListener.inOutRecords.Out8 = int.Parse(item.SubItems[1].Text);
                    // Also adjust stock.
                    theListener.Stock   = theListener.Stock - int.Parse(item.SubItems[1].Text);
                    theListener.LastOut = DateTime.Now;

                    if (!serviceLayer.UpdateListener(theListener))
                    {
                        Interaction.MsgBox("Error: Failed to update scan information on listener.");
                        this.Close();
                    }

                    serviceLayer.RecordScan(theListener.Wallet, ScanTypes.OUT);
                }
            }

            // Show message and close.
            exitMe = true;
            this.Close();
        }
Example #2
0
        // Close the form and process the wallets.
        public void doClose()
        {
            ModuleScanning.setScannedIn(scannedIn);

            // Actually process the scanned items!
            for (int i = 0; i <= (lstScanned.Items.Count - 1); i++)
            {
                ListViewItem item = lstScanned.Items[i];

                // If the item exists, just update the quantity.
                Listener theListener = serviceLayer.GetListenerById(int.Parse(item.SubItems[0].Text));
                if ((theListener != null))
                {
                    theListener.inOutRecords.In8 = int.Parse(item.SubItems[1].Text);

                    // Also adjust stock.
                    theListener.Stock = theListener.Stock + int.Parse(item.SubItems[1].Text);

                    // Are there more than 3 stock items?
                    if (theListener.Stock > Listener.DEFAULT_STOCK)
                    {
                        int overStock = theListener.Stock;
                        theListener.Stock = 3;
                        MessageBox.Show("Listener with Wallet: " + theListener.Wallet + ", Name: " + theListener.GetNiceName() + " would have " + overStock + " stock after scanning in these wallets. " + Environment.NewLine + Environment.NewLine +
                                        "Please look for any old wallets and remove the labels before clicking OK to continue.");
                        log.Warn("Listner " + theListener.GetNiceName() + " would have " + overStock + " stock after the scanning in. Limiting to " + Listener.DEFAULT_STOCK + " and displaying warning.");
                    }

                    // If the listener is active, we will be also sending it out
                    if (theListener.Status.Equals(ListenerStates.ACTIVE))
                    {
                        theListener.Stock = theListener.Stock - 1;

                        // Increment scanned out count
                        ModuleScanning.setScannedOut(ModuleScanning.getScannedOut() + 1);

                        // Also update the last out time (as we will be updating this listener in a minute with out8 = 1).
                        theListener.LastOut = DateTime.Now;
                    }

                    theListener.LastIn = DateTime.Now;

                    if (!serviceLayer.UpdateListener(theListener))
                    {
                        Interaction.MsgBox("Error: Failed to update scan information on listener.");
                        log.Error("Error: Failed to update scan information on listener.");
                        this.Close();
                    }
                    else
                    {
                        log.Debug("Updated listener information.");
                    }

                    serviceLayer.RecordScan(theListener.Wallet, ScanTypes.IN);
                }
            }

            // Show message and close.
            MessageBox.Show("The " + scannedIn + " wallets you have scanned have been successfully processed." + Environment.NewLine + Environment.NewLine + "You can now load them with memory sticks and place them in GPO mailbags.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK);
            exitMe = true;

            // Update the new week stats
            ModuleGeneric.UpdateStatsWeek(serviceLayer, true);

            this.Close();
        }