示例#1
0
        private void Eventos()
        {
            Shown += async(s, e) =>
            {
                Refresh();

                loading.Visible = true;
                workerBackground.RunWorkerAsync();

                ToolHelp.Show(
                    $"Referente ao período ({DateTime.Now.AddDays(-Days):dd/MM/yyyy}) até Hoje ({DateTime.Now:dd/MM/yyyy})",
                    pictureBox4, ToolHelp.ToolTipIcon.Info, "Ajuda!");

                dataSemana.Text = $@"{DateTime.Now.AddDays(-Days):dd/MM/yyyy} até Hoje ({DateTime.Now:dd/MM/yyyy})";
                LoadGrafico();

                SetHeadersTable(GridLista);

                await Task.Delay(500);

                new Caixa().CheckCaixaDate();
            };

            timer1.Tick += (s, e) =>
            {
                panel1.Visible  = false;
                loading.Visible = true;

                workerBackground.RunWorkerAsync();
                timer1.Enabled = true;
                timer1.Stop();
            };

            btnTodosAreceber.Click += (s, e) =>
            {
                if (UserPermission.SetControlLabel(btnTodosAreceber, pictureBox3, "fin_recebimentos"))
                {
                    return;
                }

                Home.financeiroPage = "Receber";
                OpenForm.Show <Titulos>(this);
            };

            btnTodosApagar.Click += (s, e) =>
            {
                if (UserPermission.SetControlLabel(btnTodosApagar, pictureBox3, "fin_pagamentos"))
                {
                    return;
                }

                Home.financeiroPage = "Pagar";
                OpenForm.Show <Titulos>(this);
            };

            btnNovoRecebimento.Click += (s, e) =>
            {
                Home.financeiroPage   = "Receber";
                EditarTitulo.IdTitulo = 0;
                OpenForm.Show <EditarTitulo>(this);
            };

            btnNovoPagamento.Click += (s, e) =>
            {
                Home.financeiroPage   = "Pagar";
                EditarTitulo.IdTitulo = 0;
                OpenForm.Show <EditarTitulo>(this);
            };

            workerBackground.DoWork += (s, e) =>
            {
                GetDados();

                aReceber = GetValues("Receber");
                aPagar   = GetValues("Pagar");
                vendas   = GetVendas();

                dataProductsEstoque = new Item().FindAll()
                                      .WhereRaw("estoqueminimo >= estoqueatual")
                                      .Where("estoqueminimo", "!=", "0")
                                      .WhereFalse("excluir")
                                      .Get();
            };

            workerBackground.RunWorkerCompleted += async(s, e) =>
            {
                panel1.Visible  = true;
                loading.Visible = false;
                //timer1.Start();
                LoadData();
                LoadSeriesGrafico();

                await SetContentTableAsync(GridLista, dataProductsEstoque);
            };

            btnRefresh.Click += (s, e) =>
            {
                panel1.Visible  = false;
                loading.Visible = true;

                workerBackground.RunWorkerAsync();
            };
        }