コード例 #1
0
        public static List <Socio> BuscarPorActivo(bool activo)
        {
            SqlCommand    cmd;
            SqlDataReader rd;
            string        select;
            List <Socio>  lista;
            Socio         socio;
            int           act;

            act    = Convert.ToInt32(activo);
            select = "select * from socio where bActivo=" + act;
            lista  = new List <Socio> ();

            cmd = new SqlCommand(select, BD.Con);
            rd  = cmd.ExecuteReader();

            while (rd.Read())
            {
                socio             = new Socio();
                socio.SocioId     = Convert.ToInt32(rd [0]);
                socio.Nombre      = rd [1].ToString();
                socio.Apellido    = rd [2].ToString();
                socio.FechaDeAlta = Convert.ToDateTime(rd [3]);
                socio.FechaDeBaja = Convert.ToDateTime(rd [4]);
                socio.Activo      = Convert.ToBoolean(rd [5]);
                lista.Add(socio);
            }

            rd.Close();
            return(lista);
        }
コード例 #2
0
 public static void Guardar(Socio socio)
 {
     if (socio.SocioId == 0)
     {
         Ingresar(socio);
     }
     else
     {
         Modificar(socio);
     }
 }
コード例 #3
0
        private static void Modificar(Socio socio)
        {
            SqlCommand cmd;
            string     update;
            int        act;

            act    = Convert.ToInt32(socio.Activo);
            update = "update Socio set cNombre = '" + socio.Nombre + "', cApellido = '" + socio.Apellido + "', dFechaDeAlta = '" + socio.FechaDeAlta + "', dFechaDeBaja = '" + socio.FechaDeBaja + "', bActivo = " + act + " where iSocioId =" + socio.SocioId;

            cmd = new SqlCommand(update, BD.Con);
            cmd.ExecuteNonQuery();
        }
コード例 #4
0
        private static void Ingresar(Socio socio)
        {
            SqlCommand    cmd;
            SqlDataReader rd;
            string        insert;
            string        select;

            insert = "insert into Socio (cNombre, cApellido, dFechaDeAlta, dFechaDeBaja ,bActivo) values ('" + socio.Nombre + "','" + socio.Apellido + "', '" + socio.FechaDeAlta + "', '" + socio.FechaDeBaja + "', 1 )";
            select = "select IDENT_CURRENT ('Socio')";

            cmd = new SqlCommand(insert, BD.Con);
            cmd.ExecuteNonQuery();

            cmd = new SqlCommand(select, BD.Con);
            rd  = cmd.ExecuteReader();
            rd.Read();
            socio.SocioId = Convert.ToInt32(rd [0]);
            rd.Close();
        }