示例#1
0
 private void codEmpresaFreteComboBox_Leave(object sender, EventArgs e)
 {
     if (estado.Equals(EstadoFormulario.INSERIR))
     {
         List <Pessoa> pessoas = (List <Pessoa>)GerenciadorPessoa.GetInstance().ObterPorNomeFantasia(codEmpresaFreteComboBox.Text);
         if (pessoas.Count == 0)
         {
             Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa(codEmpresaFreteComboBox.Text);
             frmPessoaPesquisa.ShowDialog();
             if (frmPessoaPesquisa.PessoaSelected != null)
             {
                 pessoaTransportadoraBindingSource.Position = pessoaTransportadoraBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
                 codEmpresaFreteComboBox.Text = frmPessoaPesquisa.PessoaSelected.Nome;
             }
             else
             {
                 codEmpresaFreteComboBox.Focus();
             }
             frmPessoaPesquisa.Dispose();
         }
         else
         {
             pessoaTransportadoraBindingSource.Position = pessoaTransportadoraBindingSource.List.IndexOf(pessoas[0]);
         }
     }
     codEntradaTextBox_Leave(sender, e);
 }
示例#2
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
     frmPessoaPesquisa.ShowDialog();
     if (frmPessoaPesquisa.PessoaSelected != null)
     {
         pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
     }
     frmPessoaPesquisa.Dispose();
 }
示例#3
0
        private void btnAdicionarContato_Click(object sender, EventArgs e)
        {
            Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
            frmPessoaPesquisa.ShowDialog();
            if (frmPessoaPesquisa.PessoaSelected != null)
            {
                ContatoPessoa contatoPessoa = new ContatoPessoa();
                contatoPessoa.CodPessoa        = Int64.Parse(codPessoaTextBox.Text);
                contatoPessoa.CodPessoaContato = frmPessoaPesquisa.PessoaSelected.CodPessoa;

                GerenciadorPessoa.GetInstance().InserirContato(contatoPessoa);
                contatosBindingSource.DataSource = GerenciadorPessoa.GetInstance().ObterContatos(long.Parse(codPessoaTextBox.Text));
            }
            frmPessoaPesquisa.Dispose();
        }
示例#4
0
 private void btnContato_Click(object sender, EventArgs e)
 {
     Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
     frmPessoaPesquisa.ShowDialog();
     if (frmPessoaPesquisa.getCodPessoa() != -1)
     {
         btnSalvar_Click(sender, e);
         try
         {
             tb_contato_empresaTableAdapter.Insert(long.Parse(codigoEmpresaTextBox.Text), frmPessoaPesquisa.getCodPessoa());
         }
         catch (Exception)
         {
             MessageBox.Show("O contato selecionado já foi incluído na empresa.");
         }
     }
     frmPessoaPesquisa.Dispose();
     btnContato.Focus();
     this.tb_contato_empresaTableAdapter.FillByEmpresa(this.saceDataSet.tb_contato_empresa, long.Parse(codigoEmpresaTextBox.Text));
 }
示例#5
0
 private void FrmUsuario_KeyDown(object sender, KeyEventArgs e)
 {
     if (estado.Equals(EstadoFormulario.ESPERA))
     {
         if (e.KeyCode == Keys.F2)
         {
             btnBuscar_Click(sender, e);
         }
         if (e.KeyCode == Keys.F3)
         {
             btnNovo_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F4)
         {
             btnEditar_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F5)
         {
             btnExcluir_Click(sender, e);
         }
         else if (e.KeyCode == Keys.End)
         {
             usuarioBindingSource.MoveLast();
         }
         else if (e.KeyCode == Keys.Home)
         {
             usuarioBindingSource.MoveFirst();
         }
         else if (e.KeyCode == Keys.PageUp)
         {
             usuarioBindingSource.MovePrevious();
         }
         else if (e.KeyCode == Keys.PageDown)
         {
             usuarioBindingSource.MoveNext();
         }
         else if (e.KeyCode == Keys.Escape)
         {
             this.Close();
         }
     }
     else
     {
         if (e.KeyCode == Keys.Enter)
         {
             e.Handled = true;
             SendKeys.Send("{tab}");
         }
         if (e.KeyCode == Keys.Escape)
         {
             btnCancelar_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F6)
         {
             btnSalvar_Click(sender, e);
         }
         else if ((e.KeyCode == Keys.F2) && (codPessoaComboBox.Focused))
         {
             Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa(Pessoa.PESSOA_JURIDICA);
             frmPessoaPesquisa.ShowDialog();
             if (frmPessoaPesquisa.PessoaSelected != null)
             {
                 pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
             }
             frmPessoaPesquisa.Dispose();
         }
         else if ((e.KeyCode == Keys.F3) && (codPessoaComboBox.Focused))
         {
             Telas.FrmPessoa frmPessoa = new Telas.FrmPessoa();
             frmPessoa.ShowDialog();
             if (frmPessoa.PessoaSelected != null)
             {
                 pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoa.PessoaSelected);
             }
             frmPessoa.Dispose();
         }
     }
 }
