コード例 #1
0
        public Tb_Cliente getClienteByCpf(string CPF)
        {
            Tb_Cliente cliente = new Tb_Cliente();
            string     query   = string.Empty;

            try
            {
                query = string.Format("SELECT * FROM TB_CLIENTE WHERE CPF = '{0}'", CPF);

                cliente = new ClienteRepository().getCliente(query).FirstOrDefault();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cliente não localizado :" + ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(cliente);
        }
コード例 #2
0
        public Resultado InsertCliente(Tb_Cliente cliente)
        {
            Resultado resultado = new Resultado();
            string    query     = string.Empty;

            try
            {
                query = string.Format("INSERT INTO TB_CLIENTE(Nome,Sobrenome,Endereco,Numero,Telefone,Bairro,CEP,CPF,Complemento) " +
                                      "VALUES('{0}','{1}','{2}',{3},'{4}','{5}','{6}','{7}','{8}')", cliente.Nome, cliente.SobreNome, cliente.Endereco, cliente.Numero, cliente.Telefone, cliente.Bairro, cliente.CEP, cliente.CPF, cliente.Complemento);

                resultado = new ClienteRepository().InsertCliente(query);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao inserir cliente :" + ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(resultado);
        }
コード例 #3
0
        private void SaveCadastrarCliente_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(textBoxNome.Text) && !string.IsNullOrEmpty(maskedTelefone.Text) &&
                    !string.IsNullOrEmpty(maskedCEP.Text) && !string.IsNullOrEmpty(txtNumero.Text))
                {
                    Resultado resultado = new Resultado();

                    Tb_Cliente cliente = new Tb_Cliente()
                    {
                        CEP         = maskedCEP.Text,
                        Endereco    = string.IsNullOrEmpty(txtEndereco.Text)?null: txtEndereco.Text,
                        Nome        = string.IsNullOrEmpty(textBoxNome.Text) ? null : textBoxNome.Text,
                        SobreNome   = string.IsNullOrEmpty(textBoxSobrenome.Text) ? null : textBoxSobrenome.Text,
                        Numero      = string.IsNullOrEmpty(txtNumero.Text) ? 0 : Convert.ToInt32(txtNumero.Text),
                        Telefone    = string.IsNullOrEmpty(maskedTelefone.Text) ? null : maskedTelefone.Text,
                        Complemento = string.IsNullOrEmpty(textBoxComplemento.Text) ? null : textBoxComplemento.Text,
                        Bairro      = string.IsNullOrEmpty(txtBairro.Text) ? null : txtBairro.Text,
                        CPF         = string.IsNullOrEmpty(maskedCPF.Text) ? null:maskedCPF.Text
                    };

                    resultado = new ClienteBusiness().InsertCliente(cliente);

                    if (resultado.Sucesso)
                    {
                        labelRespostaCliente.Text = string.Concat("Cliente :", cliente.Nome, " adicionado com sucesso!");

                        utilitarios.LimparCampos(panel1);
                        utilitarios.LimparCampos(groupBox1);
                    }
                }
                else
                {
                    MessageBox.Show("Preencha os campos corretamente", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Erro ao cadastrar cliente :" + ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
 public HttpResponseMessage PostCliente(Tb_Cliente tb_Cliente)
 {
     return(Request.CreateResponse(HttpStatusCode.OK, "Aluno cadastrado com sucesso"));
 }