Пример #1
0
        public void LoadStockRequests()
        {
            //users = Models.User.GetAll();
            stockRequests = StockRequest.GetAll();

            this.flpStockRequests.Controls.Clear();

            stockRequests.ForEach(stockrequest =>
            {
                if (stockrequest.Completed == 0)
                {
                    var btn       = new Button();
                    btn.BackColor = SystemColors.ControlLightLight;
                    btn.Width     = this.flpStockRequests.Width - 30;
                    btn.Height    = 60;

                    btn.Text      = $"Stock Request ({stockrequest.Id}) : Product: {stockrequest.Product.Name} -> {stockrequest.Quantity} pieces";
                    btn.Font      = new Font("Segoe UI Black", 12);
                    btn.TextAlign = ContentAlignment.MiddleLeft;

                    btn.MouseEnter += new EventHandler((s, ev) =>
                    {
                        btn.BackColor = SystemColors.ControlLight;
                        btn.Cursor    = Cursors.Hand;
                    });

                    btn.MouseLeave += new EventHandler((s, ev) =>
                    {
                        btn.BackColor = SystemColors.ControlLightLight;
                    });

                    //Open a ViewStockRequestForm for this stockrequest when clicking on it
                    btn.Click += new EventHandler((s, ev) =>
                    {
                        ViewStockRequestForm form = new ViewStockRequestForm(stockrequest);
                        form.Show();

                        this.Close();
                    });


                    this.flpStockRequests.Controls.Add(btn);
                }
            });

            if (StockRequest.GetAllPendingRequests().Count == 0)
            {
                var btn = new Button();
                btn.BackColor = SystemColors.ControlLightLight;
                btn.Width     = this.flpStockRequests.Width - 30;
                btn.Height    = 60;
                btn.Text      = $"No stock requests";
                btn.Font      = new Font("Segoe UI Black", 12);
                btn.TextAlign = ContentAlignment.MiddleCenter;
                this.flpStockRequests.Controls.Add(btn);
            }
        }