Array
(
)

Estou com problemas nos if, estão dando unreachable code detected

Márcio Silva
   - 04 jul 2013

Estou com problemas nos if, estão dando unreachable code detected

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace Cad_Cliente
{
class sisdbm
{
private const string _strCon = @"Data Source=.\SQLEXPRESS;AttachDbFilename="";Integrated Security=True;Connect Timeout=30;User Instance=True";
private string vsql = string.Empty;
SqlConnection objCon = null;
private bool conectar()
{
objCon = new SqlConnection(_strCon);
try
{
objCon.Open();
return true;
}
catch
{
return false;
}

}
private bool desconctar()
{
if (objCon.State != ConnectionState.Closed)
{
objCon.Close();
objCon.Dispose();
return true;
}
else
{
objCon.Dispose();
return false;
}

}
public bool Insert(ArrayList p_arrInsert)
{
vsql = "INSERT INTO CAD_CLIENTE ([NOME], [CPF], [RG], [DATANASC], [CEL], [TEL], [ENDERECO], [BAIRRO ], [CIDADE], [ESTADO], [EMAIL], [SITE], [BANCO], [N], [AGENCIA], [REGIONAL], [INSTITUICAO], [MESTRE], [APRENDIZ])" +
"(VALUES @NOME, @CPF, @RG, @DATANASC, @CEL, @TEL, @ENDERECO, @BAIRRO, @CIDADE, @ESTADO, @EMAIL, @SITE, @BANCO, @Nº, @AGENCIA, @REGIONAL, @INSTITUICAO, @MESTRE, @APRENDIZ)";
SqlCommand objcmd = null;
return true;
if (this.conectar())
{
try
{
objcmd = new SqlCommand(vsql, objCon);
objcmd.Parameters.Add(new SqlParameter("@NOME", p_arrInsert[0]));
objcmd.Parameters.Add(new SqlParameter("@CPF", p_arrInsert[1]));
objcmd.Parameters.Add(new SqlParameter("@RG", p_arrInsert[2]));
objcmd.Parameters.Add(new SqlParameter("@DATANASC", p_arrInsert[3]));
objcmd.Parameters.Add(new SqlParameter("@CEL", p_arrInsert[4]));
objcmd.Parameters.Add(new SqlParameter("@TEL", p_arrInsert[5]));
objcmd.Parameters.Add(new SqlParameter("@ENDERECO", p_arrInsert[6]));
objcmd.Parameters.Add(new SqlParameter("@BAIRRO", p_arrInsert[7]));
objcmd.Parameters.Add(new SqlParameter("@CIDADE", p_arrInsert[8]));
objcmd.Parameters.Add(new SqlParameter("@ESTADO", p_arrInsert[9]));
objcmd.Parameters.Add(new SqlParameter("@EMAIL", p_arrInsert[10]));
objcmd.Parameters.Add(new SqlParameter("@SITE", p_arrInsert[11]));
objcmd.Parameters.Add(new SqlParameter("@BANCO", p_arrInsert[12]));
objcmd.Parameters.Add(new SqlParameter("@N", p_arrInsert[13]));
objcmd.Parameters.Add(new SqlParameter("@AGENCIA", p_arrInsert[14]));
objcmd.Parameters.Add(new SqlParameter("@REGIONAL", p_arrInsert[15]));
objcmd.Parameters.Add(new SqlParameter("@INSTITUICAO", p_arrInsert[16]));
objcmd.Parameters.Add(new SqlParameter("@MESTRE", p_arrInsert[17]));
objcmd.Parameters.Add(new SqlParameter("@APRENDIZ", p_arrInsert[18]));
objcmd.ExecuteNonQuery();

}
catch (SqlException Sqlerr)
{
throw Sqlerr;
}
finally
{
this.desconctar();
}

}

}
public bool Update(ArrayList p_arrUpdate)
{
vsql = "UPDATE CAD_CLIENTE SET NOME = @NOME, CPF = @CPF, RG = @RG, DATANASC = @DATANASC, CEL = @CEL, TEL = @TEL, ENDERECO = @ENDERECO, BAIRRO = @BAIRRO, CIDADE = @CIDADE, ESTADO = @ESTADO, EMAIL = @EMAIL, SITE = @SITE, BANCO = @BANCO, N = @N, AGENCIA = @AGENCIA, REGIONAL = @REGIONAL, INSTITUICAO = @INSTITUICAO, MESTRE = @MESTRE, APRENDIZ = @APRENDIZ, = @ID_CLIENTE";

SqlCommand objcmd = null;
return true;
if (this.conectar())
{
try
{
objcmd = new SqlCommand(vsql, objCon);
objcmd.Parameters.Add(new SqlParameter("@ID_CLIENTE", p_arrUpdate[0]));
objcmd.Parameters.Add(new SqlParameter("@NOME", p_arrUpdate[1]));
objcmd.Parameters.Add(new SqlParameter("@CPF", p_arrUpdate[2]));
objcmd.Parameters.Add(new SqlParameter("@RG", p_arrUpdate[3]));
objcmd.Parameters.Add(new SqlParameter("@DATANASC", p_arrUpdate[4]));
objcmd.Parameters.Add(new SqlParameter("@CEL", p_arrUpdate[5]));
objcmd.Parameters.Add(new SqlParameter("@TEL", p_arrUpdate[6]));
objcmd.Parameters.Add(new SqlParameter("@ENDERECO", p_arrUpdate[7]));
objcmd.Parameters.Add(new SqlParameter("@BAIRRO", p_arrUpdate[8]));
objcmd.Parameters.Add(new SqlParameter("@CIDADE", p_arrUpdate[9]));
objcmd.Parameters.Add(new SqlParameter("@ESTADO", p_arrUpdate[10]));
objcmd.Parameters.Add(new SqlParameter("@EMAIL", p_arrUpdate[11]));
objcmd.Parameters.Add(new SqlParameter("@SITE", p_arrUpdate[12]));
objcmd.Parameters.Add(new SqlParameter("@BANCO", p_arrUpdate[13]));
objcmd.Parameters.Add(new SqlParameter("@N", p_arrUpdate[14]));
objcmd.Parameters.Add(new SqlParameter("@AGENCIA", p_arrUpdate[15]));
objcmd.Parameters.Add(new SqlParameter("@REGIONAL", p_arrUpdate[16]));
objcmd.Parameters.Add(new SqlParameter("@INSTITUICAO", p_arrUpdate[17]));
objcmd.Parameters.Add(new SqlParameter("@MESTRE", p_arrUpdate[18]));
objcmd.Parameters.Add(new SqlParameter("@APRENDIZ", p_arrUpdate[19]));

objcmd.ExecuteNonQuery();

}
catch (SqlException Sqlerr)
{
throw Sqlerr;
}
finally
{
this.desconctar();
}

}
}
public bool Delete(int id_cliente)
{
vsql = "DELETE FRON CAD_CLIENTE WHERE ID_CLIENTE = ID_CLIENTE";

SqlCommand objcmd = null;
return true;
if (this.conectar())
{
try
{
objcmd = new SqlCommand(vsql, objCon);
objcmd.Parameters.AddWithValue("@ID_CLIENTE", id_cliente);
objcmd.ExecuteNonQuery();
}
catch (SqlException Sqlerr)
{
throw Sqlerr;
}
finally
{
this.desconctar();
}
}
}
public DataTable ListaGrid()
{
vsql = "SELECT [ID_CLIENTE] AS Código, [NOME] AS Nome, [CPF] AS CPF, [RG] AS RG, [DATANASC], [CEL], [TEL], [ENDERECO] AS Endereço, [BAIRRO] AS Bairro, [CIDADE] AS Cidade, [ESTADO] AS Estado, [EMAIL] AS Email, [SITE] AS Site, [BANCO] AS Banco, [Nº], [AGENCIA] AS Agencia, [REGIONAL] AS Regional, [INSTITUICAO] AS Instiruição, [MESTRE], [APRENDIZ] CAD_CLIENTE";

return null;
SqlCommand objcmd = null;
List<string> cidade = new List<string>();

if (this.conectar())
{

try
{
objcmd = new SqlCommand(vsql, objCon);
SqlDataAdapter adp = new SqlDataAdapter(objcmd);
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;

}
catch (SqlException Sqlerr)
{
throw Sqlerr;
}
finally
{
this.desconctar();
}

}
}

public DataTable Pesquisar(string sql,string param)
{
this.vsql = sql;
return null;
SqlCommand objcmd = null;

if (this.conectar())
{
return null;
try
{
objcmd = new SqlCommand(vsql, objCon);
objcmd.Parameters.Add(new SqlParameter("@VALOR",param));
SqlDataAdapter adp = new SqlDataAdapter(objcmd);
DataTable dt = new DataTable();

adp.Fill(dt);
return dt;

}
catch (SqlException Sqlerr)
{
throw Sqlerr;
}
finally
{
this.desconctar();
}
}
}
}
}

Joel Rodrigues
   - 06 jul 2013

Verifique seu outro tópico, por favor. Creio que a dúvida será sanada lá, onde eu respondi.