Ejemplo n.º 1
0
        public Classes.Cliente RetrieveClient(int ID)
        {
            Classes.Cliente cliente = new Classes.Cliente();
            if (con == null)
            {
                this.OpenConnection();
            }
            string query = String.Format(@"SELECT * FROM Clientes WHERE IDCliente = {0}", ID);

            try
            {
                com = new SqlCommand(query, con);
                rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    cliente = new Classes.Cliente(ID, rdr["Nombre"].ToString(), rdr["APaterno"].ToString(), rdr["AMaterno"].ToString(), rdr["Correo"].ToString(), rdr["RFC"].ToString(), rdr["Domicilio"].ToString(), rdr["Telefono"].ToString(), rdr["ImgPath"].ToString());
                }
                this.CloseConnection();
            } catch (Exception ex)
            {
                Debug.Write(ex.Message);
                this.CloseConnection();
            }
            return(cliente);
        }
Ejemplo n.º 2
0
        private void btCadastrar_MouseClick(object sender, MouseEventArgs e)
        {
            string nome     = tbNome.Text;
            int    cpf      = Int32.Parse(tbCpf.Text);
            int    telefone = Int32.Parse(tbTelefone.Text);

            Classes.Cliente cliente = new Classes.Cliente(nome, cpf, telefone);
            cliente.cadastrarCliente();
            listagem();
            limpar();
        }
Ejemplo n.º 3
0
 //Listagem de Produtos
 private void listagem()
 {
     Classes.Cliente list = new Classes.Cliente();
     try
     {
         dgCliente.DataSource = list.listarCliente();
     }
     catch (Exception)
     {
         Console.WriteLine("Listagem Falhou! Verifique a conexão com o banco");
     }
 }
Ejemplo n.º 4
0
 private void tbPesquisa_TextChanged(object sender, EventArgs e)
 {
     Classes.Cliente filtro = new Classes.Cliente();
     try
     {
         dgCliente.DataSource = filtro.filtroCliente(tbPesquisa.Text);
         Console.WriteLine(tbPesquisa.Text);
     }
     catch (Exception)
     {
         Console.WriteLine("filtro Falhou! Verifique a conexão com o banco");
     }
 }
Ejemplo n.º 5
0
        public bool AddClient(Classes.Cliente cliente)
        {
            if (con == null)
            {
                this.OpenConnection();
            }
            string query = String.Format(@"INSERT INTO Clientes(Nombre, APaterno, AMaterno, Correo, RFC, Domicilio, Telefono, ImgPath) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')", cliente.Nombre, cliente.APaterno, cliente.AMaterno, cliente.Correo, cliente.RFC, cliente.Domicilio, cliente.Telefono, cliente.Path);

            try
            {
                com = new SqlCommand(query, con);
                com.ExecuteNonQuery();
                this.CloseConnection();
                return(true);
            } catch (Exception ex)
            {
                Debug.Write(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool DeleteClient(Classes.Cliente cliente)
        {
            if (con == null)
            {
                this.OpenConnection();
            }
            string query = String.Format(@"DELETE FROM Clientes WHERE IDCliente = {0}", cliente.ID);

            try
            {
                com = new SqlCommand(query, con);
                com.ExecuteNonQuery();
                this.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 7
0
        public bool UpdateClient(Classes.Cliente cliente)
        {
            if (con == null)
            {
                this.OpenConnection();
            }
            string query = String.Format(@"UPDATE Clientes SET Nombre = '{0}', APaterno = '{1}', AMaterno = '{2}', Correo = '{3}', RFC = '{4}', Domicilio = '{5}', Telefono = '{6}', ImgPath = '{7}' WHERE IDCliente = {8}", cliente.Nombre, cliente.APaterno, cliente.AMaterno, cliente.Correo, cliente.RFC, cliente.Domicilio, cliente.Telefono, cliente.Path, cliente.ID);

            try
            {
                com = new SqlCommand(query, con);
                com.ExecuteNonQuery();
                this.CloseConnection();
                return(true);
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 8
0
        private void button_cadastrar_Click(object sender, EventArgs e)
        {
            bool erro = false;

            txt_erro_cnpj.Text         = " ";
            txt_erro_nome.Text         = " ";
            txt_erro_endereco.Text     = " ";
            txt_erro_telefone.Text     = "";
            txt_erro_nomeContato.Text  = "";
            txt_erro_emailContato.Text = " ";
            txt_erro_emailEmpresa.Text = " ";
            txtsucesso.Text            = " ";

            if (txt_cnpj.Text == "   ,   ,   -") // Verificação de vazio no campo CNPJ
            {
                txt_erro_cnpj.Text = "Insira um CNPJ válido!";
                erro = true;
                return;
            }

            if (txt_nome.Text == " ") // Verificação de vazio no campo NOME FANTASIA
            {
                txt_erro_nome.Text = "Insira um nome fantasia válido!";
                erro = true;
                return;
            }

            if (txt_endereco.Text == " ") // Verificação de vazio no campo ENDERECO
            {
                txt_erro_endereco.Text = "Insira um endereço válido!";
                erro = true;
                return;
            }

            if (txt_telefone.Text == " ") // Verificação de vazio no campo TELEFONE EMPRESA
            {
                txt_erro_telefone.Text = "Insira um telefone válido!";
                erro = true;
                return;
            }

            if (txt_nomeContato.Text == " ") // Verificação de vazio no campo NOME CONTATO DIRETO
            {
                txt_erro_nomeContato.Text = "Insira um nome de contato válido válida!";
                erro = true;
                return;
            }
            if (txt_emailContato.Text == " ") // Verificação de vazio no campo E-MAIL CONTATO DIRETO
            {
                txt_erro_emailContato.Text = "Insira um email válido!";
                erro = true;
                return;
            }
            if (txt_emailEmpresa.Text == " ") // Verificação de vazio no campo E-MAIL EMPRESA
            {
                txt_erro_emailEmpresa.Text = "Insira um email válido!";
                erro = true;
                return;
            }


            if (erro == false)
            {
                Classes.Cliente func = new Classes.Cliente(txt_cnpj.Text, txt_nome.Text, txt_endereco.Text, txt_telefone.Text, txt_nomeContato.Text, txt_emailContato.Text, txt_emailEmpresa.Text);
                txtsucesso.Text = "Cadastro realizado com sucesso!";
            }

            else
            {
                txtsucesso.Text = "Preencha corretamente os dados! ";
                return;
            }
        }