Ejemplo n.º 1
0
        private void saveProductToList()
        {
            if (productTextBox.Text != String.Empty && countTextBox.Text != String.Empty)
            {
                if (isProductKnown(productTextBox.Text))
                {
                    if (this.replace)
                    {
                        this.productList.Find(findScannedProduct).setCount(countTextBox.Text);
                        this.replace = false;
                    }
                    else
                    {
                        ScannedProduct sp = new ScannedProduct(productTextBox.Text);
                        sp.setCount(countTextBox.Text);

                        this.productList.Add(sp);
                    }

                    countTextBox.Enabled = false;

                    countTextBox.Text = productTextBox.Text = String.Empty;

                    productTextBox.Focus();
                }
            }
        }
Ejemplo n.º 2
0
        public MainMenuForm(List <string> knownProducts)
        {
            InitializeComponent();

            // Bind the KeyDown event handler
            this.KeyDown += new KeyEventHandler(MainMenuForm_KeyDown);
            this.laser1.ScannerEnabled = false;
            this.nameMenuItem.Text     = getHostName();
            this.knownProductList      = knownProducts;

            try
            {
                this.serverIP = Registry.GetValue("HKEY_CURRENT_USER\\BalieScanner", "ServerIP", "(unset)").ToString();
            }
            catch (NullReferenceException)
            {
                Registry.SetValue("HKEY_CURRENT_USER\\BalieScanner", "ServerIP", "(unset)");
                this.serverIP = "(unset)";
            }

            this.ipLabel.Text = "Server IP: " + this.serverIP.ToString();

            // Check if the file exists before trying to repopulate
            if (File.Exists("\\Backup\\balie_scanner\\scannerdata.txt"))
            {
                // Repopulate the product list from the backup file
                string       line;
                string       directory = "\\Backup\\balie_scanner";
                StreamReader file      = new StreamReader(directory + "\\scannerdata.txt");
                while ((line = file.ReadLine()) != null)
                {
                    string product = line.Split((char)44)[0];
                    string count   = line.Split((char)44)[1];

                    ScannedProduct prod = new ScannedProduct(product);
                    prod.setCount(count);

                    this.productList.Add(prod);
                }

                file.Close();
            }
        }
Ejemplo n.º 3
0
 private bool findScannedProduct(ScannedProduct obj)
 {
     return(obj.getProduct() == this.scannerInput);
 }