Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     IdVendedor = ((Controle_Dados.Usuarios)(((System.Web.UI.UserControl)(this.Master)).Session["LoginUsuario"])).IdVendedor;
     if (!this.IsPostBack)
     {
         LstTpMov.SelectedValue = "0";
         TxtPesquisa.Focus();
     }
 }
 private void WinPrincipal_Loaded(object sender, RoutedEventArgs e)
 {
     Pesquisa(TxtPesquisa.Text.Trim());
     TxtPesquisa.Focus();
 }
Пример #3
0
        private void TxtPesquisa_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (TxtPesquisa.Text.Trim() != "")
                {
                    try
                    {
                        DataSet Tabela = new DataSet();
                        string  sSQL   = "SELECT T1.ID_FUNC,T1.MATRICULA,T1.NOME,T2.DEPARTAMENTO,T3.FILIAL AS LotFilial FROM FUNCIONARIOS T1 " +
                                         " LEFT JOIN Departamentos T2 ON (T2.Id_Departamento=T1.Id_Departamento)" +
                                         " LEFT JOIN Empresa_Filial T3 ON (T3.Id_Filial=T1.Id_FilialTrab) WHERE T1.DTDEMISSAO IS NULL AND T3.ID_FILIAL<>2";

                        if (TxtPesquisa.Text.Trim() != "")
                        {
                            try
                            {
                                if (LstPesquisa.SelectedIndex == 0)
                                {
                                    Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.NOME LIKE '%{0}%' order by T1.NOME", TxtPesquisa.Text.Trim()));
                                }
                                else if (LstPesquisa.SelectedIndex == 1)
                                {
                                    Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.MATRICULA LIKE '%{0}%' order by T1.MATRICULA", TxtPesquisa.Text.Trim()));
                                }
                                else if (LstPesquisa.SelectedIndex == 2)
                                {
                                    Tabela = Controle.ConsultaTabela(string.Format(sSQL + " AND T1.CPF LIKE '%{0}%' order by T1.CPF", TxtPesquisa.Text.Trim()));
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Erro ao pesquisar verifique o conteúdo da pesquisa", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            Tabela = Controle.ConsultaTabela(sSQL + " ORDER BY T1.NOME");
                        }

                        BindingSource Source = new BindingSource();
                        Source.DataSource    = Tabela;
                        Source.DataMember    = Tabela.Tables[0].TableName;
                        GridDados.DataSource = Source;
                        int item = Source.Find("Id_Func", CadFunc.IdFunc);
                        Source.Position = item;

                        if (GridDados.CurrentRow != null)
                        {
                            GridDados.Focus();
                        }
                        else
                        {
                            MessageBox.Show("Nenhum registro foi localizado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            TxtPesquisa.Focus();
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }
Пример #4
0
        private void TxtPesquisa_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                BtnFicha.Enabled     = false;
                BtnUltCompra.Enabled = false;
                if (TxtPesquisa.Text.Trim() != "")
                {
                    try
                    {
                        string sSQL = "SELECT T1.Id_Pessoa,CASE CLIE_FORN WHEN 0 THEN 'Cliente' WHEN 1 THEN 'Fornecedor' WHEN 2 THEN 'Cliente e Fornecedor' WHEN 3 THEN 'Distribuidor' " +
                                      " WHEN 4 THEN 'Rede ou Grupo' WHEN 5 THEN 'Funcionário' WHEN 6 THEN 'Revenda' WHEN 6 THEN 'Representante' ELSE '' END AS TipoCad,T1.Cnpj,T1.RazaoSocial," +
                                      "T1.Fantasia,T1.LimiteCredito,T1.Credito,T1.Fone,T1.CONTATO,T2.VENDEDOR,Rtrim(T1.Endereco)+','+RTrim(T1.Numero)+' '+Rtrim(T1.Complemento)+' '+RTrim(T1.Cep)+' '+RTrim(T1.Bairro)+' '+Rtrim(T1.Cidade) as Logradouro,T1.DATACADASTRO AS DTCADASTRO FROM Pessoas T1 LEFT JOIN VENDEDORES T2 ON (T2.ID_VENDEDOR=T1.ID_VENDEDOR) ";

                        if (RedeGrp)
                        {
                            sSQL = sSQL + " WHERE T1.CLIE_FORN=4 AND";
                        }
                        else
                        {
                            sSQL = sSQL + " WHERE";
                        }

                        DataSet Tabela = new DataSet();
                        if (LstPesquisa.SelectedIndex == 0)
                        {
                            Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Cnpj LIKE '%{0}%' order by T1.Cnpj", TxtPesquisa.Text.Trim()));
                        }
                        else if (LstPesquisa.SelectedIndex == 1)
                        {
                            Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.RazaoSocial LIKE '%{0}%' order by T1.RazaoSocial", TxtPesquisa.Text.Trim()));
                        }
                        else if (LstPesquisa.SelectedIndex == 2)
                        {
                            Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Fantasia LIKE '%{0}%' order by T1.Fantasia", TxtPesquisa.Text.Trim()));
                        }
                        else if (LstPesquisa.SelectedIndex == 3)
                        {
                            Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Endereco LIKE '%{0}%' order by T1.Fantasia", TxtPesquisa.Text.Trim()));
                        }
                        else if (LstPesquisa.SelectedIndex == 4)
                        {
                            Tabela = Controle.ConsultaTabela(string.Format(sSQL + " T1.Ativo=1 and T1.Fone LIKE '%{0}%' order by T1.Fone", TxtPesquisa.Text.Trim()));
                        }


                        GridDados.DataSource = Tabela;
                        GridDados.DataMember = Tabela.Tables[0].TableName;
                        if (GridDados.CurrentRow != null)
                        {
                            GridDados.Focus();
                            BtnFicha.Enabled     = true;
                            BtnUltCompra.Enabled = true && !FrmPrincipal.VersaoDistribuidor;
                        }
                        else
                        {
                            MessageBox.Show("Nenhum registro foi localizado", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            TxtPesquisa.Focus();
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Erro ao pesquisar verifique o conteúdo da pesquisa", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }