0
I have a problem when I will enter record in the Notes field. When the user writes a note and then right after click save the same is not registered.
Customer Class: --> The Method I am using to perform the insertion is Newcustomer()
public class Cliente
{
    [Key]
    [Display(Name = "Id")]
    public string ClienteId { get; set; }
    [Required(ErrorMessage ="* Informe o nome do cliente")]
    [Display(Name = "Nome")]
    public string Nome { get; set; }
    [Display(Name = "CPF ou CNPJ")]
    public string CPFCNPJ { get; set; }
    [Display(Name = "CEP")]
    public string CEP { get; set; }
    [Display(Name = "Logradouro")]
    public string Logradouro { get; set; }
    [Display(Name = "Número")]
    public string Numero { get; set; }
    [Display(Name = "Bairro")]
    public string Bairro { get; set; }
    [Display(Name = "Cidade")]
    public string Cidade { get; set; }
    [Display(Name = "Estado")]
    public string Estado { get; set; }
    [Display(Name = "Telefone")]
    public string Telefone { get; set; }
    [Display(Name = "Celular")]
    public string Celular { get; set; }
    [Display(Name = "Whastapp")]
    public string Whatsapp { get; set; }
    [Display(Name = "Email")]
    public string Email { get; set; }
    [Display(Name = "Observações")]
    public string Observacoes { get; set; }
    [Display(Name = "Data de criação")]
    public DateTime? DataCriacao { get; set; }
    // Método para lista dos clientes.
    public List<Cliente> ListarTodosClientes()
    {
        List<Cliente> lista = new List<Cliente>(); // Instância do objeto Lista do tipo lista cliente
        Cliente item;
        DAL objDAL = new DAL(); // Instância para realizar a conexão com banco de dados.
        string sql = "Select ClienteId, Nome, CPFCNPJ, Cidade, Estado, Telefone From Cadastro.Clientes order by Nome asc";
        DataTable dt = objDAL.RetDataTable(sql);
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            item = new Cliente
            {
                ClienteId = dt.Rows[i]["ClienteId"].ToString(),
                Nome = dt.Rows[i]["Nome"].ToString(),
                CPFCNPJ = dt.Rows[i]["CPFCNPJ"].ToString(),
                Cidade = dt.Rows[i]["Cidade"].ToString(),
                Estado = dt.Rows[i]["Estado"].ToString(),
                Telefone = dt.Rows[i]["Telefone"].ToString(),
            };
            lista.Add(item);
        }
        return lista;
    }
    // Método para consultar cliente pelo ID
    public Cliente RetornarCliente(long? id)
    {
        Cliente item;
        DAL objDAL = new DAL();
        string sql = $"Select ClienteId, Nome, CPFCNPJ, CEP, Logradouro, Numero, Bairro, Cidade, Estado, Telefone, Celular, Whatsapp, Email, Observacoes  From Cadastro.Clientes Where ClienteId = {id} order by Nome asc";
        DataTable dt = objDAL.RetDataTable(sql);
        item = new Cliente
        {
            ClienteId = dt.Rows[0]["ClienteId"].ToString(),
            Nome = dt.Rows[0]["Nome"].ToString(),
            CPFCNPJ = dt.Rows[0]["CPFCNPJ"].ToString(),
            CEP = dt.Rows[0]["CEP"].ToString(),
            Logradouro = dt.Rows[0]["Logradouro"].ToString(),
            Numero = dt.Rows[0]["Numero"].ToString(),
            Bairro = dt.Rows[0]["Bairro"].ToString(),
            Cidade = dt.Rows[0]["Cidade"].ToString(),
            Estado = dt.Rows[0]["Estado"].ToString(),
            Telefone = dt.Rows[0]["Telefone"].ToString(),
            Celular = dt.Rows[0]["Celular"].ToString(),
            Whatsapp = dt.Rows[0]["Whatsapp"].ToString(),
            Email = dt.Rows[0]["Email"].ToString(),
            Observacoes = dt.Rows[0]["Observacoes"].ToString()
        };
        return item;
    }
    // Método para inserir registro no banco de dados
    public void NovoAlterarCliente()
    {
        DAL objDAL = new DAL(); // Instanciando objDAL para abrir a conexão e realizar a operação
        string sql = string.Empty;
        if (ClienteId != null)
        {
             sql = $"Update Cadastro.Clientes Set Nome='{Nome}', CPFCNPJ = '{CPFCNPJ}', CEP = '{CEP}', Logradouro = '{Logradouro}', Numero = '{Numero}', Bairro = '{Bairro}', Cidade = '{Cidade}', Estado = '{Estado}', Telefone = '{Telefone}', Celular = '{Celular}', Whatsapp = '{Whatsapp}', Email = '{Email}' Observacoes = '{Observacoes}' Where ClienteId = '{ClienteId}'"; 
        }
        else
        {
             sql = $"Insert Cadastro.Clientes(Nome, CPFCNPJ, CEP, Logradouro, Numero, Bairro, Cidade, Estado, Telefone, Celular, Whatsapp, Email, Observacoes) Values('{Nome}','{CPFCNPJ}','{CEP}','{Logradouro}','{Numero}','{Bairro}','{Cidade}','{Estado}','{Telefone}','{Celular}','{Whatsapp}','{Email}','{Observacoes}')"; // Comando para inserir registro no banco de dados.
        }
        objDAL.ExecutarComandosSql(sql); // Objeto chama o método para executar a variavel sql que passamos como parametro.
    }
}


I didn’t see the whole problem, but your code has serious security issues and not recording is the least of your problems. https://answall.com/q/183975/101. And something tells me you don’t have enough information to answer your question.
– Maniero
Hello Cool all right? Yes I know you have serious security problems, but my goal is just to verify why this problem is occurring. Then my next step will be to tidy up the security part. : ) Thanks more.
– Thiago Correa