示例#6
0
        private void FrmEntradaPedido_KeyDown(object sender, KeyEventArgs e)
        {
            if (estado.Equals(EstadoFormulario.ESPERA))
            {
                if (e.KeyCode == Keys.F2)
                {
                    btnBuscar_Click(sender, e);
                }
                if (e.KeyCode == Keys.F3)
                {
                    btnNovo_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F4)
                {
                    btnEditar_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F5)
                {
                    btnExcluir_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F7)
                {
                    btnProdutos_Click(sender, e);
                }
                else if (e.KeyCode == Keys.End)
                {
                    entradaBindingSource.MoveLast();
                }
                else if (e.KeyCode == Keys.Home)
                {
                    entradaBindingSource.MoveFirst();
                }
                else if (e.KeyCode == Keys.PageUp)
                {
                    entradaBindingSource.MovePrevious();
                }
                else if (e.KeyCode == Keys.PageDown)
                {
                    entradaBindingSource.MoveNext();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    this.Close();
                }
            }
            else
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (codFornecedorComboBox.Focused)
                    {
                        codFornecedorComboBox_Leave(sender, e);
                    }
                    else if (codEmpresaFreteComboBox.Focused)
                    {
                        codEmpresaFreteComboBox_Leave(sender, e);
                    }
                    else if (codProdutoComboBox.Focused)
                    {
                        codProdutoComboBox_Leave(sender, e);
                    }

                    e.Handled = true;
                    SendKeys.Send("{tab}");
                }
                if ((e.KeyCode == Keys.F7) || (e.KeyCode == Keys.Escape))
                {
                    btnCancelar_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F6)
                {
                    btnSalvar_Click(sender, e);
                }
                else if ((e.KeyCode == Keys.F2) && (codFornecedorComboBox.Focused))
                {
                    Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
                    frmPessoaPesquisa.ShowDialog();
                    if (frmPessoaPesquisa.PessoaSelected != null)
                    {
                        pessoaFornecedorBindingSource.Position = pessoaFornecedorBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
                    }
                    frmPessoaPesquisa.Dispose();
                }
                else if ((e.KeyCode == Keys.F3) && (codFornecedorComboBox.Focused))
                {
                    Telas.FrmPessoa frmPessoa = new Telas.FrmPessoa();
                    frmPessoa.ShowDialog();
                    if (frmPessoa.PessoaSelected != null)
                    {
                        pessoaFornecedorBindingSource.Position = pessoaFornecedorBindingSource.List.IndexOf(frmPessoa.PessoaSelected);
                    }
                    frmPessoa.Dispose();
                }
                else if ((e.KeyCode == Keys.F2) && (codEmpresaFreteComboBox.Focused))
                {
                    Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
                    frmPessoaPesquisa.ShowDialog();
                    if (frmPessoaPesquisa.PessoaSelected != null)
                    {
                        pessoaTransportadoraBindingSource.Position = pessoaTransportadoraBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
                    }
                    frmPessoaPesquisa.Dispose();
                }
                else if ((e.KeyCode == Keys.F3) && (codEmpresaFreteComboBox.Focused))
                {
                    Telas.FrmPessoa frmPessoa = new Telas.FrmPessoa();
                    frmPessoa.ShowDialog();
                    if (frmPessoa.PessoaSelected != null)
                    {
                        pessoaTransportadoraBindingSource.Position = pessoaTransportadoraBindingSource.List.IndexOf(frmPessoa.PessoaSelected);
                    }
                    frmPessoa.Dispose();
                }
                else if ((e.KeyCode == Keys.F2) && (codProdutoComboBox.Focused))
                {
                    Telas.FrmProdutoPesquisaPreco frmProdutoPesquisaPreco = new Telas.FrmProdutoPesquisaPreco(true);
                    frmProdutoPesquisaPreco.ShowDialog();
                    if (frmProdutoPesquisaPreco.ProdutoPesquisa != null)
                    {
                        produtoBindingSource.Position = produtoBindingSource.List.IndexOf(frmProdutoPesquisaPreco.ProdutoPesquisa);
                    }
                    frmProdutoPesquisaPreco.Dispose();
                }
                else if ((e.KeyCode == Keys.F3) && (codProdutoComboBox.Focused))
                {
                    Telas.FrmProduto frmProduto = new Telas.FrmProduto();
                    frmProduto.ShowDialog();
                    if (frmProduto.ProdutoPesquisa != null)
                    {
                        produtoBindingSource.DataSource = GerenciadorProduto.GetInstance().ObterTodos();
                        produtoBindingSource.Position   = produtoBindingSource.List.IndexOf(frmProduto.ProdutoPesquisa);
                    }
                    frmProduto.Dispose();
                }
            }
            // Coloca o foco na grid caso ela não possua
            if (e.KeyCode == Keys.F12)
            {
                btnCancelar_Click(sender, e);
                tb_entrada_produtoDataGridView.Focus();
                tb_entrada_produtoDataGridView.Select();
                if (tb_entrada_produtoDataGridView.RowCount == 1)
                {
                    tb_entrada_produtoDataGridView.SelectAll();
                }
            }

            // permite excluir um contato quando o foco está na grid
            if ((e.KeyCode == Keys.Delete) && (tb_entrada_produtoDataGridView.Focused == true))
            {
                excluirProduto(sender, e);
            }
        }
示例#7
0
        private void FrmContas_KeyDown(object sender, KeyEventArgs e)
        {
            if (estado.Equals(EstadoFormulario.ESPERA))
            {
                if (e.KeyCode == Keys.F2)
                {
                    btnBuscar_Click(sender, e);
                }
                if (e.KeyCode == Keys.F3)
                {
                    btnNovo_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F4)
                {
                    btnEditar_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F5)
                {
                    btnExcluir_Click(sender, e);
                }
                else if (e.KeyCode == Keys.End)
                {
                    contaBindingSource.MoveLast();
                }
                else if (e.KeyCode == Keys.Home)
                {
                    contaBindingSource.MoveFirst();
                }
                else if (e.KeyCode == Keys.PageUp)
                {
                    contaBindingSource.MovePrevious();
                }
                else if (e.KeyCode == Keys.PageDown)
                {
                    contaBindingSource.MoveNext();
                }
                else if (e.KeyCode == Keys.Escape)
                {
                    this.Close();
                }
            }
            else
            {
                if ((e.KeyCode == Keys.F7) || (e.KeyCode == Keys.Escape))
                {
                    btnCancelar_Click(sender, e);
                }
                else if (e.KeyCode == Keys.F6)
                {
                    btnSalvar_Click(sender, e);
                }
                else if ((e.KeyCode == Keys.F2) && (codPessoaComboBox.Focused))
                {
                    Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa();
                    frmPessoaPesquisa.ShowDialog();
                    if (frmPessoaPesquisa.PessoaSelected != null)
                    {
                        pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
                    }
                    frmPessoaPesquisa.Dispose();
                }
                else if ((e.KeyCode == Keys.F3) && (codPessoaComboBox.Focused))
                {
                    Telas.FrmPessoa frmPessoa = new Telas.FrmPessoa();
                    frmPessoa.ShowDialog();
                    if (frmPessoa.PessoaSelected != null)
                    {
                        pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoa.PessoaSelected);
                    }
                    frmPessoa.Dispose();
                }

                else if ((e.KeyCode == Keys.F2) && (codPlanoContaComboBox.Focused))
                {
                    Telas.FrmPlanoContaPesquisa frmPlanoContaPesquisa = new Telas.FrmPlanoContaPesquisa();
                    frmPlanoContaPesquisa.ShowDialog();
                    if (frmPlanoContaPesquisa.PlanoContaSelected != null)
                    {
                        planoContaBindingSource.Position = planoContaBindingSource.List.IndexOf(frmPlanoContaPesquisa.PlanoContaSelected);
                    }
                    frmPlanoContaPesquisa.Dispose();
                }
                else if ((e.KeyCode == Keys.F3) && (codPlanoContaComboBox.Focused))
                {
                    Telas.FrmPlanoConta frmPlanoConta = new Telas.FrmPlanoConta();
                    frmPlanoConta.ShowDialog();
                    if (frmPlanoConta.PlanoContaSelected != null)
                    {
                        planoContaBindingSource.Position = planoContaBindingSource.List.IndexOf(frmPlanoConta.PlanoContaSelected);
                    }
                    frmPlanoConta.Dispose();
                }
            }
        }
        /// <summary>
        /// Controla os combobox com entrada de pessoas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="pessoaComboBox"></param>
        /// <param name="estado"></param>
        /// <param name="pessoaBindingSource"></param>
        /// <param name="retornaNomeFantasia"></param>
        public static Pessoa PessoaComboBox_Leave(object sender, EventArgs e, ComboBox pessoaComboBox, EstadoFormulario estado, BindingSource pessoaBindingSource, bool retornaNomeFantasia, bool precisaEscolherPessoa)
        {
            if (estado.Equals(EstadoFormulario.INSERIR) || estado.Equals(EstadoFormulario.ATUALIZAR))
            {
                List <Pessoa> pessoas;
                if (retornaNomeFantasia)
                {
                    pessoas = (List <Pessoa>)GerenciadorPessoa.GetInstance().ObterPorNomeFantasia(pessoaComboBox.Text);
                }
                else
                {
                    pessoas = (List <Pessoa>)GerenciadorPessoa.GetInstance().ObterPorNome(pessoaComboBox.Text);
                }

                Pessoa pessoaNomeIgual = null;
                foreach (Pessoa pessoa in pessoas)
                {
                    if (retornaNomeFantasia)
                    {
                        if (pessoa.NomeFantasia.Equals(pessoaComboBox.Text))
                        {
                            pessoaNomeIgual = pessoa;
                        }
                    }
                    else
                    {
                        if (pessoa.Nome.Equals(pessoaComboBox.Text))
                        {
                            pessoaNomeIgual = pessoa;
                        }
                    }
                }

                if ((pessoas.Count == 0) || ((pessoas.Count > 1) && (pessoaNomeIgual == null)) || ((pessoaNomeIgual != null) && pessoaNomeIgual.CodPessoa.Equals(Global.CLIENTE_PADRAO) && precisaEscolherPessoa))
                {
                    Telas.FrmPessoaPesquisa frmPessoaPesquisa;
                    if ((pessoaNomeIgual != null) && pessoaNomeIgual.CodPessoa.Equals(Global.CLIENTE_PADRAO))
                    {
                        frmPessoaPesquisa = new Telas.FrmPessoaPesquisa("");
                    }
                    else
                    {
                        frmPessoaPesquisa = new Telas.FrmPessoaPesquisa(pessoaComboBox.Text);
                    }
                    frmPessoaPesquisa.ShowDialog();
                    if (frmPessoaPesquisa.PessoaSelected != null)
                    {
                        pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
                        if (retornaNomeFantasia)
                        {
                            pessoaComboBox.Text = ((Pessoa)pessoaBindingSource.Current).NomeFantasia;
                        }
                        else
                        {
                            pessoaComboBox.Text = ((Pessoa)pessoaBindingSource.Current).Nome;
                        }
                    }
                    else
                    {
                        pessoaComboBox.Focus();
                    }
                    frmPessoaPesquisa.Dispose();
                }
                else
                {
                    pessoaBindingSource.Position = pessoaBindingSource.List.IndexOf(pessoaNomeIgual);
                    if (retornaNomeFantasia)
                    {
                        pessoaComboBox.Text = ((Pessoa)pessoaBindingSource.Current).NomeFantasia;
                    }
                    else
                    {
                        pessoaComboBox.Text = ((Pessoa)pessoaBindingSource.Current).Nome;
                    }
                }
            }
            return((Pessoa)pessoaBindingSource.Current);
        }
