示例#1
0
        public void Incluir(ModeloCliente modelo)
        {
            if (modelo.CliNome.Trim().Length == 0)
            {
                throw new Exception("O nome do cliente é obrigatório");
            }


            if (modelo.CliCpfcnpj.Trim().Length == 0)
            {
                throw new Exception("O CPF/CNPJ é obrigatorio");
            }

            if(modelo.CliTipo == 0)
            {
                if(Validacao.ValidaCPF.IsCpf(modelo.CliCpfcnpj) == false)
                {
                    throw new Exception("CPF Invalido");
                }
            }
            else
            {
                if(Validacao.ValidaCNPJ.IsCnpj(modelo.CliCpfcnpj)== false)
                {
                    throw new Exception("CNPJ Invalido");
                }
            }
            //verifica CPF/CNPJ

            if (modelo.CliRgie.Trim().Length == 0)
            {
                throw new Exception("O RG/IE é obrigatorio");
            }

            if (modelo.CliFone.Trim().Length == 0)
            {
                throw new Exception("O Telefone é obrigatorio");
            }

            //cli_tipo => 0=fisica ; 1=juridica

            string strRegex = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}" +
                "\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\" +
                ".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
            Regex re = new Regex(strRegex);

            if (!re.IsMatch(modelo.CliEmail))
            {
                throw new Exception("Digite um email válido");
            }


            DALCliente DALObj = new DALCliente(conexao);
            DALObj.Incluir(modelo);
        }
        public void Incluir(ModeloCliente modelo)
        {
            if (modelo.CliNome.Trim().Length == 0)
            {
                throw new Exception("O nome do Cliente é obrigatório");
            }
            if (modelo.CliCidade.Trim().Length == 0)
            {
                throw new Exception("O nome da Cidade é obrigatório");
            }
            if (modelo.CliEstado.Trim().Length == 0)
            {
                throw new Exception("O nome do estado é obrigatório");
            }

            DALCliente DALobj = new DALCliente(conexao);
            DALobj.Incluir(modelo);
        }
示例#3
0
        public void Incluir(ModeloCliente obj)
        {
            if (obj.CliNome.Trim().Length == 0)
            {
                throw new Exception("O nome do cliente é obrigatório");
            }

            if (obj.CliCPF_CNPJ.Trim().Length == 0)
            {
                throw new Exception("O CNPJ/CPF é obrigatório");
            }

            if (obj.CliCep.Trim().Length <= 0)
            {
                throw new Exception("O CEP do cliente é obrigatório");
            }

            if (obj.CliEndereco.Trim().Length <= 0)
            {
                throw new Exception("O endereço do cliente é obrigatório");
            }

            if (obj.CliBairro.Trim().Length <= 0)
            {
                throw new Exception("O bairro do cliente é obrigatório");
            }
            if (obj.CliFone.Trim().Length <= 0 || obj.CliCel.Trim().Length <=0)
            {
                throw new Exception("Pelo menos um contato do cliente é obrigatório");
            }
            if (obj.CliEndNumero.Trim().Length <= 0)
            {
                throw new Exception("O Número resedencial do cliente é obrigatório");
            }
            if (obj.CliCidade.Trim().Length <= 0)
            {
                throw new Exception("A cidade do cliente é obrigatório");
            }
            if (obj.CliEstado.Trim().Length <= 0)
            {
                throw new Exception("O estado do cliente é obrigatório");
            }

            DALCliente DALobj = new DALCliente(conexao);
            DALobj.Incluir(obj);
        }