How could I adapt this C # code to Java?

2

Good evening how could you adapt this code to java?

  • This is my DAOCliente

    internal void getCliente(clsCliente e_cliente)
        {
            string bd = "Cinestar";
            SqlConnection cn = new SqlConnection("Data Source=localhost;Initial Catalog=" + bd + ";Integrated Security=True");
            SqlCommand cmd = new SqlCommand("usp_getCliente "+e_cliente.idCliente, cn);//lo que hace es Listarme todos los clientes con el id dado
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                e_cliente.setRegistro(System.Array.ConvertAll(dt.Rows[0].ItemArray, x => x.ToString().Trim()));
            }
        }
    
  • This is My BeanClient Class

    #region propiedades
    public int idCliente { get; set; }
    public string Nombres { get; set; }
    public string Apellidos { get; set; }
    public string Dni { get; set; }
    public string Contraseña { get; set; }
    public string Genero { get; set; }
    public string FechaNacimiento { get; set; }
    public string Direccion { get; set; }
    public int IdDistrito { get; set; }
    public string Correo { get; set; }
    public bool Eliminado { get; set; }
    public bool valido { get; set; }
    #endregion
    
    #region Metodos
    public void setRegistro(string [] aRegistro) {
        valido = aRegistro != null;
        if (valido)
        {
            idCliente = int.Parse(aRegistro[0]);
            Nombres = aRegistro[1];
            Apellidos = aRegistro[2];
            Dni = aRegistro[3];
            Contraseña = aRegistro[4];
            Genero = aRegistro[5];
            FechaNacimiento = aRegistro[6];
            Direccion = aRegistro[7];
            IdDistrito = int.Parse(aRegistro[8]);
            Correo = aRegistro[9];
            Eliminado = aRegistro[10] == "true";
        }
    }
    public object[] getRegistro()
    {
        return new object[] { idCliente, Nombres, Apellidos, Dni, Contraseña, Genero, FechaNacimiento, Direccion, IdDistrito, Correo, Eliminado };
    }
    

    -I have notions of how to do it but I find it an error I would appreciate your help

asked by Jcastillo 10.07.2017 в 02:00
source

0 answers