public bool Inserir(SZ5 sz5)
        {
            StringBuilder sb = new StringBuilder();
            var _db = new Models.banco.bd();
            SqlCommand _cmd;
            bool enviar = false;
            sb.Append("EXEC PROC_PORTALAVANTLED_NOVO_CLIENTE '" + sz5.Z5_FILIAL + "','" + sz5.Z5_CODVEND + "','" +
                      sz5.Z5_CGC + "','" + sz5.Z5_RAZASOC + "' , ");
            sb.Append(" '" + sz5.Z5_NOMEABR + "','" + sz5.Z5_ENDEREC + "','" + sz5.Z5_ENDERNR + "','" +
                      sz5.Z5_ENDCOMP + "','" + sz5.Z5_BAIRRO + "','" + sz5.Z5_CIDADE + "', ");
            sb.Append(" '" + sz5.Z5_CDMUNIC + "','" + sz5.Z5_UF + "','" + sz5.Z5_PAIS + "','" + sz5.Z5_INSCEST +
                      "','" + sz5.Z5_CEP + "','" + sz5.Z5_TELEFDD + "', ");
            sb.Append(" '" + sz5.Z5_TELEFON + "','" + sz5.Z5_CELULAR + "','" + sz5.Z5_FAX + "','" +
                      sz5.Z5_CONTATO + "','" + sz5.Z5_SETOR + "', '" + sz5.Z5_DTCADAS + "' , ");
            sb.Append(" '" + sz5.Z5_CONDPAG + "','" + sz5.Z5_ENDPAG + "','" + sz5.Z5_ENDNRPG + "','" +
                      sz5.Z5_COMPPAG + "','" + sz5.Z5_BAIRROP + "','" + sz5.Z5_CEPPG + "' , ");
            sb.Append(" '" + sz5.Z5_CIDADEP + "','" + sz5.Z5_CDMUNPG + "','" + sz5.Z5_UFPG + "','" +
                      sz5.Z5_ENDENT + "','" + sz5.Z5_ENDNREN + "','" + sz5.Z5_COMPEN + "','" + sz5.Z5_BAIRROE +
                      "' ,");
            sb.Append(" '" + sz5.Z5_CEPEN + "','" + sz5.Z5_CIDADEN + "','" + sz5.Z5_CDMUNEN + "','" +
                      sz5.Z5_UFEN + "','" + sz5.Z5_EMAIL + "','" + sz5.Z5_EMAIL1 + "','" + sz5.Z5_OBSERV + "', ");
            sb.Append(" '" + sz5.Z5_OBS2 + "','" + sz5.Z5_COMIS + "','" + sz5.Z5_CONSFIN + "','" +
                      sz5.Z5_NMCOMPR + "','" + sz5.Z5_NMGEREN + "','" + sz5.Z5_PROPRIE + "', ");
            sb.Append(" '" + sz5.Z5_ANIVCOM + "','" + sz5.Z5_ANIVGER + "','" + sz5.Z5_ANIVPRO + "','" +
                      sz5.Z5_SUFRAMA + "','" + sz5.Z5_SUFRACR + "','" + sz5.Z5_SUFRADT + "', ");
            sb.Append(" '" + sz5.Z5_CNAE + "','" + sz5.Z5_CNAESEC + "','" + sz5.Z5_STATUS + "','" +
                      sz5.Z5_DESCWEB + "',  " + KeyTable() + ", '" + sz5.Z5_X_HORA + "' , '" + sz5.Z5_X_CANAL + "','" + sz5.Z5_X_SEGME + "','" + sz5.Z5_X_PERFI + "', '" + sz5.Z5_GRPTRIB + "' , '" + sz5.Z5_XREGESP + "' ");

            try
            {
                _db.Conectar();
                _cmd = new SqlCommand(sb.ToString(), _db.conn);
                _cmd.ExecuteNonQuery();
                enviar = true;
            }
            catch (SqlException h)
            {
                throw new Exception("Erro na inserção de dados" + h.Message);
            }
            catch (Exception t)
            {
                throw new Exception("Erro no acesso de dados" + t.Message);
            }
            finally
            {
                _db.Desconectar();
            }

            return enviar;
        }
        public List<SZ5> Verificar(string cpf)
        {
            var codigo = string.Empty;
            var sz5 = new SZ5();
            var dados = new List<SZ5>();
            StringBuilder sb = new StringBuilder();
            var _db = new Models.banco.bd();
            SqlCommand _cmd;
            SqlDataReader _ler;

            sb.Append(" SELECT Z5_CGC FROM SZ5010 WHERE Z5_CGC = '" + cpf + "' AND D_E_L_E_T_ = ''  ");

            _db.Conectar();
            try
            {
                _cmd = new SqlCommand(sb.ToString(), _db.conn);
                _ler = _cmd.ExecuteReader();
                while (_ler.Read())
                {
                    sz5.Z5_CGC = Convert.ToString(_ler["Z5_CGC"].ToString());
                }
                _ler.Close();
                dados.Add(sz5);
             }
            catch (SqlException f)
            {
                throw new Exception("Erro no Acesso de Dados" + f.Message);
            }
            catch (Exception g)
            {
                throw new Exception("Erro na Consulta de dados" + g.Message);
            }
            finally
            {
                _db.Desconectar();
            }

            return dados;
        }
 public HttpResponseMessage PostCadastro(SZ5 sz5_)
 {
     if (sz5_ == null)
         return Request.CreateResponse<SZ5>(HttpStatusCode.BadRequest, sz5_);
     else
     {
         try
         {
             if (Inserir(sz5_))
                 return Request.CreateResponse(HttpStatusCode.OK, "Cadastro Realizado" + sz5_.Z5_RAZASOC);
             else
                 return Request.CreateResponse(HttpStatusCode.NotFound, "Erro na Gravação ");
         }
         catch (Exception)
         {
             return Request.CreateResponse<SZ5>(HttpStatusCode.InternalServerError, sz5_);
         }
     }
 }