示例#9
0
 private void FrmProduto_KeyDown(object sender, KeyEventArgs e)
 {
     if (estado.Equals(EstadoFormulario.ESPERA))
     {
         if (e.KeyCode == Keys.F2)
         {
             btnBuscar_Click(sender, e);
         }
         if (e.KeyCode == Keys.F3)
         {
             btnNovo_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F4)
         {
             btnEditar_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F5)
         {
             btnExcluir_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F7)
         {
             btnEstoque_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F8)
         {
             btnPontaEstoque_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F9)
         {
             btnEstatistica_Click(sender, e);
         }
         else if (e.KeyCode == Keys.End)
         {
             produtoBindingSource.MoveLast();
         }
         else if (e.KeyCode == Keys.Home)
         {
             produtoBindingSource.MoveFirst();
         }
         else if (e.KeyCode == Keys.PageUp)
         {
             produtoBindingSource.MovePrevious();
         }
         else if (e.KeyCode == Keys.PageDown)
         {
             produtoBindingSource.MoveNext();
         }
         else if (e.KeyCode == Keys.Escape)
         {
             this.Close();
         }
     }
     else
     {
         if (e.KeyCode == Keys.Enter)
         {
             if (codigoFabricanteComboBox.Focused)
             {
                 codigoFabricanteComboBox_Leave(sender, e);
             }
             e.Handled = true;
             SendKeys.Send("{tab}");
         }
         else if (e.KeyCode == Keys.Escape)
         {
             btnCancelar_Click(sender, e);
         }
         else if (e.KeyCode == Keys.F6)
         {
             btnSalvar_Click(sender, e);
         }
         else if ((e.KeyCode == Keys.F2) && (codGrupoComboBox.Focused))
         {
             Telas.FrmGrupoPesquisa frmGrupoPesquisa = new Telas.FrmGrupoPesquisa();
             frmGrupoPesquisa.ShowDialog();
             if (frmGrupoPesquisa.SelectedGrupo != null)
             {
                 grupoBindingSource.Position = grupoBindingSource.List.IndexOf(frmGrupoPesquisa.SelectedGrupo);
             }
             frmGrupoPesquisa.Dispose();
         }
         else if ((e.KeyCode == Keys.F3) && (codGrupoComboBox.Focused))
         {
             Telas.FrmGrupo frmGrupo = new Telas.FrmGrupo();
             frmGrupo.ShowDialog();
             if (frmGrupo.GrupoSelected != null)
             {
                 grupoBindingSource.Position = grupoBindingSource.List.IndexOf(frmGrupo.GrupoSelected);
             }
             frmGrupo.Dispose();
         }
         else if ((e.KeyCode == Keys.F2) && (codSubgrupoComboBox.Focused))
         {
             Telas.FrmSubgrupoPesquisa frmSubGrupoPesquisa = new Telas.FrmSubgrupoPesquisa();
             frmSubGrupoPesquisa.ShowDialog();
             if (frmSubGrupoPesquisa.SubgrupoSelected != null)
             {
                 grupoBindingSource.Position    = grupoBindingSource.List.IndexOf(frmSubGrupoPesquisa.GrupoSelected);
                 subgrupoBindingSource.Position = subgrupoBindingSource.List.IndexOf(frmSubGrupoPesquisa.SubgrupoSelected);
             }
             frmSubGrupoPesquisa.Dispose();
         }
         else if ((e.KeyCode == Keys.F3) && (codSubgrupoComboBox.Focused))
         {
             Telas.FrmSubgrupo frmSubgrupo = new Telas.FrmSubgrupo(Convert.ToInt32(codGrupoComboBox.SelectedValue.ToString()));
             frmSubgrupo.ShowDialog();
             if (frmSubgrupo.SubgrupoSelected != null)
             {
                 grupoBindingSource.Position    = grupoBindingSource.List.IndexOf(frmSubgrupo.GrupoSelected);
                 subgrupoBindingSource.Position = subgrupoBindingSource.List.IndexOf(frmSubgrupo.SubgrupoSelected);
             }
             frmSubgrupo.Dispose();
         }
         else if ((e.KeyCode == Keys.F2) && (codigoFabricanteComboBox.Focused))
         {
             Telas.FrmPessoaPesquisa frmPessoaPesquisa = new Telas.FrmPessoaPesquisa(Pessoa.PESSOA_JURIDICA);
             frmPessoaPesquisa.ShowDialog();
             if (frmPessoaPesquisa.PessoaSelected != null)
             {
                 fabricanteBindingSource.Position = fabricanteBindingSource.List.IndexOf(frmPessoaPesquisa.PessoaSelected);
             }
             frmPessoaPesquisa.Dispose();
         }
         else if ((e.KeyCode == Keys.F3) && (codigoFabricanteComboBox.Focused))
         {
             Telas.FrmPessoa frmPessoa = new Telas.FrmPessoa();
             frmPessoa.ShowDialog();
             if (frmPessoa.PessoaSelected != null)
             {
                 fabricanteBindingSource.DataSource = GerenciadorPessoa.GetInstance().ObterTodos();
                 fabricanteBindingSource.Position   = fabricanteBindingSource.List.IndexOf(frmPessoa.PessoaSelected);
             }
             frmPessoa.Dispose();
         }
     }
 }