Example #1
0
 public void PostRol(tbl_roles rol)
 {
     vsystem_ndcEntities db = new vsystem_ndcEntities();
     tbl_roles Rol = new tbl_roles();
     Rol.rolesid = rol.rolesid;
     Rol.descripcion = rol.descripcion;
     Rol.activo = rol.activo;
     db.tbl_roles.Add(Rol);
     db.SaveChanges();
 }
Example #2
0
        public int DeleteRol(int Id)
        {
            vsystem_ndcEntities db = new vsystem_ndcEntities();
            tbl_roles rol = new tbl_roles();
            rol = db.tbl_roles.Find(Id);
            if(rol != null)
            {
                try
                {
                    db.tbl_roles.Remove(rol);
                    db.SaveChanges();
                    return 1;
                }
                catch (SystemException)
                {
                    return 2;
                }

            }
            return 0;
        }
Example #3
0
        public List<tbl_roles> GetRolList()
        {
            string connectionString = "SERVER=104.236.126.219;DATABASE=vsystem_ndc;UID=ndc;PASSWORD=ndc01;";
            List<tbl_roles> list = new List<tbl_roles>();
            tbl_roles temp;

            MySqlConnection connection = new MySqlConnection(connectionString);
            string query = "SELECT * FROM tbl_roles";

            connection.Open();
            MySqlCommand cmd = new MySqlCommand(query, connection);
            MySqlDataReader dataReader = cmd.ExecuteReader();
            while (dataReader.Read())
            {
                temp = new tbl_roles();
                temp.activo = (dataReader["activo"].ToString().Equals("1") ? true : false);
                temp.descripcion = dataReader["descripcion"].ToString();
                temp.rolesid = (int)dataReader["rolesid"];
                list.Add(temp);

            }
            dataReader.Close();
            connection.Close();

            return list;
        }