Ejemplo n.º 1
0
 private void TextBoxScan_TextChanged(object sender, EventArgs e)
 {
     ViewExistingProduct.Hide();
     ShowAddForm.Hide();
     //Goes into the if when the text is only numbers
     if (TextBoxScan.Text.All(char.IsDigit) && TextBoxScan.Text != "")
     {
         LogoPanel.Hide();
         //if the barcode already exists in the database, it gets the expiration time that has been added to the product
         if (Products.Exists(p => p.ID == TextBoxScan.Text))
         {
             FillExistingProductView();
             //Product will be added to the food table
             AddToProductsInHouse();
         }
         else
         {
             //If it doesnt exist, addform will be shown with the barcode already added.
             ShowAddForm.Show();
             ShowAddForm.Controls[1].Text = TextBoxScan.Text;
         }
     }
     else
     {
         //Fifo logo will be shown when textbox is empty.
         LogoPanel.Show();
     }
 }
Ejemplo n.º 2
0
        public ScanView(Rectangle size)
        {
            InitializeComponent();
            _Font = new Font("Arial", 21, FontStyle.Regular);
            //The textbox for the barcode
            TextBoxScan.Size        = new Size(size.Width / 4, TextBoxScan.Size.Height);
            TextBoxScan.Location    = new Point(size.Width / 4 - TextBoxScan.Width / 2, 110);
            TextBoxScan.Font        = _Font;
            CheckDirectAdd.Location = new Point(TextBoxScan.Location.X, TextBoxScan.Location.Y + TextBoxScan.Size.Height + 10);
            //The tables from the MySQL database
            Products        = DataManager.Instance.Products;
            Categories      = DataManager.Instance.Categories;
            ProductsInHouse = DataManager.Instance.ProductsInHouse;
            //Add form when product doesn't exist
            ShowAddForm.BackColor = Color.AliceBlue;
            ShowAddForm.Location  = new Point(size.Width / 2, 0);
            ShowAddForm.Size      = new Size(size.Width / 2, size.Height);
            ShowAddForm.Hide();
            AddControlsToAddForm(ShowAddForm);
            //Add form when product does exist
            ViewExistingProduct.BackColor = Color.LightSkyBlue;
            ViewExistingProduct.Location  = new Point(size.Width / 2, 0);
            ViewExistingProduct.Size      = new Size(size.Width / 2, size.Height);
            ViewExistingProduct.Hide();
            AddControlsToViewForm(ViewExistingProduct);
            //The logo on the right
            LogoPanel.BackgroundImage       = Image.FromFile("..\\..\\Content\\logo.png");
            LogoPanel.Size                  = new Size(size.Width / 2, size.Height);
            LogoPanel.Location              = new Point(size.Width / 2, 0);
            LogoPanel.BackgroundImageLayout = ImageLayout.Stretch;
            //Manual add button
            Button AddButton = new Button();

            AddButton.Font      = _Font;
            AddButton.Text      = "Toevoegen";
            AddButton.Location  = new Point(ViewExistingProduct.Controls[10].Location.X, ViewExistingProduct.Controls[10].Location.Y + 70);
            AddButton.Size      = ViewExistingProduct.Controls[10].Size;
            AddButton.FlatStyle = FlatStyle.Flat;
            AddButton.FlatAppearance.BorderSize = 0;
            AddButton.TabStop = false;
            AddButton.Click  += AddButtonManuallyClick;
            ViewExistingProduct.Controls.Add(AddButton);
        }