Esempio n. 1
0
        public override void Validate()
        {
            ClearValidateMensages();

            if (Cep.ToString().Length < 1)
            {
                AddError("O campo CEP do Endereço não foi informado.");
            }

            if (Cep.ToString().Length > 0 && Cep.ToString().Length < 8)
            {
                AddError("O campo CEP do Endereço não possuí o número de caracteres esperados.");
            }

            if (Rua.Length < 1)
            {
                AddError("O campo Rua do Endereço não foi informado.");
            }

            if (Bairro.Length < 1)
            {
                AddError("O campo Bairro do Endereço não foi informado.");
            }

            if (Numero.ToString().Length < 1)
            {
                AddError("O campo Número do Endereço não foi informado.");
            }

            if (Cidade.Length < 1)
            {
                AddError("O campo Cidade do Endereço não foi informado.");
            }

            if (Estado.Length < 1)
            {
                AddError("O campo Estado do Endereço não foi informado.");
            }
        }
Esempio n. 2
0
        public void InsertProdutor(string ValorUF)
        {
            try
            {
                string id_usuario_logado = @HttpContextAccessor.HttpContext.Session.GetString("IdNomeUsuarioLogado");
                string sql = "";
                if (CpfCnpj == null)
                {
                    CpfCnpj = "";
                }
                if (Cpf == null)
                {
                    Cpf = "";
                }
                if (Ie == null)
                {
                    Ie = "";
                }
                if (Endereco == null)
                {
                    Endereco = "";
                }
                if (Cidade == null)
                {
                    Cidade = "";
                }
                if (Bairro == null)
                {
                    Bairro = "";
                }
                if (Cep == null)
                {
                    Cep = "";
                }
                if (Contato == null)
                {
                    Contato = "";
                }
                if (EmailContato == null)
                {
                    EmailContato = "";
                }
                if (FoneContato == null)
                {
                    FoneContato = "";
                }

                if (Id == 0)
                {
                    sql = $"INSERT INTO FORNECEDORES " +
                          $"(NOME,CNPJ_CPF,CPF,INSTEST,ENDERECO,CIDADE,BAIRRO,ESTADO," +
                          $"CEP,CONTATO,EMAIL,FONE) " +
                          $"VALUES ('{Descricao.ToString().ToUpper()}'," +
                          $"'{CpfCnpj.ToString().Replace(",", ".")}','{Cpf.ToString().Replace(",", ".")}'," +
                          $"'{Ie.ToString().ToUpper()}','{Endereco.ToString().ToUpper()}'," +
                          $"'{Cidade.ToString().ToUpper()}','{Bairro.ToString().ToUpper()}'," +
                          $"'{ValorUF.ToString().ToUpper()}','{Cep.ToString().ToUpper()}'," +
                          $"'{Contato.ToString().ToUpper()}','{EmailContato.ToString().ToUpper()}'," +
                          $"'{FoneContato.ToString().ToUpper()}')";
                }
                else
                {
                    sql = $"UPDATE FORNECEDORES " +
                          $"SET NOME='{Descricao}'," +
                          $"CNPJ_CPF='{CpfCnpj.ToString().Replace(",", ".")}'," +
                          $"CPF='{Cpf.ToString().Replace(",", ".")}'," +
                          $"INSTEST='{Ie.ToString().Replace(",", ".")}'," +
                          $"ENDERECO='{Endereco.ToString().Replace(",", ".")}'," +
                          $"CIDADE='{Cidade.ToString().Replace(",", ".")}'," +
                          $"BAIRRO='{Bairro.ToString().Replace(",", ".")}'," +
                          $"ESTADO='{ValorUF.ToString().Replace(",", ".")}'," +
                          $"CEP='{Cep.ToString().Replace(",", ".")}'," +
                          $"CONTATO='{Contato.ToString().Replace(",", ".")}'," +
                          $"EMAIL='{EmailContato.ToString().Replace(",", ".")}'," +
                          $"FONE='{FoneContato.ToString().Replace(",", ".")}'" +
                          $" WHERE ID='{Id}'";
                }
                DAL objDAL = new DAL();
                objDAL.ExecutarComandoSQL(sql);
                objDAL.FechaComandoSQL();
            }
            catch (Exception error)
            {
            }
        }