示例#1
0
        private void DataTableStart()
        {
            BuscarPessoa.Select();

            GridLista.Visible = false;
            Loading.Size      = new Size(GridLista.Width, GridLista.Height);
            Loading.Visible   = true;
            workerBackground.RunWorkerAsync();
        }
示例#2
0
        private void Eventos()
        {
            controle   = "";
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) =>
            {
                int diff;

                if (Home.pedidoPage != "Ordens de Servico")
                {
                    aLabel.Visible = false;
                    aText.Visible  = false;
                    bLabel.Visible = false;
                    bText.Visible  = false;
                    cLabel.Visible = false;
                    cText.Visible  = false;
                    dLabel.Visible = false;
                    dText.Visible  = false;
                    eLabel.Visible = false;
                    eText.Visible  = false;
                    fLabel.Visible = false;
                    fText.Visible  = false;

                    diff = 112;
                    visualSeparator1.Location = new Point(visualSeparator1.Location.X, visualSeparator1.Location.Y - diff);
                    label8.Location           = new Point(label8.Location.X, label8.Location.Y - diff);
                    label9.Location           = new Point(label9.Location.X, label9.Location.Y - diff);
                    dataInicial.Location      = new Point(dataInicial.Location.X, dataInicial.Location.Y - diff);
                    label10.Location          = new Point(label10.Location.X, label10.Location.Y - diff);
                    dataFinal.Location        = new Point(dataFinal.Location.X, dataFinal.Location.Y - diff);
                    noFilterData.Location     = new Point(noFilterData.Location.X, noFilterData.Location.Y - diff);
                    btnSearch.Location        = new Point(btnSearch.Location.X, btnSearch.Location.Y - diff);
                    panel2.Location           = new Point(panel2.Location.X, panel2.Location.Y - diff);
                    panel2.Size = new Size(panel2.Size.Width, panel2.Size.Height + diff);

                    return;
                }

                aLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_1_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_1_Pesquisa", "OS"));
                aText.Visible  = aLabel.Visible;
                aLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_1_Descr", "OS"))
                    ? IniFile.Read("Campo_1_Descr", "OS")
                    : "";

                bLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_2_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_2_Pesquisa", "OS"));
                bText.Visible  = bLabel.Visible;
                bLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_2_Descr", "OS"))
                    ? IniFile.Read("Campo_2_Descr", "OS")
                    : "";

                cLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_3_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_3_Pesquisa", "OS"));
                cText.Visible  = cLabel.Visible;
                cLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_3_Descr", "OS"))
                    ? IniFile.Read("Campo_3_Descr", "OS")
                    : "";

                dLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_4_Pesquisa", "OS"));
                dText.Visible  = dLabel.Visible;
                dLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_4_Descr", "OS"))
                    ? IniFile.Read("Campo_4_Descr", "OS")
                    : "";

                eLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_5_Pesquisa", "OS"));
                eText.Visible  = eLabel.Visible;
                eLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_5_Descr", "OS"))
                    ? IniFile.Read("Campo_5_Descr", "OS")
                    : "";

                fLabel.Visible = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Pesquisa", "OS")) && Convert.ToBoolean(IniFile.Read("Campo_6_Pesquisa", "OS"));
                fText.Visible  = fLabel.Visible;
                fLabel.Text    = !string.IsNullOrEmpty(IniFile.Read("Campo_6_Descr", "OS"))
                    ? IniFile.Read("Campo_6_Descr", "OS")
                    : "";

                if (!dLabel.Visible && !eLabel.Visible && !eLabel.Visible)
                {
                    diff = 59;
                    visualSeparator1.Location = new Point(visualSeparator1.Location.X, visualSeparator1.Location.Y - diff);
                    label8.Location           = new Point(label8.Location.X, label8.Location.Y - diff);
                    label9.Location           = new Point(label9.Location.X, label9.Location.Y - diff);
                    dataInicial.Location      = new Point(dataInicial.Location.X, dataInicial.Location.Y - diff);
                    label10.Location          = new Point(label10.Location.X, label10.Location.Y - diff);
                    dataFinal.Location        = new Point(dataFinal.Location.X, dataFinal.Location.Y - diff);
                    noFilterData.Location     = new Point(noFilterData.Location.X, noFilterData.Location.Y - diff);
                    btnSearch.Location        = new Point(btnSearch.Location.X, btnSearch.Location.Y - diff);
                    panel2.Location           = new Point(panel2.Location.X, panel2.Location.Y - diff);
                    panel2.Size = new Size(panel2.Size.Width, panel2.Size.Height + diff);
                }
            };

            Shown += (s, e) =>
            {
                Refresh();

                DataTableStart();
                BuscarPessoa.Select();
                AutoCompletePessoas();
                AutoCompleteUsers();

                if (Home.pedidoPage == "Ordens de Servico")
                {
                    AutoCompleteOS();
                }

                produtoId.AutoCompleteCustomSource = _mItem.AutoComplete();

                dataInicial.Text = DateTime.Now.ToString();
                dataFinal.Text   = DateTime.Now.ToString();

                var status = new ArrayList {
                    new { ID = 99, NOME = "Todos" }
                };
                switch (Home.pedidoPage)
                {
                case "Notas":
                case "Cupons":
                {
                    if (Home.pedidoPage == "Notas")
                    {
                        status.Add(new { ID = 1, NOME = "Pendentes" });
                    }

                    status.Add(new { ID = 2, NOME = "Autorizadas" });
                    status.Add(new { ID = 3, NOME = "Canceladas" });
                    break;
                }

                case "Ordens de Servico":
                case "Orçamentos":
                case "Devoluções":
                case "Consignações":
                    status.Add(new { ID = 0, NOME = "Pendente" });
                    status.Add(new { ID = 1, NOME = "Finalizado" });
                    break;

                default:
                    status.Add(new { ID = 2, NOME = "Recebimento Pendente" });
                    status.Add(new { ID = 1, NOME = @"Finalizado\Recebido" });
                    break;
                }

                Status.DataSource    = status;
                Status.DisplayMember = "NOME";
                Status.ValueMember   = "ID";
                Status.SelectedValue = 99;
            };

            BuscarPessoa.KeyDown += (s, e) =>
            {
                controle = "BuscarPessoa";
                KeyDowns(s, e);
            };

            btnTotais.Click += (s, e) =>
            {
                OpenForm.Show <PedidoTotais>(this);
            };

            btnSearch.Click += (s, e) => Filter();

            btnAdicionar.Click += (s, e) => { EditPedido(true); };

            btnEditar.Click       += (s, e) => EditPedido();
            GridLista.DoubleClick += (s, e) => EditPedido();

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

            btnHelp.Click += (s, e) => Support.OpenLinkBrowser(Configs.LinkAjuda);

            GridLista.CellFormatting += (s, e) =>
            {
                if (Home.pedidoPage != "Remessas")
                {
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        if (row.Cells[7].Value.ToString().Contains("Finalizado") || row.Cells[7].Value.ToString().Contains("Autorizada"))
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(139, 215, 146);
                        }
                        else if (row.Cells[7].Value.ToString().Contains("Cancelada"))
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(0, 150, 230);
                        }
                        else
                        {
                            row.Cells[7].Style.Font = new Font("Segoe UI Semibold", 9.75F, FontStyle.Bold,
                                                               GraphicsUnit.Point, 0);
                            row.Cells[7].Style.ForeColor = Color.White;
                            row.Cells[7].Style.BackColor = Color.FromArgb(255, 89, 89);
                        }
                    }
                }
            };

            using (var b = workerBackground)
            {
                b.DoWork += async(s, e) =>
                {
                    dataTable = await _cPedido.GetDataTablePedidos(Home.pedidoPage, dataInicial.Text,
                                                                   dataFinal.Text, noFilterData.Checked);
                };

                b.RunWorkerCompleted += async(s, e) =>
                {
                    await _cPedido.SetTablePedidos(GridLista, Home.pedidoPage, dataInicial.Text, dataFinal.Text,
                                                   noFilterData.Checked, dataTable, BuscarPessoa.Text);

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

            timer.AutoReset = false;
            timer.Elapsed  += (s, e) => BuscarPessoa.Invoke((MethodInvoker) delegate
            {
                Filter();
                Loading.Visible   = false;
                GridLista.Visible = true;
            });

            BuscarPessoa.Enter += async(s, e) =>
            {
                await Task.Delay(100);

                Filter();
            };

            imprimir.Click += async(s, e) => await RenderizarAsync();

            switch (Home.pedidoPage)
            {
            case "Vendas":
                btnVideoAjuda.Click += (s, e) => Support.Video("https://www.youtube.com/watch?v=Z2pkMEAAk4Q");
                break;

            case "Notas":
            case "Cupons":
            case "Orçamentos":
            case "Devoluções":
            case "Consignações":
                btnVideoAjuda.Visible = false;
                break;
            }
        }