Example #1
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                BuscarProduto.Select();
                BuscarProduto.Focus();

                AutoCompleteItens();
                Start();
                DataTableStart();
                LoadItens();
            };

            addProduto.Click += (s, e) =>
            {
                for (var i = 0; i < Validation.ConvertToInt32(Quantidade.Text); i++)
                {
                    AddItem();
                }

                // Limpa os campos
                ClearForms();
                DataTable();
                LoadItens();
            };

            imprimir.Click += (s, e) => Render();

            modelos.SelectedValueChanged += (s, e) => { label9.Text = modelos.SelectedValue.ToString(); };

            btnClean.Click += (s, e) =>
            {
                new Model.Etiqueta().Clean();
                DataTable();
                LoadItens();
            };

            BuscarProduto.TextChanged += (s, e) =>
            {
                labelEstoque.Visible = false;
                if (collection.Lookup(BuscarProduto.Text) <= 0)
                {
                    return;
                }

                labelEstoque.Visible = true;
                var itemId = collection.Lookup(BuscarProduto.Text);
                var item   = _mItem.FindById(itemId).Where("excluir", 0).Where("tipo", "Produtos").First <Item>();
                labelEstoque.Text = $"Estoque atual: {item.EstoqueAtual}";
            };

            label5.Click  += (s, e) => Close();
            btnExit.Click += (s, e) => Close();

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) => { dataTable = await _controller.GetDataTable(); };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    LoadItens();
                    await _controller.SetTable(GridLista, dataTable);

                    Loading.Visible   = false;
                    GridLista.Visible = true;
                };
            }

            timer.AutoReset = false;

            btnVideoAjuda.Click += (s, e) => Support.Video("https://www.youtube.com/watch?v=_ybEHAVTXUA");
        }